gettime: locking fix and debug check for identical sequence
authorJens Axboe <axboe@kernel.dk>
Mon, 17 Dec 2012 13:23:47 +0000 (14:23 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Dec 2012 13:23:47 +0000 (14:23 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
gettime.c

index bf35c7164007b16353a0b6faa4aaa196154155fe..0683bd1552093298b4a868e08ee1edf97ad80a62 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -388,8 +388,8 @@ static void *clock_thread_fn(void *data)
                return (void *) 1;
        }
 
-       pthread_mutex_unlock(&t->started);
        pthread_mutex_lock(&t->lock);
+       pthread_mutex_unlock(&t->started);
 
        c = &t->entries[0];
        for (i = 0; i < CLOCK_ENTRIES; i++, c++) {
@@ -414,6 +414,9 @@ static int clock_cmp(const void *p1, const void *p2)
        const struct clock_entry *c1 = p1;
        const struct clock_entry *c2 = p2;
 
+       if (c1->seq == c2->seq)
+               log_err("cs: bug in atomic sequence!\n");
+
        return c1->seq - c2->seq;
 }