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

Changeset 798105ca in mainline


Ignore:
Timestamp:
2012-08-05T12:54:44Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
7cd9b02
Parents:
d4112ba
Message:

tcp_sock_recv_fibril() needs to handle situation when sock_core goes away before TCP signals end of connection.

File:
1 edited

Legend:

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

    rd4112ba r798105ca  
    779779        }
    780780
     781        /* Grab recv_buffer_lock because of CV wait in tcp_sock_recv_fibril() */
     782        fibril_mutex_lock(&socket->recv_buffer_lock);
     783        socket->sock_core = NULL;
     784        fibril_mutex_unlock(&socket->recv_buffer_lock);
     785
    781786        rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
    782787            tcp_free_sock_data);
     
    839844        log_msg(LVL_DEBUG, "tcp_sock_recv_fibril()");
    840845
     846        fibril_mutex_lock(&sock->recv_buffer_lock);
     847
    841848        while (true) {
    842849                log_msg(LVL_DEBUG, "call tcp_uc_receive()");
    843                 fibril_mutex_lock(&sock->recv_buffer_lock);
    844                 while (sock->recv_buffer_used != 0)
     850                while (sock->recv_buffer_used != 0 && sock->sock_core != NULL)
    845851                        fibril_condvar_wait(&sock->recv_buffer_cv,
    846852                            &sock->recv_buffer_lock);
     
    852858                        sock->recv_error = trc;
    853859                        fibril_condvar_broadcast(&sock->recv_buffer_cv);
    854                         fibril_mutex_unlock(&sock->recv_buffer_lock);
    855                         tcp_sock_notify_data(sock->sock_core);
     860                        if (sock->sock_core != NULL)
     861                                tcp_sock_notify_data(sock->sock_core);
    856862                        break;
    857863                }
     
    861867                sock->recv_buffer_used = data_len;
    862868                fibril_condvar_broadcast(&sock->recv_buffer_cv);
    863                 fibril_mutex_unlock(&sock->recv_buffer_lock);
    864                 tcp_sock_notify_data(sock->sock_core);
    865         }
     869                if (sock->sock_core != NULL)
     870                        tcp_sock_notify_data(sock->sock_core);
     871        }
     872
     873        fibril_mutex_unlock(&sock->recv_buffer_lock);
    866874
    867875        tcp_uc_delete(sock->conn);
Note: See TracChangeset for help on using the changeset viewer.