Changeset 16ac756 in mainline
- Timestamp:
- 2010-11-07T19:47:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88b127b, 9ce7eb5
- Parents:
- 9fd39d6
- Location:
- uspace/lib/c/generic/net
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/modules.c
r9fd39d6 r16ac756 41 41 #include <async.h> 42 42 #include <malloc.h> 43 #include <err .h>43 #include <errno.h> 44 44 #include <sys/time.h> 45 45 … … 137 137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 ERROR_DECLARE;139 int rc; 140 140 141 141 /* Connect to the needed service */ … … 144 144 /* Request the bidirectional connection */ 145 145 ipcarg_t phonehash; 146 if (ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, 147 &phonehash))) { 146 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); 148 if (rc != EOK) { 148 149 ipc_hangup(phone); 149 return ERROR_CODE;150 return rc; 150 151 } 151 152 async_new_connection(phonehash, 0, NULL, client_receiver); … … 212 213 int data_receive(void **data, size_t *length) 213 214 { 214 ERROR_DECLARE;215 216 215 ipc_callid_t callid; 216 int rc; 217 217 218 218 if (!data || !length) … … 229 229 230 230 // fetch the data 231 if (ERROR_OCCURRED(async_data_write_finalize(callid, *data, *length))) { 231 rc = async_data_write_finalize(callid, *data, *length); 232 if (rc != EOK) { 232 233 free(data); 233 return ERROR_CODE;234 return rc; 234 235 } 235 236 -
uspace/lib/c/generic/net/packet.c
r9fd39d6 r16ac756 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 45 44 #include <sys/mman.h> … … 91 90 int pm_init(void) 92 91 { 93 ERROR_DECLARE;92 int rc; 94 93 95 94 fibril_rwlock_initialize(&pm_globals.lock); 95 96 96 fibril_rwlock_write_lock(&pm_globals.lock); 97 ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));97 rc = gpm_initialize(&pm_globals.packet_map); 98 98 fibril_rwlock_write_unlock(&pm_globals.lock); 99 return EOK; 99 100 return rc; 100 101 } 101 102 … … 139 140 int pm_add(packet_t packet) 140 141 { 141 ERROR_DECLARE;142 143 142 packet_map_ref map; 143 int rc; 144 144 145 145 if (!packet_is_valid(packet)) … … 160 160 } 161 161 bzero(map, sizeof(packet_map_t)); 162 if ((ERROR_CODE =163 gpm_add(&pm_globals.packet_map, map))< 0) {162 rc = gpm_add(&pm_globals.packet_map, map); 163 if (rc < 0) { 164 164 fibril_rwlock_write_unlock(&pm_globals.lock); 165 165 free(map); 166 return ERROR_CODE;166 return rc; 167 167 } 168 168 } while (PACKET_MAP_PAGE(packet->packet_id) >= -
uspace/lib/c/generic/net/socket_client.c
r9fd39d6 r16ac756 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 #include <err.h>46 45 47 46 #include <ipc/services.h> … … 212 211 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 213 212 { 214 ERROR_DECLARE;215 216 213 ipc_callid_t callid; 217 214 ipc_call_t call; 218 215 socket_ref socket; 216 int rc; 219 217 220 218 loop: … … 231 229 SOCKET_GET_SOCKET_ID(call)); 232 230 if (!socket) { 233 ERROR_CODE= ENOTSOCK;231 rc = ENOTSOCK; 234 232 fibril_rwlock_read_unlock(&socket_globals.lock); 235 233 break; … … 240 238 fibril_mutex_lock(&socket->receive_lock); 241 239 // push the number of received packet fragments 242 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->received,240 rc = dyn_fifo_push(&socket->received, 243 241 SOCKET_GET_DATA_FRAGMENTS(call), 244 SOCKET_MAX_RECEIVED_SIZE))) { 242 SOCKET_MAX_RECEIVED_SIZE); 243 if (rc == EOK) { 245 244 // signal the received packet 246 245 fibril_condvar_signal(&socket->receive_signal); … … 252 251 // push the new socket identifier 253 252 fibril_mutex_lock(&socket->accept_lock); 254 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 255 1, SOCKET_MAX_ACCEPTED_SIZE))) { 253 rc = dyn_fifo_push(&socket->accepted, 1, 254 SOCKET_MAX_ACCEPTED_SIZE); 255 if (rc != EOK) { 256 256 // signal the accepted socket 257 257 fibril_condvar_signal(&socket->accept_signal); … … 261 261 262 262 default: 263 ERROR_CODE= ENOTSUP;263 rc = ENOTSUP; 264 264 } 265 265 … … 280 280 281 281 default: 282 ERROR_CODE= ENOTSUP;283 } 284 285 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE);282 rc = ENOTSUP; 283 } 284 285 ipc_answer_0(callid, (ipcarg_t) rc); 286 286 goto loop; 287 287 } … … 405 405 int socket(int domain, int type, int protocol) 406 406 { 407 ERROR_DECLARE;408 409 407 socket_ref socket; 410 408 int phone; … … 413 411 ipcarg_t fragment_size; 414 412 ipcarg_t header_size; 413 int rc; 415 414 416 415 // find the appropriate service … … 479 478 } 480 479 481 if (ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, 482 service, NULL, &fragment_size, &header_size))) { 480 rc = (int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 481 &fragment_size, &header_size); 482 if (rc != EOK) { 483 483 fibril_rwlock_write_unlock(&socket_globals.lock); 484 484 free(socket); 485 return ERROR_CODE;485 return rc; 486 486 } 487 487 … … 492 492 socket_initialize(socket, socket_id, phone, service); 493 493 // store the new socket 494 ERROR_CODE= sockets_add(socket_get_sockets(), socket_id, socket);494 rc = sockets_add(socket_get_sockets(), socket_id, socket); 495 495 496 496 fibril_rwlock_write_unlock(&socket_globals.lock); 497 if ( ERROR_CODE< 0) {497 if (rc < 0) { 498 498 dyn_fifo_destroy(&socket->received); 499 499 dyn_fifo_destroy(&socket->accepted); … … 501 501 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, 502 502 service); 503 return ERROR_CODE;503 return rc; 504 504 } 505 505 … … 770 770 int closesocket(int socket_id) 771 771 { 772 ERROR_DECLARE;773 774 772 socket_ref socket; 773 int rc; 775 774 776 775 fibril_rwlock_write_lock(&socket_globals.lock); … … 787 786 788 787 // request close 789 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 790 (ipcarg_t) socket->socket_id, 0, socket->service)); 788 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 789 (ipcarg_t) socket->socket_id, 0, socket->service); 790 if (rc != EOK) { 791 fibril_rwlock_write_unlock(&socket_globals.lock); 792 return rc; 793 } 791 794 // free the socket structure 792 795 socket_destroy(socket);
Note:
See TracChangeset
for help on using the changeset viewer.