comparison src/c/urweb.c @ 1551:5175bed443f9

Warn about concurrency issues with message-passing
author Adam Chlipala <adam@chlipala.net>
date Sun, 28 Aug 2011 14:43:30 -0400
parents 3c0803c1acd7
children c3b5cf5c2f98
comparison
equal deleted inserted replaced
1550:daf71c76707e 1551:5175bed443f9
218 static void release_client(client *c) { 218 static void release_client(client *c) {
219 pthread_mutex_unlock(&c->pull_lock); 219 pthread_mutex_unlock(&c->pull_lock);
220 pthread_mutex_lock(&c->lock); 220 pthread_mutex_lock(&c->lock);
221 --c->refcount; 221 --c->refcount;
222 pthread_mutex_unlock(&c->lock); 222 pthread_mutex_unlock(&c->lock);
223
224 } 223 }
225 224
226 static const char begin_msgs[] = "Content-type: text/plain\r\n\r\n"; 225 static const char begin_msgs[] = "Content-type: text/plain\r\n\r\n";
227 226
228 static client *find_client(unsigned id) { 227 static client *find_client(unsigned id) {
3183 3182
3184 for (i = 0; i < ctx->used_deltas; ++i) { 3183 for (i = 0; i < ctx->used_deltas; ++i) {
3185 delta *d = &ctx->deltas[i]; 3184 delta *d = &ctx->deltas[i];
3186 client *c = find_client(d->client); 3185 client *c = find_client(d->client);
3187 3186
3188 assert (c != NULL && c->mode == USED); 3187 assert (c != NULL);
3188 assert(c->mode == USED);
3189 3189
3190 client_send(c, &d->msgs, ctx->script.start, uw_buffer_used(&ctx->script)); 3190 client_send(c, &d->msgs, ctx->script.start, uw_buffer_used(&ctx->script));
3191 } 3191 }
3192 3192
3193 if (ctx->client) 3193 if (ctx->client)