Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4581 → Rev 4582

/branches/network/uspace/srv/net/structures/packet/packet_server.c
37,7 → 37,7
#include <align.h>
#include <async.h>
#include <errno.h>
#include <futex.h>
#include <fibril_sync.h>
//#include <stdio.h>
#include <unistd.h>
 
72,7 → 72,7
static struct{
/** Safety lock.
*/
futex_t lock;
fibril_mutex_t lock;
/** Free packet queues.
*/
packet_t free[ FREE_QUEUES_COUNT ];
85,7 → 85,7
*/
unsigned int count;
} ps_globals = {
{ 1 },
{ .counter = 1, .waiters = { .prev = & ps_globals.lock.waiters, .next = & ps_globals.lock.waiters, }},
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL },
{ PAGE_SIZE, PAGE_SIZE * 2, PAGE_SIZE * 4, PAGE_SIZE * 8, PAGE_SIZE * 16, PAGE_SIZE * 32, PAGE_SIZE * 64 },
0
208,9 → 208,9
 
packet = pm_find( packet_id );
if( ! packet_is_valid( packet )) return ENOENT;
futex_down( & ps_globals.lock );
fibril_mutex_lock( & ps_globals.lock );
pq_destroy( packet, packet_release );
futex_up( & ps_globals.lock );
fibril_mutex_unlock( & ps_globals.lock );
return EOK;
}
 
227,7 → 227,7
size_t length;
 
length = ALIGN_UP( sizeof( struct packet ) + 2 * addr_len + max_prefix + max_content + max_suffix, PAGE_SIZE );
futex_down( & ps_globals.lock );
fibril_mutex_lock( & ps_globals.lock );
for( index = 0; index < FREE_QUEUES_COUNT - 1; ++ index ){
if( length <= ps_globals.sizes[ index ] ){
packet = ps_globals.free[ index ];
241,13 → 241,13
pq_detach( packet );
}
packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
futex_up( & ps_globals.lock );
fibril_mutex_unlock( & ps_globals.lock );
return packet;
}
}
}
packet = packet_create( length, addr_len, max_prefix, max_content, max_suffix );
futex_up( & ps_globals.lock );
fibril_mutex_unlock( & ps_globals.lock );
return packet;
}