Changeset b5cbff4 in mainline
- Timestamp:
- 2010-03-06T14:46:47Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 71b00dcc, 936835e
- Parents:
- 7d31f7c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/icmp/icmp.c
r7d31f7c rb5cbff4 175 175 /** Requests an echo message. 176 176 * Sends a packet with specified parameters to the target host and waits for the reply upto the given timeout. 177 * Blocks the caller until the reply or the timeout occur res.177 * Blocks the caller until the reply or the timeout occurs. 178 178 * @param[in] id The message identifier. 179 179 * @param[in] sequence The message sequence parameter. … … 221 221 222 222 /** Tries to set the pending reply result as the received message type. 223 * If the reply data are still present, the reply timeouted and the parent fibril is awaken.224 * The global lock is not released in this case to be reused by the parent fibril.223 * If the reply data is not present, the reply timed out and the other fibril 224 * is already awake. 225 225 * Releases the packet. 226 226 * @param[in] packet The received reply message. … … 332 332 } 333 333 334 // unlock the globals and wait for areply334 // unlock the globals so that we can wait for the reply 335 335 fibril_rwlock_write_unlock( & icmp_globals.lock ); 336 336 … … 338 338 icmp_send_packet( ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment ); 339 339 340 // wait for areply340 // wait for the reply 341 341 // timeout in microseconds 342 342 if( ERROR_OCCURRED( fibril_condvar_wait_timeout( & reply->condvar, & reply->mutex, timeout * 1000 ))){ 343 343 result = ERROR_CODE; 344 345 // drop the reply mutex346 fibril_mutex_unlock( & reply->mutex );347 // lock the globals again and clean up348 fibril_rwlock_write_lock( & icmp_globals.lock );349 344 }else{ 350 345 // read the result 351 346 result = reply->result; 352 353 // release the reply structure 354 fibril_mutex_unlock( & reply->mutex ); 355 } 347 } 348 349 // drop the reply mutex before locking the globals again 350 fibril_mutex_unlock( & reply->mutex ); 351 fibril_rwlock_write_lock( & icmp_globals.lock ); 356 352 357 353 // destroy the reply structure … … 620 616 // set the result 621 617 reply->result = type; 622 // notify the mainfibril618 // notify the waiting fibril 623 619 fibril_condvar_signal( & reply->condvar ); 624 }else{ 625 // unlock only if no reply 626 fibril_rwlock_write_unlock( & icmp_globals.lock ); 627 } 620 } 621 fibril_rwlock_write_unlock( & icmp_globals.lock ); 628 622 return EOK; 629 623 }
Note:
See TracChangeset
for help on using the changeset viewer.