Changeset 49bd793b in mainline for uspace/lib/c/generic/net/packet.c


Ignore:
Timestamp:
2011-10-07T21:42:14Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
80099c19
Parents:
00d7e1b
Message:

networking fixes

  • use sysarg_t for packet_id_t to avoid potential overflow
  • fix the confusion in the order of arguments for nil_received_msg(), this fixes the strange ping timeout on 127.0.0.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/packet.c

    r00d7e1b r49bd793b  
    139139packet_t *pm_find(packet_id_t packet_id)
    140140{
    141         packet_t *packet;
    142141        if (!packet_id)
    143142                return NULL;
    144 
     143       
    145144        fibril_rwlock_read_lock(&pm_globals.lock);
    146         link_t *link =
    147             hash_table_find(&pm_globals.packet_map, &packet_id);
     145       
     146        unsigned long key = packet_id;
     147        link_t *link = hash_table_find(&pm_globals.packet_map, &key);
     148       
     149        packet_t *packet;
    148150        if (link != NULL) {
    149151                pm_entry_t *entry =
     
    172174       
    173175        fibril_rwlock_write_lock(&pm_globals.lock);
    174         pm_entry_t *entry = malloc(sizeof (pm_entry_t));
     176       
     177        pm_entry_t *entry = malloc(sizeof(pm_entry_t));
    175178        if (entry == NULL) {
    176179                fibril_rwlock_write_unlock(&pm_globals.lock);
     
    179182       
    180183        entry->packet = packet;
    181         hash_table_insert(&pm_globals.packet_map, &packet->packet_id,
    182             &entry->link);
     184       
     185        unsigned long key = packet->packet_id;
     186        hash_table_insert(&pm_globals.packet_map, &key, &entry->link);
     187       
    183188        fibril_rwlock_write_unlock(&pm_globals.lock);
     189       
    184190        return EOK;
    185191}
     
    195201       
    196202        fibril_rwlock_write_lock(&pm_globals.lock);
    197         hash_table_remove(&pm_globals.packet_map, &packet->packet_id, 1);
     203       
     204        unsigned long key = packet->packet_id;
     205        hash_table_remove(&pm_globals.packet_map, &key, 1);
     206       
    198207        fibril_rwlock_write_unlock(&pm_globals.lock);
    199208}
Note: See TracChangeset for help on using the changeset viewer.