Changeset 1e2e0c1e in mainline for uspace/srv/net/structures
- Timestamp:
- 2010-02-17T21:15:03Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e6b7b198
- Parents:
- bfd7aac
- Location:
- uspace/srv/net/structures/packet
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/structures/packet/packet.c
rbfd7aac r1e2e0c1e 184 184 } 185 185 186 packet_t pq_add( packet_tfirst, packet_t packet, size_t order, size_t metric ){186 int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ){ 187 187 packet_t item; 188 188 189 if( ! packet_is_valid( packet )) return NULL;189 if(( ! first ) || ( ! packet_is_valid( packet ))) return EINVAL; 190 190 pq_set_order( packet, order, metric ); 191 if( packet_is_valid( first )){192 item = first;191 if( packet_is_valid( * first )){ 192 item = * first; 193 193 do{ 194 194 if( item->order < order ){ … … 198 198 item->next = packet->packet_id; 199 199 packet->previous = item->packet_id; 200 return first;200 return EOK; 201 201 } 202 202 }else{ … … 205 205 item->previous = packet->packet_id; 206 206 item = pm_find( packet->previous ); 207 if( item ) item->next = packet->packet_id; 208 return item ? first : packet; 207 if( item ){ 208 item->next = packet->packet_id; 209 }else{ 210 * first = packet; 211 } 212 return EOK; 209 213 } 210 214 }while( packet_is_valid( item )); 211 215 } 212 return packet; 216 * first = packet; 217 return EOK; 213 218 } 214 219 -
uspace/srv/net/structures/packet/packet.h
rbfd7aac r1e2e0c1e 86 86 * The queue is sorted in the ascending order. 87 87 * The packet is inserted right before the packets of the same order value. 88 * @param[in ] first The first packet of the queue. May be NULL.88 * @param[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet. 89 89 * @param[in] packet The packet to be added. 90 90 * @param[in] order The packet order value. 91 91 * @param[in] metric The metric value of the packet. 92 * @returns The first packet of the queue. The original first packet may be shifted by the new packet. 93 * @returns NULL if the packet is not valid. 92 * @returns EOK on success. 93 * @returns EINVAL if the first parameter is NULL. 94 * @returns EINVAL if the packet is not valid. 94 95 */ 95 packet_t pq_add( packet_tfirst, packet_t packet, size_t order, size_t metric );96 int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ); 96 97 97 98 /** Finds the packet with the given order. -
uspace/srv/net/structures/packet/packet_server.c
rbfd7aac r1e2e0c1e 229 229 void packet_release( packet_t packet ){ 230 230 int index; 231 int result; 231 232 232 233 // remove debug dump 233 234 // printf( "packet %d released\n", packet->packet_id ); 234 235 for( index = 0; ( index < FREE_QUEUES_COUNT - 1 ) && ( packet->length > ps_globals.sizes[ index ] ); ++ index ); 235 ps_globals.free[ index ] = pq_add(ps_globals.free[ index ], packet, packet->length, packet->length );236 assert( ps_globals.free[ index ]);236 result = pq_add( & ps_globals.free[ index ], packet, packet->length, packet->length ); 237 assert( result == EOK ); 237 238 } 238 239
Note:
See TracChangeset
for help on using the changeset viewer.