Changeset 0ab68f6 in mainline for uspace/lib/net/tl
- Timestamp:
- 2010-11-07T20:48:21Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a5d238f
- Parents:
- 88b127b
- Location:
- uspace/lib/net/tl
- Files:
-
- 2 edited
-
socket_core.c (modified) (13 diffs)
-
tl_common.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/socket_core.c
r88b127b r0ab68f6 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; -
uspace/lib/net/tl/tl_common.c
r88b127b r0ab68f6 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h>57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 124 123 packet_dimension_ref *packet_dimension) 125 124 { 126 ERROR_DECLARE;125 int rc; 127 126 128 127 if (!packet_dimension) … … 137 136 return ENOMEM; 138 137 139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,140 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 141 140 free(*packet_dimension); 142 return ERROR_CODE;141 return rc; 143 142 } 144 143 145 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 146 145 *packet_dimension); 147 if ( ERROR_CODE< 0) {146 if (rc < 0) { 148 147 free(*packet_dimension); 149 return ERROR_CODE;148 return rc; 150 149 } 151 150 } … … 292 291 socklen_t addrlen) 293 292 { 294 ERROR_DECLARE;295 296 293 ipc_callid_t callid; 297 294 size_t length; 298 void * data; 295 void *data; 296 int rc; 299 297 300 298 if (!dimension) … … 319 317 320 318 // read the data into the packet 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 325 321 pq_release_remote(packet_phone, packet_get_id(*packet)); 326 return ERROR_CODE; 322 return rc; 323 } 324 325 // set the packet destination address 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 329 return rc; 327 330 } 328 331
Note:
See TracChangeset
for help on using the changeset viewer.
