Changeset 1d4024cf in mainline for uspace/srv
- Timestamp:
- 2012-06-13T16:19:01Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49c94a3
- Parents:
- 33f9670 (diff), 2902e1bb (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
- Files:
-
- 12 edited
-
bd/ata_bd/ata_bd.c (modified) (1 diff)
-
bd/file_bd/file_bd.c (modified) (1 diff)
-
bd/gxe_bd/gxe_bd.c (modified) (1 diff)
-
bd/part/guid_part/guid_part.c (modified) (1 diff)
-
bd/part/mbr_part/mbr_part.c (modified) (1 diff)
-
bd/rd/rd.c (modified) (1 diff)
-
hid/fb/fb.c (modified) (2 diffs)
-
net/tcp/sock.c (modified) (1 diff)
-
net/udp/sock.c (modified) (21 diffs)
-
net/udp/udp.c (modified) (1 diff)
-
net/udp/udp_type.h (modified) (2 diffs)
-
vfs/vfs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
r33f9670 r1d4024cf 308 308 309 309 (void) async_share_out_finalize(callid, &fs_va); 310 if (fs_va == (void *) -1) {310 if (fs_va == AS_MAP_FAILED) { 311 311 async_answer_0(callid, EHANGUP); 312 312 return; -
uspace/srv/bd/file_bd/file_bd.c
r33f9670 r1d4024cf 189 189 190 190 (void) async_share_out_finalize(callid, &fs_va); 191 if (fs_va == (void *) -1) {191 if (fs_va == AS_MAP_FAILED) { 192 192 async_answer_0(callid, EHANGUP); 193 193 return; -
uspace/srv/bd/gxe_bd/gxe_bd.c
r33f9670 r1d4024cf 196 196 197 197 (void) async_share_out_finalize(callid, &fs_va); 198 if (fs_va == (void *) -1) {198 if (fs_va == AS_MAP_FAILED) { 199 199 async_answer_0(callid, EHANGUP); 200 200 return; -
uspace/srv/bd/part/guid_part/guid_part.c
r33f9670 r1d4024cf 350 350 351 351 (void) async_share_out_finalize(callid, &fs_va); 352 if (fs_va == (void *) -1) {352 if (fs_va == AS_MAP_FAILED) { 353 353 async_answer_0(callid, EHANGUP); 354 354 return; -
uspace/srv/bd/part/mbr_part/mbr_part.c
r33f9670 r1d4024cf 427 427 428 428 (void) async_share_out_finalize(callid, &fs_va); 429 if (fs_va == (void *) -1) {429 if (fs_va == AS_MAP_FAILED) { 430 430 async_answer_0(callid, EHANGUP); 431 431 return; -
uspace/srv/bd/rd/rd.c
r33f9670 r1d4024cf 106 106 if (async_share_out_receive(&callid, &comm_size, &flags)) { 107 107 (void) async_share_out_finalize(callid, &fs_va); 108 if (fs_va == (void *) -1) {108 if (fs_va == AS_MAP_FAILED) { 109 109 async_answer_0(callid, EHANGUP); 110 110 return; -
uspace/srv/hid/fb/fb.c
r33f9670 r1d4024cf 305 305 306 306 int rc = async_share_out_finalize(callid, &frontbuf->data); 307 if ((rc != EOK) || (frontbuf->data == (void *) -1)) {307 if ((rc != EOK) || (frontbuf->data == AS_MAP_FAILED)) { 308 308 free(frontbuf); 309 309 async_answer_0(iid, ENOMEM); … … 348 348 349 349 int rc = async_share_out_finalize(callid, &imagemap->data); 350 if ((rc != EOK) || (imagemap->data == (void *) -1)) {350 if ((rc != EOK) || (imagemap->data == AS_MAP_FAILED)) { 351 351 free(imagemap); 352 352 async_answer_0(iid, ENOMEM); -
uspace/srv/net/tcp/sock.c
r33f9670 r1d4024cf 151 151 sock, sock_id); 152 152 153 if (rc != EOK) 153 if (rc != EOK) { 154 fibril_destroy(sock->recv_fibril); 155 sock->recv_fibril = 0; 154 156 return rc; 157 } 155 158 156 159 sock_core = socket_cores_find(&sock->client->sockets, *sock_id); -
uspace/srv/net/udp/sock.c
r33f9670 r1d4024cf 51 51 #include "ucall.h" 52 52 53 #define FRAGMENT_SIZE 102454 55 53 /** Free ports pool start. */ 56 54 #define UDP_FREE_PORTS_START 1025 … … 63 61 64 62 static void udp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); 63 static int udp_sock_recv_fibril(void *arg); 65 64 66 65 int udp_sock_init(void) … … 82 81 83 82 socket = (udp_sockdata_t *)sock_core->specific_data; 84 assert(socket->assoc != NULL); 85 udp_uc_destroy(socket->assoc); 83 (void)socket; 84 85 /* XXX We need to force the receive fibril to quit */ 86 86 } 87 87 … … 91 91 async_exch_t *exch = async_exchange_begin(sock_core->sess); 92 92 async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t)sock_core->socket_id, 93 FRAGMENT_SIZE, 0, 0, 1);93 UDP_FRAGMENT_SIZE, 0, 0, 1); 94 94 async_exchange_end(exch); 95 95 } … … 113 113 sock->client = client; 114 114 115 sock->recv_buffer_used = 0; 116 sock->recv_error = UDP_EOK; 117 fibril_mutex_initialize(&sock->recv_buffer_lock); 118 fibril_condvar_initialize(&sock->recv_buffer_cv); 119 115 120 rc = udp_uc_create(&sock->assoc); 116 121 if (rc != EOK) { 122 free(sock); 123 async_answer_0(callid, rc); 124 return; 125 } 126 127 sock->recv_fibril = fibril_create(udp_sock_recv_fibril, sock); 128 if (sock->recv_fibril == 0) { 129 udp_uc_destroy(sock->assoc); 130 free(sock); 131 async_answer_0(callid, ENOMEM); 132 return; 133 } 134 135 sock_id = SOCKET_GET_SOCKET_ID(call); 136 rc = socket_create(&client->sockets, client->sess, sock, &sock_id); 137 if (rc != EOK) { 138 fibril_destroy(sock->recv_fibril); 117 139 udp_uc_destroy(sock->assoc); 118 140 free(sock); … … 121 143 } 122 144 123 sock_id = SOCKET_GET_SOCKET_ID(call); 124 rc = socket_create(&client->sockets, client->sess, sock, &sock_id); 125 if (rc != EOK) { 126 async_answer_0(callid, rc); 127 return; 128 } 145 fibril_add_ready(sock->recv_fibril); 129 146 130 147 sock_core = socket_cores_find(&client->sockets, sock_id); … … 134 151 SOCKET_SET_SOCKET_ID(answer, sock_id); 135 152 136 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, FRAGMENT_SIZE);153 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, UDP_FRAGMENT_SIZE); 137 154 SOCKET_SET_HEADER_SIZE(answer, sizeof(udp_header_t)); 138 155 async_answer_3(callid, EOK, IPC_GET_ARG1(answer), … … 205 222 } 206 223 207 udp_sock_notify_data(sock_core);208 209 224 log_msg(LVL_DEBUG, " - success"); 210 225 async_answer_0(callid, rc); … … 245 260 ipc_callid_t wcallid; 246 261 size_t length; 247 uint8_t buffer[ FRAGMENT_SIZE];262 uint8_t buffer[UDP_FRAGMENT_SIZE]; 248 263 udp_error_t urc; 249 264 int rc; … … 292 307 goto out; 293 308 } 294 295 udp_sock_notify_data(sock_core);296 309 } 297 310 … … 330 343 } 331 344 332 if (length > FRAGMENT_SIZE)333 length = FRAGMENT_SIZE;345 if (length > UDP_FRAGMENT_SIZE) 346 length = UDP_FRAGMENT_SIZE; 334 347 335 348 rc = async_data_write_finalize(wcallid, buffer, length); … … 367 380 368 381 IPC_SET_ARG1(answer, 0); 369 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, FRAGMENT_SIZE);382 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, UDP_FRAGMENT_SIZE); 370 383 async_answer_2(callid, EOK, IPC_GET_ARG1(answer), 371 384 IPC_GET_ARG2(answer)); … … 386 399 ipc_call_t answer; 387 400 ipc_callid_t rcallid; 388 uint8_t buffer[FRAGMENT_SIZE];389 401 size_t data_len; 390 xflags_t xflags;391 402 udp_error_t urc; 403 udp_sock_t rsock; 392 404 struct sockaddr_in addr; 393 udp_sock_t rsock;394 405 int rc; 395 406 … … 416 427 (void)flags; 417 428 418 urc = udp_uc_receive(socket->assoc, buffer, FRAGMENT_SIZE, &data_len, 419 &xflags, &rsock); 420 log_msg(LVL_DEBUG, "**** udp_uc_receive done, data_len=%zu", data_len); 429 log_msg(LVL_DEBUG, "udp_sock_recvfrom(): lock recv_buffer lock"); 430 fibril_mutex_lock(&socket->recv_buffer_lock); 431 while (socket->recv_buffer_used == 0 && socket->recv_error == UDP_EOK) { 432 log_msg(LVL_DEBUG, "udp_sock_recvfrom(): wait for cv"); 433 fibril_condvar_wait(&socket->recv_buffer_cv, 434 &socket->recv_buffer_lock); 435 } 436 437 log_msg(LVL_DEBUG, "Got data in sock recv_buffer"); 438 439 rsock = socket->recv_fsock; 440 data_len = socket->recv_buffer_used; 441 urc = socket->recv_error; 442 443 log_msg(LVL_DEBUG, "**** recv data_len=%zu", data_len); 421 444 422 445 switch (urc) { … … 437 460 log_msg(LVL_DEBUG, "**** udp_uc_receive -> %d", rc); 438 461 if (rc != EOK) { 462 fibril_mutex_unlock(&socket->recv_buffer_lock); 439 463 fibril_mutex_unlock(&socket->lock); 440 464 async_answer_0(callid, rc); … … 450 474 log_msg(LVL_DEBUG, "addr read receive"); 451 475 if (!async_data_read_receive(&rcallid, &addr_length)) { 476 fibril_mutex_unlock(&socket->recv_buffer_lock); 452 477 fibril_mutex_unlock(&socket->lock); 453 478 async_answer_0(callid, EINVAL); … … 461 486 rc = async_data_read_finalize(rcallid, &addr, addr_length); 462 487 if (rc != EOK) { 488 fibril_mutex_unlock(&socket->recv_buffer_lock); 463 489 fibril_mutex_unlock(&socket->lock); 464 490 async_answer_0(callid, EINVAL); … … 469 495 log_msg(LVL_DEBUG, "data read receive"); 470 496 if (!async_data_read_receive(&rcallid, &length)) { 497 fibril_mutex_unlock(&socket->recv_buffer_lock); 471 498 fibril_mutex_unlock(&socket->lock); 472 499 async_answer_0(callid, EINVAL); … … 478 505 479 506 log_msg(LVL_DEBUG, "data read finalize"); 480 rc = async_data_read_finalize(rcallid, buffer, length);507 rc = async_data_read_finalize(rcallid, socket->recv_buffer, length); 481 508 482 509 if (length < data_len && rc == EOK) … … 489 516 async_answer_3(callid, EOK, IPC_GET_ARG1(answer), 490 517 IPC_GET_ARG2(answer), IPC_GET_ARG3(answer)); 491 492 /* Push one fragment notification to client's queue */ 493 udp_sock_notify_data(sock_core); 518 519 socket->recv_buffer_used = 0; 520 521 fibril_condvar_broadcast(&socket->recv_buffer_cv); 522 fibril_mutex_unlock(&socket->recv_buffer_lock); 494 523 fibril_mutex_unlock(&socket->lock); 495 524 } … … 538 567 } 539 568 569 static int udp_sock_recv_fibril(void *arg) 570 { 571 udp_sockdata_t *sock = (udp_sockdata_t *)arg; 572 udp_error_t urc; 573 xflags_t xflags; 574 size_t rcvd; 575 576 log_msg(LVL_DEBUG, "udp_sock_recv_fibril()"); 577 578 while (true) { 579 log_msg(LVL_DEBUG, "[] wait for rcv buffer empty()"); 580 fibril_mutex_lock(&sock->recv_buffer_lock); 581 while (sock->recv_buffer_used != 0) { 582 fibril_condvar_wait(&sock->recv_buffer_cv, 583 &sock->recv_buffer_lock); 584 } 585 586 log_msg(LVL_DEBUG, "[] call udp_uc_receive()"); 587 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 588 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 589 sock->recv_error = urc; 590 591 udp_sock_notify_data(sock->sock_core); 592 593 if (urc != UDP_EOK) { 594 fibril_condvar_broadcast(&sock->recv_buffer_cv); 595 fibril_mutex_unlock(&sock->recv_buffer_lock); 596 break; 597 } 598 599 log_msg(LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 600 601 sock->recv_buffer_used = rcvd; 602 fibril_mutex_unlock(&sock->recv_buffer_lock); 603 fibril_condvar_broadcast(&sock->recv_buffer_cv); 604 } 605 606 udp_uc_destroy(sock->assoc); 607 608 return 0; 609 } 610 540 611 static void udp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 541 612 { -
uspace/srv/net/udp/udp.c
r33f9670 r1d4024cf 73 73 printf(NAME ": UDP (User Datagram Protocol) service\n"); 74 74 75 rc = log_init(NAME, LVL_ WARN);75 rc = log_init(NAME, LVL_DEBUG); 76 76 if (rc != EOK) { 77 77 printf(NAME ": Failed to initialize log.\n"); -
uspace/srv/net/udp/udp_type.h
r33f9670 r1d4024cf 36 36 #define UDP_TYPE_H 37 37 38 #include <fibril.h> 38 39 #include <fibril_synch.h> 39 40 #include <socket_core.h> 40 41 #include <sys/types.h> 42 43 #define UDP_FRAGMENT_SIZE 4096 44 41 45 42 46 typedef enum { … … 141 145 /** Connection */ 142 146 udp_assoc_t *assoc; 147 /** Receiving fibril */ 148 fid_t recv_fibril; 149 uint8_t recv_buffer[UDP_FRAGMENT_SIZE]; 150 size_t recv_buffer_used; 151 udp_sock_t recv_fsock; 152 fibril_mutex_t recv_buffer_lock; 153 fibril_condvar_t recv_buffer_cv; 154 udp_error_t recv_error; 143 155 } udp_sockdata_t; 144 156 -
uspace/srv/vfs/vfs.c
r33f9670 r1d4024cf 173 173 * Allocate and initialize the Path Lookup Buffer. 174 174 */ 175 plb = as_area_create( (void *) -1, PLB_SIZE,175 plb = as_area_create(AS_AREA_ANY, PLB_SIZE, 176 176 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 177 if (plb == (void *) -1) {177 if (plb == AS_MAP_FAILED) { 178 178 printf("%s: Cannot create address space area\n", NAME); 179 179 return ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.
