Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 141a20d in mainline for uspace/srv/net/udp/sock.c


Ignore:
Timestamp:
2012-08-13T10:40:17Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
a1e2df13
Parents:
e5e73af
Message:

Terminate UDP receive fibril when socket is closed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/sock.c

    re5e73af r141a20d  
    531531        int rc;
    532532
    533         log_msg(LVL_DEBUG, "tcp_sock_close()");
     533        log_msg(LVL_DEBUG, "udp_sock_close()");
    534534        socket_id = SOCKET_GET_SOCKET_ID(call);
    535535
     
    543543        fibril_mutex_lock(&socket->lock);
    544544
     545        fibril_mutex_lock(&socket->recv_buffer_lock);
     546        log_msg(LVL_DEBUG, "udp_sock_close - set socket->sock_core = NULL");
     547        socket->sock_core = NULL;
     548        fibril_mutex_unlock(&socket->recv_buffer_lock);
     549
     550        udp_uc_reset(socket->assoc);
     551
    545552        rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
    546553            udp_free_sock_data);
    547554        if (rc != EOK) {
     555                log_msg(LVL_DEBUG, "udp_sock_close - socket_destroy failed");
    548556                fibril_mutex_unlock(&socket->lock);
    549557                async_answer_0(callid, rc);
    550558                return;
    551559        }
     560
     561        log_msg(LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv");
     562        fibril_condvar_broadcast(&socket->recv_buffer_cv);
    552563
    553564        fibril_mutex_unlock(&socket->lock);
     
    576587        log_msg(LVL_DEBUG, "udp_sock_recv_fibril()");
    577588
     589        fibril_mutex_lock(&sock->recv_buffer_lock);
     590
    578591        while (true) {
    579592                log_msg(LVL_DEBUG, "[] wait for rcv buffer empty()");
    580                 fibril_mutex_lock(&sock->recv_buffer_lock);
    581                 while (sock->recv_buffer_used != 0) {
     593                while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) {
    582594                        fibril_condvar_wait(&sock->recv_buffer_cv,
    583595                            &sock->recv_buffer_lock);
     
    589601                sock->recv_error = urc;
    590602
    591                 udp_sock_notify_data(sock->sock_core);
     603                log_msg(LVL_DEBUG, "[] udp_uc_receive -> %d", urc);
     604
     605                if (sock->sock_core != NULL)
     606                        udp_sock_notify_data(sock->sock_core);
    592607
    593608                if (urc != UDP_EOK) {
     609                        log_msg(LVL_DEBUG, "[] urc != UDP_EOK, break");
    594610                        fibril_condvar_broadcast(&sock->recv_buffer_cv);
    595                         fibril_mutex_unlock(&sock->recv_buffer_lock);
    596611                        break;
    597612                }
     
    600615
    601616                sock->recv_buffer_used = rcvd;
    602                 fibril_mutex_unlock(&sock->recv_buffer_lock);
    603617                fibril_condvar_broadcast(&sock->recv_buffer_cv);
    604618        }
    605619
     620        log_msg(LVL_DEBUG, "udp_sock_recv_fibril() exited loop");
     621        fibril_mutex_unlock(&sock->recv_buffer_lock);
    606622        udp_uc_destroy(sock->assoc);
     623
     624        log_msg(LVL_DEBUG, "udp_sock_recv_fibril() terminated");
    607625
    608626        return 0;
Note: See TracChangeset for help on using the changeset viewer.