summaryrefslogtreecommitdiff
path: root/parsing.c
diff options
context:
space:
mode:
Diffstat (limited to 'parsing.c')
-rw-r--r--parsing.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/parsing.c b/parsing.c
index 3f38681..ac99c82 100644
--- a/parsing.c
+++ b/parsing.c
@@ -280,12 +280,17 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
}
pcre_copy_named_substring(rs->log_opened, line, ovector, rc, "date", date, DATE_BUFFER_SIZE);
+
+ /* TODO: Find a better way around this.
+ * Locking early to allow setting of correct date before any other threads start setting time
+ * before date is set. */
+ pthread_mutex_lock(&time_mutex);
if(!strptime(date, log_date_format, &now)) {
fprintf(stderr, "log fail: %s\n", date);
+ pthread_mutex_unlock(&time_mutex);
continue;
}
- pthread_mutex_lock(&time_mutex);
now_global = now;
pthread_mutex_unlock(&time_mutex);
@@ -302,12 +307,15 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
}
pcre_copy_named_substring(rs->day_changed, line, ovector, rc, "date", date, DATE_BUFFER_SIZE);
+
+ /* See comment in log_opened parsing. */
+ pthread_mutex_lock(&time_mutex);
if(!strptime(date, day_date_format, &now)) {
fprintf(stderr, "day fail: %s\n", date);
+ pthread_mutex_unlock(&time_mutex);
continue;
}
- pthread_mutex_lock(&time_mutex);
now_global = now;
pthread_mutex_unlock(&time_mutex);