On Sun, Oct 04, 2015 at 07:22:40PM BST, Jérémie Courrèges-Anglas wrote:
> 
> +cc MAINTAINER
> 
> Stuart Henderson <[email protected]> writes:
> 
> > On 2015/10/04 16:18, Raf Czlonka wrote:
> >> On Sun, Oct 04, 2015 at 01:30:15PM BST, Stuart Henderson wrote:
> >> > On 2015/10/04 12:04, Raf Czlonka wrote:
> >> > > Hi all,
> >> > > 
> >> > > As suggested in the FAQ, I have emailed the port maintainer first but
> >> > > hadn't heard back so forwarding the email here.
> >> > 
> >> > Can you try running with the patch suggested in
> >> > https://marc.info/?l=openbsd-ports&m=144257374414248&w=2 and see if you
> >> > trigger the newly added log message?
> >> > 
> >> 
> >> Hi Stuart,
> >> 
> >> This was the very thread that prompted me to finally send an email to
> >> ports@ about the issue.
> >> 
> >> The OP experiences problems on amd64, the platform on which newsbeuter
> >> always worked fine for me - hence my i386-specific subject.
> >> 
> >> Nevertheless, I had built a package with the aforementioned patch -
> >> still the same issue.
> >> 
> >> Thanks for quick reply.
> >> 
> >> Raf
> >> 
> >
> > I wonder if it got fixed in any of the updates upstream, can you try this?
> > If you don't already have g++ 4.9 installed (eg++ doesn't exist) then 
> > pkg_add
> > it first, you'll be there for ages if you have to build it from ports.
> 
> I also had a diff for newsbeuter-2.9 but given the big changes - c++11
> and wordexp - I kinda lost interest. ;)
> 
> Looking at the differences between 2.7 and 2.9, I doubt that this issue
> got fixed.  newsbeuter stores rss feeds and items timestamps as integers
> in cache.db, an sqlite database.  sqlite3 uses 64 bits integers under
> the hood, but the sqlite3 format strings used in newsbeuter specify '%u'
> for timestamps.  This can't work on i386, and may also be the reason for
> a weird time_t value on amd64 in
> https://marc.info/?l=openbsd-ports&m=144251853400773&w=2 .
> 
> I can easily reproduce on i386 the crashes experienced by Raf, the
> following patch seems to fix those, and also addresses other similar
> problems.  I could port it to 2.9 for inclusion in the ports tree, but
> maybe it would be better to contact upstream, and fix both wordexp and
> time_t problems there first.
> 
> Anyway, here's the patch for 2.7.  Thoughts?

This has fixed the issue for me - newsbeuter is now working as expected.

Thanks a lot!

Raf

> Index: patches/patch-src_cache_cpp
> ===================================================================
> RCS file: patches/patch-src_cache_cpp
> diff -N patches/patch-src_cache_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_cache_cpp       4 Oct 2015 17:57:35 -0000
> @@ -0,0 +1,77 @@
> +$OpenBSD$
> +--- src/cache.cpp.orig       Tue Aug 27 14:20:39 2013
> ++++ src/cache.cpp    Sun Oct  4 19:56:03 2015
> +@@ -80,7 +80,7 @@ static int lastmodified_callback(void * handler, int a
> +     } else {
> +             result->etag = "";
> +     }
> +-    LOG(LOG_INFO, "lastmodified_callback: lastmodified = %d etag = %s", 
> result->lastmodified, result->etag.c_str());
> ++    LOG(LOG_INFO, "lastmodified_callback: lastmodified = %lld etag = %s", 
> (long long)result->lastmodified, result->etag.c_str());
> +     return 0;
> + }
> + 
> +@@ -295,7 +295,7 @@ void cache::fetch_lastmodified(const std::string& feed
> +     }
> +     t = result.lastmodified;
> +     etag = result.etag;
> +-    LOG(LOG_DEBUG, "cache::fetch_lastmodified: t = %d etag = %s", t, 
> etag.c_str());
> ++    LOG(LOG_DEBUG, "cache::fetch_lastmodified: t = %lld etag = %s", (long 
> long)t, etag.c_str());
> + }
> + 
> + void cache::update_lastmodified(const std::string& feedurl, time_t t, const 
> std::string& etag) {
> +@@ -306,7 +306,7 @@ void cache::update_lastmodified(const std::string& fee
> +     scope_mutex lock(&mtx);
> +     std::string query = "UPDATE rss_feed SET ";
> +     if (t > 0)
> +-            query.append(utils::strprintf("lastmodified = '%d'", t));
> ++            query.append(utils::strprintf("lastmodified = '%lld'", (long 
> long)t));
> +     if (etag.length() > 0)
> +             query.append(utils::strprintf("%c etag = %s", (t > 0 ? ',' : ' 
> '), prepare_query("'%q'", etag.c_str()).c_str()));
> +     query.append(" WHERE rssurl = ");
> +@@ -643,9 +643,9 @@ void cache::update_rssitem_unlocked(std::tr1::shared_p
> +             }
> +     } else {
> +             std::string insert = prepare_query("INSERT INTO rss_item 
> (guid,title,author,url,feedurl,pubDate,content,unread,enclosure_url,enclosure_type,enqueued,
>  base) "
> +-                                                            "VALUES 
> ('%q','%q','%q','%q','%q','%u','%q','%d','%q','%q',%d, '%q')",
> ++                                                            "VALUES 
> ('%q','%q','%q','%q','%q','%lld','%q','%d','%q','%q',%d, '%q')",
> +                                                             
> item->guid().c_str(), item->title_raw().c_str(), item->author_raw().c_str(), 
> +-                                                            
> item->link().c_str(), feedurl.c_str(), item->pubDate_timestamp(), 
> item->description_raw().c_str(), (item->unread() ? 1 : 0),
> ++                                                            
> item->link().c_str(), feedurl.c_str(), (long long)item->pubDate_timestamp(), 
> item->description_raw().c_str(), (item->unread() ? 1 : 0),
> +                                                             
> item->enclosure_url().c_str(), item->enclosure_type().c_str(), 
> item->enqueued() ? 1 : 0, item->get_base().c_str());
> +             LOG(LOG_DEBUG,"running query: %s", insert.c_str());
> +             rc = sqlite3_exec(db,insert.c_str(),NULL,NULL,NULL);
> +@@ -715,9 +715,9 @@ void cache::update_rssitem_unread_and_enqueued(rss_ite
> +             }
> +     } else {
> +             std::string insert = prepare_query("INSERT INTO rss_item 
> (guid,title,author,url,feedurl,pubDate,content,unread,enclosure_url,enclosure_type,enqueued,flags,base)
>  "
> +-                                                                            
> "VALUES ('%q','%q','%q','%q','%q','%u','%q','%d','%q','%q',%d, '%q', '%q')",
> ++                                                                            
> "VALUES ('%q','%q','%q','%q','%q','%lld','%q','%d','%q','%q',%d, '%q', '%q')",
> +                                                                             
> item->guid().c_str(), item->title_raw().c_str(), item->author_raw().c_str(), 
> +-                                                                            
> item->link().c_str(), feedurl.c_str(), item->pubDate_timestamp(), 
> item->description_raw().c_str(), item->unread() ? 1 : 0,
> ++                                                                            
> item->link().c_str(), feedurl.c_str(), (long long)item->pubDate_timestamp(), 
> item->description_raw().c_str(), item->unread() ? 1 : 0,
> +                                                                             
> item->enclosure_url().c_str(), item->enclosure_type().c_str(), 
> item->enqueued() ? 1 : 0, item->flags().c_str(), 
> +                                                                             
> item->get_base().c_str());
> +             LOG(LOG_DEBUG,"running query: %s", insert.c_str());
> +@@ -753,9 +753,9 @@ void cache::update_rssitem_unread_and_enqueued(std::tr
> +             }
> +     } else {
> +             std::string insert = prepare_query("INSERT INTO rss_item 
> (guid,title,author,url,feedurl,pubDate,content,unread,enclosure_url,enclosure_type,enqueued,flags,base)
>  "
> +-                                                                            
> "VALUES ('%q','%q','%q','%q','%q','%u','%q','%d','%q','%q',%d, '%q', '%q')",
> ++                                                                            
> "VALUES ('%q','%q','%q','%q','%q','%lld','%q','%d','%q','%q',%d, '%q', '%q')",
> +                                                                             
> item->guid().c_str(), item->title_raw().c_str(), item->author_raw().c_str(), 
> +-                                                                            
> item->link().c_str(), feedurl.c_str(), item->pubDate_timestamp(), 
> item->description_raw().c_str(), (item->unread() ? 1 : 0),
> ++                                                                            
> item->link().c_str(), feedurl.c_str(), (long long)item->pubDate_timestamp(), 
> item->description_raw().c_str(), (item->unread() ? 1 : 0),
> +                                                                             
> item->enclosure_url().c_str(), item->enclosure_type().c_str(), 
> item->enqueued() ? 1 : 0, item->flags().c_str(),
> +                                                                             
> item->get_base().c_str());
> +             LOG(LOG_DEBUG,"running query: %s", insert.c_str());
> +@@ -876,8 +876,8 @@ void cache::clean_old_articles() {
> +     if (days > 0) {
> +             time_t old_date = time(NULL) - days*24*60*60;
> + 
> +-            std::string query(utils::strprintf("DELETE FROM rss_item WHERE 
> pubDate < %d", old_date));
> +-            LOG(LOG_DEBUG, "cache::clean_old_articles: about to delete 
> articles with a pubDate older than %d", old_date);
> ++            std::string query(utils::strprintf("DELETE FROM rss_item WHERE 
> pubDate < %lld", (long long)old_date));
> ++            LOG(LOG_DEBUG, "cache::clean_old_articles: about to delete 
> articles with a pubDate older than %lld", (long long)old_date);
> +             int rc = sqlite3_exec(db, query.c_str(), NULL, NULL, NULL);
> +             LOG(LOG_DEBUG, "cache::clean_old_artgicles: old article delete 
> result: rc = %d", rc);
> +     } else {
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to