Changeset 4e716180 in mainline for uspace/srv/net/udp/sock.c
- Timestamp:
- 2013-05-03T21:14:39Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 716357f
- Parents:
- 1c7ba2d (diff), 5d1cb8a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/sock.c
r1c7ba2d r4e716180 537 537 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()"); 538 538 int socket_id = SOCKET_GET_SOCKET_ID(call); 539 539 540 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - find core"); 540 541 socket_core_t *sock_core = 541 542 socket_cores_find(&client->sockets, socket_id); 542 543 if (sock_core == NULL) { 544 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - core not found"); 543 545 async_answer_0(callid, ENOTSOCK); 544 546 return; 545 547 } 546 548 549 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - spec data"); 547 550 udp_sockdata_t *socket = 548 551 (udp_sockdata_t *) sock_core->specific_data; 552 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket"); 549 553 fibril_mutex_lock(&socket->lock); 550 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 551 563 int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 552 564 udp_free_sock_data); 553 565 if (rc != EOK) { 566 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed"); 554 567 fibril_mutex_unlock(&socket->lock); 555 568 async_answer_0(callid, rc); 556 569 return; 557 570 } 558 571 572 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv"); 573 fibril_condvar_broadcast(&socket->recv_buffer_cv); 574 559 575 fibril_mutex_unlock(&socket->lock); 560 576 async_answer_0(callid, EOK); … … 582 598 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()"); 583 599 600 fibril_mutex_lock(&sock->recv_buffer_lock); 601 584 602 while (true) { 585 603 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()"); 586 fibril_mutex_lock(&sock->recv_buffer_lock); 587 while (sock->recv_buffer_used != 0) { 604 while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) { 588 605 fibril_condvar_wait(&sock->recv_buffer_cv, 589 606 &sock->recv_buffer_lock); 590 607 } 591 608 609 fibril_mutex_unlock(&sock->recv_buffer_lock); 610 592 611 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()"); 593 612 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 594 613 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 614 fibril_mutex_lock(&sock->recv_buffer_lock); 595 615 sock->recv_error = urc; 596 597 udp_sock_notify_data(sock->sock_core); 598 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 599 622 if (urc != UDP_EOK) { 623 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break"); 600 624 fibril_condvar_broadcast(&sock->recv_buffer_cv); 601 fibril_mutex_unlock(&sock->recv_buffer_lock); 602 break; 603 } 604 625 break; 626 } 627 605 628 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 606 629 607 630 sock->recv_buffer_used = rcvd; 608 fibril_mutex_unlock(&sock->recv_buffer_lock);609 631 fibril_condvar_broadcast(&sock->recv_buffer_cv); 610 632 } 611 633 634 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop"); 635 fibril_mutex_unlock(&sock->recv_buffer_lock); 612 636 udp_uc_destroy(sock->assoc); 637 638 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated"); 613 639 614 640 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.