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