Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision 7d31f7ccc521dc4f0fc2b66a9f9788656377698d)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision b5cbff48576a057d15deb2e28751ec635d099719)
@@ -175,5 +175,5 @@
 /** Requests an echo message.
  *  Sends a packet with specified parameters to the target host and waits for the reply upto the given timeout.
- *  Blocks the caller until the reply or the timeout occurres.
+ *  Blocks the caller until the reply or the timeout occurs.
  *  @param[in] id The message identifier.
  *  @param[in] sequence The message sequence parameter.
@@ -221,6 +221,6 @@
 
 /** Tries to set the pending reply result as the received message type.
- *  If the reply data are still present, the reply timeouted and the parent fibril is awaken.
- *  The global lock is not released in this case to be reused by the parent fibril.
+ *  If the reply data is not present, the reply timed out and the other fibril
+ *  is already awake.
  *  Releases the packet.
  *  @param[in] packet The received reply message.
@@ -332,5 +332,5 @@
 	}
 
-	// unlock the globals and wait for a reply
+	// unlock the globals so that we can wait for the reply
 	fibril_rwlock_write_unlock( & icmp_globals.lock );
 
@@ -338,20 +338,16 @@
 	icmp_send_packet( ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment );
 
-	// wait for a reply
+	// wait for the reply
 	// timeout in microseconds
 	if( ERROR_OCCURRED( fibril_condvar_wait_timeout( & reply->condvar, & reply->mutex, timeout * 1000 ))){
 		result = ERROR_CODE;
-
-		// drop the reply mutex
-		fibril_mutex_unlock( & reply->mutex );
-		// lock the globals again and clean up
-		fibril_rwlock_write_lock( & icmp_globals.lock );
 	}else{
 		// read the result
 		result = reply->result;
-
-		// release the reply structure
-		fibril_mutex_unlock( & reply->mutex );
-	}
+	}
+
+	// drop the reply mutex before locking the globals again
+	fibril_mutex_unlock( & reply->mutex );
+	fibril_rwlock_write_lock( & icmp_globals.lock );
 
 	// destroy the reply structure
@@ -620,10 +616,8 @@
 		// set the result
 		reply->result = type;
-		// notify the main fibril
+		// notify the waiting fibril
 		fibril_condvar_signal( & reply->condvar );
-	}else{
-		// unlock only if no reply
-		fibril_rwlock_write_unlock( & icmp_globals.lock );
-	}
+	}
+	fibril_rwlock_write_unlock( & icmp_globals.lock );
 	return EOK;
 }
