Changes in uspace/srv/net/tl/icmp/icmp.c [aadf01e:b48ebd19] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/icmp/icmp.c
raadf01e rb48ebd19 41 41 #include <fibril_synch.h> 42 42 #include <stdint.h> 43 #include <string.h> 43 44 44 45 #include <ipc/ipc.h> … … 175 176 /** Requests an echo message. 176 177 * 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.178 * Blocks the caller until the reply or the timeout occurs. 178 179 * @param[in] id The message identifier. 179 180 * @param[in] sequence The message sequence parameter. … … 221 222 222 223 /** 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.224 * If the reply data is not present, the reply timed out and the other fibril 225 * is already awake. 225 226 * Releases the packet. 226 227 * @param[in] packet The received reply message. … … 334 335 } 335 336 336 // unlock the globals and wait for areply337 // unlock the globals so that we can wait for the reply 337 338 fibril_rwlock_write_unlock(&icmp_globals.lock); 338 339 … … 340 341 icmp_send_packet(ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment); 341 342 342 // wait for areply343 // wait for the reply 343 344 // timeout in microseconds 344 345 if(ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex, timeout * 1000))){ 345 346 result = ERROR_CODE; 346 347 // lock the globals again and clean up348 fibril_rwlock_write_lock(&icmp_globals.lock);349 347 }else{ 350 348 // read the result 351 349 result = reply->result; 352 353 // release the reply structure 354 fibril_mutex_unlock(&reply->mutex); 355 } 350 } 351 352 // drop the reply mutex before locking the globals again 353 fibril_mutex_unlock(&reply->mutex); 354 fibril_rwlock_write_lock(&icmp_globals.lock); 356 355 357 356 // destroy the reply structure … … 636 635 // set the result 637 636 reply->result = type; 638 // notify the mainfibril637 // notify the waiting fibril 639 638 fibril_condvar_signal(&reply->condvar); 640 }else{ 641 // unlock only if no reply 642 fibril_rwlock_write_unlock(&icmp_globals.lock); 643 } 639 } 640 fibril_rwlock_write_unlock(&icmp_globals.lock); 644 641 return EOK; 645 642 }
Note:
See TracChangeset
for help on using the changeset viewer.