Rev 4589 | Rev 4708 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4589 | Rev 4603 | ||
---|---|---|---|
Line 452... | Line 452... | ||
452 | int index; |
452 | int index; |
453 | ipc_call_t answer; |
453 | ipc_call_t answer; |
454 | 454 | ||
455 | if( ! data ) return EBADMEM; |
455 | if( ! data ) return EBADMEM; |
456 | if( ! datalength ) return NO_DATA; |
456 | if( ! datalength ) return NO_DATA; |
- | 457 | if( fromaddr && (( ! addrlen ) || ( * addrlen < sizeof( struct sockaddr_in )))) return EINVAL; |
|
457 | // find the socket |
458 | // find the socket |
458 | socket = sockets_find( socket_get_sockets(), socket_id ); |
459 | socket = sockets_find( socket_get_sockets(), socket_id ); |
459 | if( ! socket ) return ENOTSOCK; |
460 | if( ! socket ) return ENOTSOCK; |
460 | fibril_mutex_lock( & socket->receive_lock ); |
461 | fibril_mutex_lock( & socket->receive_lock ); |
461 | // wait for a received packet |
462 | // wait for a received packet |
Line 471... | Line 472... | ||
471 | } |
472 | } |
472 | } |
473 | } |
473 | // request packet data |
474 | // request packet data |
474 | message_id = async_send_4( socket->phone, message, socket->socket_id, 0, socket->service, flags, & answer ); |
475 | message_id = async_send_4( socket->phone, message, socket->socket_id, 0, socket->service, flags, & answer ); |
475 | // read the address if desired |
476 | // read the address if desired |
476 | if( fromaddr ){ |
- | |
477 | * addrlen = sizeof( struct sockaddr_in ); |
- | |
478 | } |
- | |
479 | if(( ! fromaddr ) || ( ipc_data_read_start( socket->phone, fromaddr, * addrlen ) == EOK )){ |
477 | if(( ! fromaddr ) || ( ipc_data_read_start( socket->phone, fromaddr, * addrlen ) == EOK )){ |
480 | if( fragments == 1 ){ |
478 | if( fragments == 1 ){ |
481 | // read all if only one fragment |
479 | // read all if only one fragment |
482 | ipc_data_read_start( socket->phone, data, datalength ); |
480 | ipc_data_read_start( socket->phone, data, datalength ); |
483 | }else{ |
481 | }else{ |
Line 501... | Line 499... | ||
501 | if( result == EOK ){ |
499 | if( result == EOK ){ |
502 | // dequeue the received packet |
500 | // dequeue the received packet |
503 | dyn_fifo_pop( & socket->received ); |
501 | dyn_fifo_pop( & socket->received ); |
504 | // return read data length |
502 | // return read data length |
505 | result = SOCKET_GET_READ_DATA_LENGTH( & answer ); |
503 | result = SOCKET_GET_READ_DATA_LENGTH( & answer ); |
- | 504 | // set address length |
|
- | 505 | if( fromaddr && addrlen ) * addrlen = SOCKET_GET_ADDRESS_LENGTH( & answer ); |
|
506 | } |
506 | } |
507 | fibril_mutex_unlock( & socket->receive_lock ); |
507 | fibril_mutex_unlock( & socket->receive_lock ); |
508 | return result; |
508 | return result; |
509 | } |
509 | } |
510 | 510 |