123,6 → 123,19 |
*/ |
typedef icmp_reply_timeout_t * icmp_reply_timeout_ref; |
|
/** ICMP reply timeout data. |
* Used as a timeouting fibril argument. |
* @see icmp_timeout_for_reply() |
*/ |
struct icmp_reply_timeout{ |
/** Reply data key. |
*/ |
int reply_key; |
/** Timeout in microseconds. |
*/ |
suseconds_t timeout; |
}; |
|
/** Processes the received ICMP packet. |
* Is used as an entry point from the underlying IP module. |
* Releases the packet on error. |
252,19 → 265,6 |
*/ |
int icmp_bind_free_id( icmp_echo_ref echo_data ); |
|
/** ICMP reply timeout data. |
* Used as a timeouting fibril argument. |
* @see icmp_timeout_for_reply() |
*/ |
struct icmp_reply_timeout{ |
/** Reply data key. |
*/ |
int reply_key; |
/** Timeout in microseconds. |
*/ |
suseconds_t timeout; |
}; |
|
/** ICMP global data. |
*/ |
icmp_globals_t icmp_globals; |
379,6 → 379,13 |
free( reply_timeout ); |
return icmp_release_and_return( packet, ENOMEM ); |
} |
// prepare the timeouting thread |
fibril = fibril_create( icmp_timeout_for_reply, reply_timeout ); |
if( ! fibril ){ |
free( reply ); |
free( reply_timeout ); |
return icmp_release_and_return( packet, EPARTY ); |
} |
reply_timeout->reply_key = ICMP_GET_REPLY_KEY( header->un.echo.identifier, header->un.echo.sequence_number ); |
// timeout in microseconds |
reply_timeout->timeout = timeout * 1000; |
385,18 → 392,13 |
fibril_mutex_initialize( & reply->mutex ); |
fibril_mutex_lock( & reply->mutex ); |
fibril_condvar_initialize( & reply->condvar ); |
// start the timeouting fibril |
fibril_add_ready( fibril ); |
index = icmp_replies_add( & icmp_globals.replies, reply_timeout->reply_key, reply ); |
if( index < 0 ){ |
free( reply ); |
free( reply_timeout ); |
return icmp_release_and_return( packet, index ); |
} |
// start the timeouting thread |
fibril = fibril_create( icmp_timeout_for_reply, reply_timeout ); |
if( ! fibril ){ |
return EPARTY; |
} |
fibril_add_ready( fibril ); |
|
// unlock the globals and wait for a reply |
fibril_rwlock_write_unlock( & icmp_globals.lock ); |
406,6 → 408,7 |
|
// wait for a reply |
fibril_condvar_wait( & reply->condvar, & reply->mutex ); |
|
// read the result |
result = reply->result; |
|