Ignore:
File:
1 edited

Legend:

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

    rab9378b4 rfbcdeb8  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <fibril_synch.h>
    4140#include <ipc/packet.h>
    4241#include <sys/mman.h>
     
    4746#include <net/packet.h>
    4847#include <net/packet_header.h>
    49 
    50 static FIBRIL_MUTEX_INITIALIZE(packet_return_lock);
    5148
    5249/** Obtain the packet from the packet server as the shared memory block.
     
    6966    packet_id_t packet_id, size_t size)
    7067{
    71         /*
    72          * Prevent racing for address space with other invocations
    73          * of packet_return().
    74          *
    75          * XXX This of course does not prevent us racing with other
    76          * competitors for address space mapping.
    77          */
    78         fibril_mutex_lock(&packet_return_lock);
    79         *packet = (packet_t *) as_get_mappable_page(size);
    80        
    8168        async_exch_t *exch = async_exchange_begin(sess);
    8269        ipc_call_t answer;
    8370        aid_t message = async_send_1(exch, NET_PACKET_GET, packet_id, &answer);
    84         int rc = async_share_in_start_0_0(exch, *packet, size);
     71        int rc = async_share_in_start_0_0(exch, size, (void *) packet);
    8572        async_exchange_end(exch);
    8673       
     
    8875        async_wait_for(message, &result);
    8976       
    90         if (rc != EOK) {
    91                 munmap(*packet, size);
    92                 fibril_mutex_unlock(&packet_return_lock);
     77        if (rc != EOK)
    9378                return rc;
    94         }
     79       
     80        if (packet == (void *) -1)
     81                return ENOMEM;
    9582       
    9683        rc = pm_add(*packet);
    9784        if (rc != EOK) {
    9885                munmap(*packet, size);
    99                 fibril_mutex_unlock(&packet_return_lock);
    10086                return rc;
    10187        }
    10288       
    103         fibril_mutex_unlock(&packet_return_lock);
    10489        return result;
    10590}
Note: See TracChangeset for help on using the changeset viewer.