(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 1 May 2013 10:19:47 +0000 (10:19 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 1 May 2013 10:19:47 +0000 (10:19 +0000)
src/main.c
src/ttrss_cache.c
src/ttrss_wsasync.c

index 64dfbe8..fa5e38a 100644 (file)
@@ -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");
        }
index be5b119..d13b534 100644 (file)
 #include <unistd.h>
 
 #include <glib.h>
+#include <pthread.h>
 
 #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);
 
index d5dd482..cb30f84 100644 (file)
@@ -60,6 +60,7 @@ void *loop()
                                if (rp)
                                        json_object_put(rp);
                                cur++;
+                               usleep(100000);
                        }
                        free(tmp);
                }