From c0e4cca24d58be685adf79c355dedca5d1885c78 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Thu, 28 Jan 2010 22:25:28 +0100 Subject: 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. --- parsing.c | 10 +++++++--- 1 file 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; -- cgit v1.2.3