Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b5cbff4 in mainline


Ignore:
Timestamp:
2010-03-06T14:46:47Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
71b00dcc, 936835e
Parents:
7d31f7c
Message:

Do not pass icmp_globals.lock ownership between fibrils.
Fix some typos and comments in the ICMP module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/icmp/icmp.c

    r7d31f7c rb5cbff4  
    175175/** Requests an echo message.
    176176 *  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 occurres.
     177 *  Blocks the caller until the reply or the timeout occurs.
    178178 *  @param[in] id The message identifier.
    179179 *  @param[in] sequence The message sequence parameter.
     
    221221
    222222/** 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.
    225225 *  Releases the packet.
    226226 *  @param[in] packet The received reply message.
     
    332332        }
    333333
    334         // unlock the globals and wait for a reply
     334        // unlock the globals so that we can wait for the reply
    335335        fibril_rwlock_write_unlock( & icmp_globals.lock );
    336336
     
    338338        icmp_send_packet( ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment );
    339339
    340         // wait for a reply
     340        // wait for the reply
    341341        // timeout in microseconds
    342342        if( ERROR_OCCURRED( fibril_condvar_wait_timeout( & reply->condvar, & reply->mutex, timeout * 1000 ))){
    343343                result = ERROR_CODE;
    344 
    345                 // drop the reply mutex
    346                 fibril_mutex_unlock( & reply->mutex );
    347                 // lock the globals again and clean up
    348                 fibril_rwlock_write_lock( & icmp_globals.lock );
    349344        }else{
    350345                // read the result
    351346                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 );
    356352
    357353        // destroy the reply structure
     
    620616                // set the result
    621617                reply->result = type;
    622                 // notify the main fibril
     618                // notify the waiting fibril
    623619                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 );
    628622        return EOK;
    629623}
Note: See TracChangeset for help on using the changeset viewer.