~jsvoboda/helenos/dnsr

« back to all changes in this revision

Viewing changes to uspace/srv/net/udp/assoc.c

  • Committer: Jiri Svoboda
  • Date: 2012-08-13 10:40:17 UTC
  • Revision ID: jiri@wiwaxia-20120813104017-t9y6pdrjuky39557
Terminate UDP receive fibril when socket is closed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
263
263
        log_msg(LVL_DEBUG, "udp_assoc_recv()");
264
264
 
265
265
        fibril_mutex_lock(&assoc->lock);
266
 
        while (list_empty(&assoc->rcv_queue)) {
 
266
        while (list_empty(&assoc->rcv_queue) && !assoc->reset) {
267
267
                log_msg(LVL_DEBUG, "udp_assoc_recv() - waiting");
268
268
                fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock);
269
269
        }
270
270
 
 
271
        if (assoc->reset) {
 
272
                log_msg(LVL_DEBUG, "udp_assoc_recv() - association was reset");
 
273
                fibril_mutex_unlock(&assoc->lock);
 
274
                return ECONNABORTED;
 
275
        }
 
276
 
271
277
        log_msg(LVL_DEBUG, "udp_assoc_recv() - got a message");
272
278
        link = list_first(&assoc->rcv_queue);
273
279
        rqe = list_get_instance(link, udp_rcv_queue_entry_t, link);
307
313
        }
308
314
}
309
315
 
 
316
/** Reset association.
 
317
 *
 
318
 * This causes any pendingreceive operations to return immediately with
 
319
 * UDP_ERESET.
 
320
 */
 
321
void udp_assoc_reset(udp_assoc_t *assoc)
 
322
{
 
323
        fibril_mutex_lock(&assoc->lock);
 
324
        assoc->reset = true;
 
325
        fibril_condvar_broadcast(&assoc->rcv_queue_cv);
 
326
        fibril_mutex_unlock(&assoc->lock);
 
327
}
 
328
 
310
329
static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp,
311
330
    udp_msg_t *msg)
312
331
{