Changeset 3090715 in mainline for uspace/lib/net/tl/socket_core.c
- Timestamp:
- 2010-11-07T21:16:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
- Children:
- 1d0d06a
- Parents:
- 9ce7eb5 (diff), 9ee9d5d (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/lib/net/tl/socket_core.c
r9ce7eb5 r3090715 48 48 #include <stdlib.h> 49 49 #include <errno.h> 50 #include <err.h>51 50 52 51 #include <adt/dynamic_fifo.h> … … 164 163 const char *key, size_t key_length) 165 164 { 166 ERROR_DECLARE;167 168 165 socket_core_ref *socket_ref; 166 int rc; 169 167 170 168 // create a wrapper … … 175 173 *socket_ref = socket; 176 174 // add the wrapper 177 if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key, 178 key_length, socket_ref))) { 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 socket_ref); 177 if (rc != EOK) { 179 178 free(socket_ref); 180 return ERROR_CODE;179 return rc; 181 180 } 182 181 … … 204 203 int port) 205 204 { 206 ERROR_DECLARE;207 208 205 socket_port_ref socket_port; 206 int rc; 209 207 210 208 // create a wrapper … … 214 212 215 213 socket_port->count = 0; 216 if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) || 217 ERROR_OCCURRED(socket_port_add_core(socket_port, socket, 218 SOCKET_MAP_KEY_LISTENING, 0))) { 219 socket_port_map_destroy(&socket_port->map); 220 free(socket_port); 221 return ERROR_CODE; 222 } 214 rc = socket_port_map_initialize(&socket_port->map); 215 if (rc != EOK) 216 goto fail; 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING, 219 0); 220 if (rc != EOK) 221 goto fail; 223 222 224 223 // register the incomming port 225 ERROR_CODE = socket_ports_add(global_sockets, port, socket_port); 226 if (ERROR_CODE < 0) { 227 socket_port_map_destroy(&socket_port->map); 228 free(socket_port); 229 return ERROR_CODE; 230 } 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 if (rc < 0) 226 goto fail; 231 227 232 228 socket->port = port; 233 229 return EOK; 230 231 fail: 232 socket_port_map_destroy(&socket_port->map); 233 free(socket_port); 234 return rc; 235 234 236 } 235 237 … … 416 418 void *specific_data, int *socket_id) 417 419 { 418 ERROR_DECLARE;419 420 420 socket_core_ref socket; 421 int res;422 421 int positive; 422 int rc; 423 423 424 424 if (!socket_id) … … 447 447 socket->key_length = 0; 448 448 socket->specific_data = specific_data; 449 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,450 SOCKET_INITIAL_RECEIVED_SIZE))) {449 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 450 if (rc != EOK) { 451 451 free(socket); 452 return ERROR_CODE; 453 } 454 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted, 455 SOCKET_INITIAL_ACCEPTED_SIZE))) { 452 return rc; 453 } 454 455 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 456 if (rc != EOK) { 456 457 dyn_fifo_destroy(&socket->received); 457 458 free(socket); 458 return ERROR_CODE;459 return rc; 459 460 } 460 461 socket->socket_id = *socket_id; 461 r es= socket_cores_add(local_sockets, socket->socket_id, socket);462 if (r es< 0) {462 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 463 if (rc < 0) { 463 464 dyn_fifo_destroy(&socket->received); 464 465 dyn_fifo_destroy(&socket->accepted); 465 466 free(socket); 466 return r es;467 return rc; 467 468 } 468 469 … … 523 524 int socket_reply_packets(packet_t packet, size_t *length) 524 525 { 525 ERROR_DECLARE;526 527 526 packet_t next_packet; 528 527 size_t fragments; 529 528 size_t *lengths; 530 529 size_t index; 530 int rc; 531 531 532 532 if (!length) … … 536 536 if (!next_packet) { 537 537 // write all if only one fragment 538 ERROR_PROPAGATE(data_reply(packet_get_data(packet), 539 packet_get_data_length(packet))); 538 rc = data_reply(packet_get_data(packet), 539 packet_get_data_length(packet)); 540 if (rc != EOK) 541 return rc; 540 542 // store the total length 541 543 *length = packet_get_data_length(packet); … … 564 566 565 567 // write the fragment lengths 566 if (ERROR_OCCURRED(data_reply(lengths,567 sizeof(int) * (fragments + 1)))) {568 rc = data_reply(lengths, sizeof(int) * (fragments + 1)); 569 if (rc != EOK) { 568 570 free(lengths); 569 return ERROR_CODE;571 return rc; 570 572 } 571 573 next_packet = packet; … … 573 575 // write the fragments 574 576 for (index = 0; index < fragments; ++index) { 575 ERROR_CODE= data_reply(packet_get_data(next_packet),577 rc = data_reply(packet_get_data(next_packet), 576 578 lengths[index]); 577 if ( ERROR_OCCURRED(ERROR_CODE)) {579 if (rc != EOK) { 578 580 free(lengths); 579 return ERROR_CODE;581 return rc; 580 582 } 581 583 next_packet = pq_next(next_packet); … … 680 682 socket_core_ref socket, const char *key, size_t key_length) 681 683 { 682 ERROR_DECLARE;683 684 684 socket_port_ref socket_port; 685 int rc; 685 686 686 687 // find ports … … 690 691 691 692 // add the socket 692 ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key, 693 key_length)); 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 if (rc != EOK) 695 return rc; 694 696 695 697 socket->port = port;
Note:
See TracChangeset
for help on using the changeset viewer.