Changeset 141a20d in mainline
- Timestamp:
- 2012-08-13T10:40:17Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1e2df13
- Parents:
- e5e73af
- Location:
- uspace/srv/net
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/transport.c
re5e73af r141a20d 52 52 size_t req_size; 53 53 struct sockaddr_in addr; 54 struct sockaddr_in laddr; 54 55 int fd; 55 56 56 57 addr.sin_family = AF_INET; 57 58 addr.sin_port = htons(53); 58 addr.sin_addr.s_addr = htonl((192 << 24) | (168 << 16) | (0 << 8) | 1); 59 addr.sin_addr.s_addr = htonl((10 << 24) | (0 << 16) | (0 << 8) | 1); 60 61 laddr.sin_family = AF_INET; 62 laddr.sin_port = htons(12345); 63 laddr.sin_addr.s_addr = INADDR_ANY; 59 64 60 65 req_data = NULL; … … 71 76 } 72 77 78 rc = bind(fd, (struct sockaddr *)&laddr, sizeof(laddr)); 79 if (rc != EOK) 80 goto error; 81 73 82 printf("fd=%d req_data=%p, req_size=%zu\n", fd, req_data, req_size); 74 83 rc = sendto(fd, req_data, req_size, 0, (struct sockaddr *)&addr, … … 76 85 if (rc != EOK) 77 86 goto error; 87 88 closesocket(fd); 89 free(req_data); 78 90 79 91 resp = NULL; -
uspace/srv/net/inetsrv/inet_link.c
re5e73af r141a20d 202 202 first = 0; 203 203 } else { 204 addr->naddr.ipv4 = (1 92 << 24) + (168 << 16) + (0 << 8) + 4;204 addr->naddr.ipv4 = (10 << 24) + (0 << 16) + (0 << 8) + 2; 205 205 } 206 206 addr->naddr.bits = 24; -
uspace/srv/net/udp/assoc.c
re5e73af r141a20d 264 264 265 265 fibril_mutex_lock(&assoc->lock); 266 while (list_empty(&assoc->rcv_queue) ) {266 while (list_empty(&assoc->rcv_queue) && !assoc->reset) { 267 267 log_msg(LVL_DEBUG, "udp_assoc_recv() - waiting"); 268 268 fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock); 269 } 270 271 if (assoc->reset) { 272 log_msg(LVL_DEBUG, "udp_assoc_recv() - association was reset"); 273 fibril_mutex_unlock(&assoc->lock); 274 return ECONNABORTED; 269 275 } 270 276 … … 308 314 } 309 315 316 /** Reset association. 317 * 318 * This causes any pendingreceive operations to return immediately with 319 * UDP_ERESET. 320 */ 321 void udp_assoc_reset(udp_assoc_t *assoc) 322 { 323 fibril_mutex_lock(&assoc->lock); 324 assoc->reset = true; 325 fibril_condvar_broadcast(&assoc->rcv_queue_cv); 326 fibril_mutex_unlock(&assoc->lock); 327 } 328 310 329 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 311 330 udp_msg_t *msg) -
uspace/srv/net/udp/assoc.h
re5e73af r141a20d 50 50 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *); 51 51 extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *); 52 52 extern void udp_assoc_reset(udp_assoc_t *); 53 53 54 54 #endif -
uspace/srv/net/udp/sock.c
re5e73af r141a20d 531 531 int rc; 532 532 533 log_msg(LVL_DEBUG, " tcp_sock_close()");533 log_msg(LVL_DEBUG, "udp_sock_close()"); 534 534 socket_id = SOCKET_GET_SOCKET_ID(call); 535 535 … … 543 543 fibril_mutex_lock(&socket->lock); 544 544 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 545 552 rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 546 553 udp_free_sock_data); 547 554 if (rc != EOK) { 555 log_msg(LVL_DEBUG, "udp_sock_close - socket_destroy failed"); 548 556 fibril_mutex_unlock(&socket->lock); 549 557 async_answer_0(callid, rc); 550 558 return; 551 559 } 560 561 log_msg(LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv"); 562 fibril_condvar_broadcast(&socket->recv_buffer_cv); 552 563 553 564 fibril_mutex_unlock(&socket->lock); … … 576 587 log_msg(LVL_DEBUG, "udp_sock_recv_fibril()"); 577 588 589 fibril_mutex_lock(&sock->recv_buffer_lock); 590 578 591 while (true) { 579 592 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) { 582 594 fibril_condvar_wait(&sock->recv_buffer_cv, 583 595 &sock->recv_buffer_lock); … … 589 601 sock->recv_error = urc; 590 602 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); 592 607 593 608 if (urc != UDP_EOK) { 609 log_msg(LVL_DEBUG, "[] urc != UDP_EOK, break"); 594 610 fibril_condvar_broadcast(&sock->recv_buffer_cv); 595 fibril_mutex_unlock(&sock->recv_buffer_lock);596 611 break; 597 612 } … … 600 615 601 616 sock->recv_buffer_used = rcvd; 602 fibril_mutex_unlock(&sock->recv_buffer_lock);603 617 fibril_condvar_broadcast(&sock->recv_buffer_cv); 604 618 } 605 619 620 log_msg(LVL_DEBUG, "udp_sock_recv_fibril() exited loop"); 621 fibril_mutex_unlock(&sock->recv_buffer_lock); 606 622 udp_uc_destroy(sock->assoc); 623 624 log_msg(LVL_DEBUG, "udp_sock_recv_fibril() terminated"); 607 625 608 626 return 0; -
uspace/srv/net/udp/ucall.c
re5e73af r141a20d 105 105 log_msg(LVL_DEBUG, "%s: udp_uc_receive()", assoc->name); 106 106 rc = udp_assoc_recv(assoc, &msg, fsock); 107 log_msg(LVL_DEBUG, "udp_assoc_recv -> %d", rc); 107 108 switch (rc) { 109 case EOK: 110 break; 111 case ECONNABORTED: 112 return UDP_ERESET; 113 default: 114 assert(false); 108 115 } 109 116 … … 125 132 { 126 133 log_msg(LVL_DEBUG, "udp_uc_destroy()"); 134 udp_assoc_reset(assoc); 127 135 udp_assoc_remove(assoc); 128 136 udp_assoc_delete(assoc); 137 } 138 139 void udp_uc_reset(udp_assoc_t *assoc) 140 { 141 udp_assoc_reset(assoc); 129 142 } 130 143 -
uspace/srv/net/udp/ucall.h
re5e73af r141a20d 48 48 extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *); 49 49 extern void udp_uc_destroy(udp_assoc_t *); 50 extern void udp_uc_reset(udp_assoc_t *); 50 51 51 52 #endif -
uspace/srv/net/udp/udp_type.h
re5e73af r141a20d 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.