Changeset 4e716180 in mainline for uspace/srv/net
- 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:
- 1c7ba2da (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. - Location:
- uspace/srv/net
- Files:
-
- 10 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/addrobj.c
r1c7ba2da r4e716180 221 221 222 222 lsrc_addr.ipv4 = addr->naddr.ipv4; 223 ldest_addr = &dgram->dest;223 ldest_addr = ldest; 224 224 225 225 return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram, -
uspace/srv/net/inetsrv/inetsrv.c
r1c7ba2da r4e716180 98 98 } 99 99 100 rc = inet_link_discovery_start(); 100 inet_sroute_t *sroute = inet_sroute_new(); 101 if (sroute == NULL) { 102 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed creating default route (%d).", rc); 103 return ENOMEM; 104 } 105 106 sroute->dest.ipv4 = 0; 107 sroute->dest.bits = 0; 108 sroute->router.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1; 109 sroute->name = str_dup("default"); 110 inet_sroute_add(sroute); 111 112 rc = inet_link_discovery_start(); 101 113 if (rc != EOK) 102 114 return EEXIST; -
uspace/srv/net/udp/assoc.c
r1c7ba2da r4e716180 279 279 280 280 fibril_mutex_lock(&assoc->lock); 281 while (list_empty(&assoc->rcv_queue) ) {281 while (list_empty(&assoc->rcv_queue) && !assoc->reset) { 282 282 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting"); 283 283 fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock); 284 } 285 286 if (assoc->reset) { 287 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset"); 288 fibril_mutex_unlock(&assoc->lock); 289 return ECONNABORTED; 284 290 } 285 291 … … 323 329 } 324 330 331 /** Reset association. 332 * 333 * This causes any pendingreceive operations to return immediately with 334 * UDP_ERESET. 335 */ 336 void udp_assoc_reset(udp_assoc_t *assoc) 337 { 338 fibril_mutex_lock(&assoc->lock); 339 assoc->reset = true; 340 fibril_condvar_broadcast(&assoc->rcv_queue_cv); 341 fibril_mutex_unlock(&assoc->lock); 342 } 343 325 344 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 326 345 udp_msg_t *msg) -
uspace/srv/net/udp/assoc.h
r1c7ba2da r4e716180 51 51 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *); 52 52 extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *); 53 53 extern void udp_assoc_reset(udp_assoc_t *); 54 54 55 55 #endif -
uspace/srv/net/udp/sock.c
r1c7ba2da 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; -
uspace/srv/net/udp/ucall.c
r1c7ba2da r4e716180 113 113 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_uc_receive()", assoc->name); 114 114 rc = udp_assoc_recv(assoc, &msg, fsock); 115 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv -> %d", rc); 115 116 switch (rc) { 117 case EOK: 118 break; 119 case ECONNABORTED: 120 return UDP_ERESET; 121 default: 122 assert(false); 116 123 } 117 124 … … 133 140 { 134 141 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_destroy()"); 142 udp_assoc_reset(assoc); 135 143 udp_assoc_remove(assoc); 136 144 udp_assoc_delete(assoc); 145 } 146 147 void udp_uc_reset(udp_assoc_t *assoc) 148 { 149 udp_assoc_reset(assoc); 137 150 } 138 151 -
uspace/srv/net/udp/ucall.h
r1c7ba2da r4e716180 49 49 extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *); 50 50 extern void udp_uc_destroy(udp_assoc_t *); 51 extern void udp_uc_reset(udp_assoc_t *); 51 52 52 53 #endif -
uspace/srv/net/udp/udp_type.h
r1c7ba2da r4e716180 51 51 UDP_EUNSPEC, 52 52 /* No route to destination */ 53 UDP_ENOROUTE 53 UDP_ENOROUTE, 54 /** Association reset by user */ 55 UDP_ERESET 54 56 } udp_error_t; 55 57 … … 119 121 udp_sockpair_t ident; 120 122 123 /** True if association was reset by user */ 124 bool reset; 125 121 126 /** True if association was deleted by user */ 122 127 bool deleted;
Note:
See TracChangeset
for help on using the changeset viewer.