projects
/
prss.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[prss.git]
/
src
/
ttrss_cache.c
diff --git
a/src/ttrss_cache.c
b/src/ttrss_cache.c
index
be5b119
..
d13b534
100644
(file)
--- a/
src/ttrss_cache.c
+++ b/
src/ttrss_cache.c
@@
-25,11
+25,13
@@
#include <unistd.h>
#include <glib.h>
#include <unistd.h>
#include <glib.h>
+#include <pthread.h>
#include "io.h"
#include "log.h"
#include "ttrss_cache.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()
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);
path = content_get_path(h);
- if (path)
+ if (path) {
+ pthread_mutex_lock(&lock);
file_set_content(path, content);
file_set_content(path, content);
+ pthread_mutex_unlock(&lock);
+ }
g_free(path);
}
g_free(path);
}
@@
-93,10
+98,12
@@
int cache_exists(const struct headline *h)
path = content_get_path(h);
path = content_get_path(h);
+ pthread_mutex_lock(&lock);
if (stat(path, &s) == -1)
result = 0;
else
result = 1;
if (stat(path, &s) == -1)
result = 0;
else
result = 1;
+ pthread_mutex_unlock(&lock);
g_free(path);
g_free(path);
@@
-107,11
+114,15
@@
char *cache_get(const struct headline *h)
{
char *content, *path;
{
char *content, *path;
+
path = content_get_path(h);
path = content_get_path(h);
- if (path)
+ if (path) {
+ pthread_mutex_lock(&lock);
content = file_get_content(path);
content = file_get_content(path);
- else
+ pthread_mutex_unlock(&lock);
+ } else {
content = NULL;
content = NULL;
+ }
g_free(path);
g_free(path);