Changeset 92307f1 in mainline
- Timestamp:
- 2010-03-02T22:52:27Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7d31f7c, 858fc90
- Parents:
- 8ab2074
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/udp/udp.c
r8ab2074 r92307f1 420 420 struct sockaddr * addr; 421 421 size_t addrlen; 422 fibril_rwlock_t lock;423 422 ipc_call_t answer; 424 423 int answer_count; … … 434 433 435 434 socket_cores_initialize( & local_sockets ); 436 fibril_rwlock_initialize( & lock );437 435 438 436 while( keep_on_going ){ … … 449 447 break; 450 448 case NET_SOCKET: 451 fibril_rwlock_write_lock( & lock );452 449 * SOCKET_SET_SOCKET_ID( answer ) = SOCKET_GET_SOCKET_ID( call ); 453 450 res = socket_create( & local_sockets, app_phone, NULL, SOCKET_SET_SOCKET_ID( answer )); 454 fibril_rwlock_write_unlock( & lock );455 451 if( res == EOK ){ 456 452 if( tl_get_ip_packet_dimension( udp_globals.ip_phone, & udp_globals.dimensions, DEVICE_INVALID_ID, & packet_dimension ) == EOK ){ … … 465 461 res = data_receive(( void ** ) & addr, & addrlen ); 466 462 if( res == EOK ){ 467 fibril_rwlock_read_lock( & lock );468 463 fibril_rwlock_write_lock( & udp_globals.lock ); 469 464 res = socket_bind( & local_sockets, & udp_globals.sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port ); 470 465 fibril_rwlock_write_unlock( & udp_globals.lock ); 471 fibril_rwlock_read_unlock( & lock );472 466 free( addr ); 473 467 } … … 476 470 res = data_receive(( void ** ) & addr, & addrlen ); 477 471 if( res == EOK ){ 478 fibril_rwlock_read_lock( & lock );479 472 fibril_rwlock_write_lock( & udp_globals.lock ); 480 473 res = udp_sendto_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_SET_DATA_FRAGMENT_SIZE( answer ), SOCKET_GET_FLAGS( call )); … … 484 477 answer_count = 2; 485 478 } 486 fibril_rwlock_read_unlock( & lock );487 479 free( addr ); 488 480 } 489 481 break; 490 482 case NET_SOCKET_RECVFROM: 491 fibril_rwlock_read_lock( & lock );492 483 fibril_rwlock_write_lock( & udp_globals.lock ); 493 484 res = udp_recvfrom_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_FLAGS( call ), & addrlen ); 494 485 fibril_rwlock_write_unlock( & udp_globals.lock ); 495 fibril_rwlock_read_unlock( & lock );496 486 if( res > 0 ){ 497 487 * SOCKET_SET_READ_DATA_LENGTH( answer ) = res; … … 502 492 break; 503 493 case NET_SOCKET_CLOSE: 504 fibril_rwlock_write_lock( & lock );505 494 fibril_rwlock_write_lock( & udp_globals.lock ); 506 495 res = socket_destroy( udp_globals.net_phone, SOCKET_GET_SOCKET_ID( call ), & local_sockets, & udp_globals.sockets, NULL ); 507 496 fibril_rwlock_write_unlock( & udp_globals.lock ); 508 fibril_rwlock_write_unlock( & lock );509 497 break; 510 498 case NET_SOCKET_GETSOCKOPT:
Note:
See TracChangeset
for help on using the changeset viewer.