summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-01-28 22:25:28 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-01-28 22:25:28 +0100
commitc0e4cca24d58be685adf79c355dedca5d1885c78 (patch)
tree8e8d9d9ca5b7f137c26b1d0edb5b1fc604cf00b4
parent82dfadb950a52bbc0cdccb5b8f224a8b49b79ea3 (diff)
Fixed monolog readings not being synchronized when using more than one
thread. This is solved by moving last_user, in_monolog and monolog_len to the heap. These are already inside the user_mutex lock when used.
-rw-r--r--parsing.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/parsing.c b/parsing.c
index e554907..c66fb6f 100644
--- a/parsing.c
+++ b/parsing.c
@@ -16,12 +16,13 @@
#define LINE_BUFFER_SIZE 0x400
#define TIME_BUFFER_SIZE 0xf
-pthread_mutex_t user_mutex, word_mutex;
+static pthread_mutex_t user_mutex, word_mutex;
+
+static struct user_t *last_user = NULL;
+static int in_monolog = 0, monolog_len = 0;;
static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *rs) {
char line[LINE_BUFFER_SIZE];
- struct user_t *last_user = NULL;
- int in_monolog = 0, monolog_len = 0;;
while(fgets(line, LINE_BUFFER_SIZE, f)) {
int rc;
@@ -161,6 +162,9 @@ void process(int thread_n) {
} else
printf("\tParsing %s\n", file->path);
+ last_user = NULL;
+ in_monolog = monolog_len = 0;
+
pthread_t *threads;
threads = malloc(sizeof(pthread_t) * thread_n);
struct thread_arg_t ta;