Changes in uspace/srv/net/udp/sock.c [ccb5165:6b0b508] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/sock.c
rccb5165 r6b0b508 537 537 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()"); 538 538 int socket_id = SOCKET_GET_SOCKET_ID(call); 539 540 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - find core"); 539 541 540 socket_core_t *sock_core = 542 541 socket_cores_find(&client->sockets, socket_id); 543 542 if (sock_core == NULL) { 544 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - core not found");545 543 async_answer_0(callid, ENOTSOCK); 546 544 return; 547 545 } 548 549 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - spec data"); 546 550 547 udp_sockdata_t *socket = 551 548 (udp_sockdata_t *) sock_core->specific_data; 552 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket");553 549 fibril_mutex_lock(&socket->lock); 554 555 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket buffer"); 556 fibril_mutex_lock(&socket->recv_buffer_lock); 557 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - set socket->sock_core = NULL"); 558 socket->sock_core = NULL; 559 fibril_mutex_unlock(&socket->recv_buffer_lock); 560 561 udp_uc_reset(socket->assoc); 562 550 563 551 int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 564 552 udp_free_sock_data); 565 553 if (rc != EOK) { 566 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed");567 554 fibril_mutex_unlock(&socket->lock); 568 555 async_answer_0(callid, rc); 569 556 return; 570 557 } 571 572 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv"); 573 fibril_condvar_broadcast(&socket->recv_buffer_cv); 574 558 575 559 fibril_mutex_unlock(&socket->lock); 576 560 async_answer_0(callid, EOK); … … 598 582 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()"); 599 583 600 fibril_mutex_lock(&sock->recv_buffer_lock);601 602 584 while (true) { 603 585 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()"); 604 while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) { 586 fibril_mutex_lock(&sock->recv_buffer_lock); 587 while (sock->recv_buffer_used != 0) { 605 588 fibril_condvar_wait(&sock->recv_buffer_cv, 606 589 &sock->recv_buffer_lock); 607 590 } 608 609 fibril_mutex_unlock(&sock->recv_buffer_lock); 610 591 611 592 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()"); 612 593 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 613 594 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 614 fibril_mutex_lock(&sock->recv_buffer_lock);615 595 sock->recv_error = urc; 616 617 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] udp_uc_receive -> %d", urc); 618 619 if (sock->sock_core != NULL) 620 udp_sock_notify_data(sock->sock_core); 621 596 597 udp_sock_notify_data(sock->sock_core); 598 622 599 if (urc != UDP_EOK) { 623 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break");624 600 fibril_condvar_broadcast(&sock->recv_buffer_cv); 625 break; 626 } 627 601 fibril_mutex_unlock(&sock->recv_buffer_lock); 602 break; 603 } 604 628 605 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 629 606 630 607 sock->recv_buffer_used = rcvd; 608 fibril_mutex_unlock(&sock->recv_buffer_lock); 631 609 fibril_condvar_broadcast(&sock->recv_buffer_cv); 632 610 } 633 611 634 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop");635 fibril_mutex_unlock(&sock->recv_buffer_lock);636 612 udp_uc_destroy(sock->assoc); 637 638 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated");639 613 640 614 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.