# HG changeset patch # User Adam Chlipala # Date 1238694539 14400 # Node ID b6a8425e1b1fc3a06853bda3436acad3e1ee75b6 # Parent 829887ca47a6c76cf0ee22d7ddb70d243e1941d5 Make sure only one pull request runs at a time for each client diff -r 829887ca47a6 -r b6a8425e1b1f src/c/urweb.c --- a/src/c/urweb.c Thu Apr 02 13:31:13 2009 -0400 +++ b/src/c/urweb.c Thu Apr 02 13:48:59 2009 -0400 @@ -94,7 +94,7 @@ usage mode; int pass; struct client *next; - pthread_mutex_t lock; + pthread_mutex_t lock, pull_lock; buf msgs; int sock; time_t last_contact; @@ -125,6 +125,7 @@ c = malloc(sizeof(client)); c->id = n_clients-1; pthread_mutex_init(&c->lock, NULL); + pthread_mutex_init(&c->pull_lock, NULL); buf_init(&c->msgs, 0); clients[n_clients-1] = c; } @@ -151,12 +152,15 @@ pthread_mutex_lock(&c->lock); ++c->refcount; pthread_mutex_unlock(&c->lock); + pthread_mutex_lock(&c->pull_lock); } static void release_client(client *c) { + pthread_mutex_unlock(&c->pull_lock); pthread_mutex_lock(&c->lock); --c->refcount; pthread_mutex_unlock(&c->lock); + } static const char begin_msgs[] = "HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\n";