From 09bcceb88ae4a548c573098fc35a884fe0cc96ad Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Wed, 1 May 2013 10:19:47 +0000 Subject: [PATCH 1/1] --- src/main.c | 5 ++++- src/ttrss_cache.c | 17 ++++++++++++++--- src/ttrss_wsasync.c | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 64dfbe8..fa5e38a 100644 --- a/src/main.c +++ b/src/main.c @@ -362,7 +362,7 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data) GtkTreeIter iter; GtkTreeModel *model; struct headline *headline; - char *str; + char *str, *date; log_debug("headline_cursor_changed_cbk()"); @@ -390,10 +390,13 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data) } model = gtk_tree_view_get_model(w_headlinetree); + date = headline_get_date(headline); gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_HEADLINE_TITLE, headline->title, + COL_HEADLINE_DATE, date, -1); + g_free(date); } else { log_debug("headline not found"); } diff --git a/src/ttrss_cache.c b/src/ttrss_cache.c index be5b119..d13b534 100644 --- a/src/ttrss_cache.c +++ b/src/ttrss_cache.c @@ -25,11 +25,13 @@ #include #include +#include #include "io.h" #include "log.h" #include "ttrss_cache.h" +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static char *cache_dir; static const char *get_cache_dir() @@ -79,8 +81,11 @@ void cache_put(const struct headline *h, const char *content) path = content_get_path(h); - if (path) + if (path) { + pthread_mutex_lock(&lock); file_set_content(path, content); + pthread_mutex_unlock(&lock); + } g_free(path); } @@ -93,10 +98,12 @@ int cache_exists(const struct headline *h) path = content_get_path(h); + pthread_mutex_lock(&lock); if (stat(path, &s) == -1) result = 0; else result = 1; + pthread_mutex_unlock(&lock); g_free(path); @@ -107,11 +114,15 @@ char *cache_get(const struct headline *h) { char *content, *path; + path = content_get_path(h); - if (path) + if (path) { + pthread_mutex_lock(&lock); content = file_get_content(path); - else + pthread_mutex_unlock(&lock); + } else { content = NULL; + } g_free(path); diff --git a/src/ttrss_wsasync.c b/src/ttrss_wsasync.c index d5dd482..cb30f84 100644 --- a/src/ttrss_wsasync.c +++ b/src/ttrss_wsasync.c @@ -60,6 +60,7 @@ void *loop() if (rp) json_object_put(rp); cur++; + usleep(100000); } free(tmp); } -- 2.7.4