Changeset 936835e in mainline for uspace/srv/net/tl/icmp/icmp.c


Ignore:
Timestamp:
2010-03-07T15:35:32Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
836dd794
Parents:
aadf01e (diff), b5cbff4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes, revision 311

File:
1 edited

Legend:

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

    raadf01e r936835e  
    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.
     
    334334        }
    335335
    336         // unlock the globals and wait for a reply
     336        // unlock the globals so that we can wait for the reply
    337337        fibril_rwlock_write_unlock(&icmp_globals.lock);
    338338
     
    340340        icmp_send_packet(ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment);
    341341
    342         // wait for a reply
     342        // wait for the reply
    343343        // timeout in microseconds
    344344        if(ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex, timeout * 1000))){
    345345                result = ERROR_CODE;
    346 
    347                 // lock the globals again and clean up
    348                 fibril_rwlock_write_lock(&icmp_globals.lock);
    349346        }else{
    350347                // read the result
    351348                result = reply->result;
    352 
    353                 // release the reply structure
    354                 fibril_mutex_unlock(&reply->mutex);
    355         }
     349        }
     350
     351        // drop the reply mutex before locking the globals again
     352        fibril_mutex_unlock(&reply->mutex);
     353        fibril_rwlock_write_lock(&icmp_globals.lock);
    356354
    357355        // destroy the reply structure
     
    636634                // set the result
    637635                reply->result = type;
    638                 // notify the main fibril
     636                // notify the waiting fibril
    639637                fibril_condvar_signal(&reply->condvar);
    640         }else{
    641                 // unlock only if no reply
    642                 fibril_rwlock_write_unlock(&icmp_globals.lock);
    643         }
     638        }
     639        fibril_rwlock_write_unlock(&icmp_globals.lock);
    644640        return EOK;
    645641}
Note: See TracChangeset for help on using the changeset viewer.