Changeset 1e2e0c1e in mainline


Ignore:
Timestamp:
2010-02-17T21:15:03Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6b7b198
Parents:
bfd7aac
Message:
  • change in the pq_add interface
Location:
uspace/srv/net
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/netif/dp8390/dp8390.c

    rbfd7aac r1e2e0c1e  
    350350                tmp = pq_next( tmp );
    351351        }
    352         if( ! pq_add( tmp, packet, 0, 0 )){
     352        if( pq_add( & tmp, packet, 0, 0 ) != EOK ){
    353353                return EINVAL;
    354354        }
     
    10061006        int last, count;
    10071007        packet_t        packet;
    1008         packet_t        queue;
    10091008
    10101009//      if (!(dep->de_flags & DEF_READING))
     
    10451044                return ELIMIT;
    10461045        }else{
    1047                 queue = pq_add( dep->received_queue, packet, 0, 0 );
    1048                 if( queue ){
    1049                         dep->received_queue = queue;
     1046                if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK ){
    10501047                        ++ dep->received_count;
    10511048                }else{
  • uspace/srv/net/structures/packet/packet.c

    rbfd7aac r1e2e0c1e  
    184184}
    185185
    186 packet_t pq_add( packet_t first, packet_t packet, size_t order, size_t metric ){
     186int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ){
    187187        packet_t        item;
    188188
    189         if( ! packet_is_valid( packet )) return NULL;
     189        if(( ! first ) || ( ! packet_is_valid( packet ))) return EINVAL;
    190190        pq_set_order( packet, order, metric );
    191         if( packet_is_valid( first )){
    192                 item = first;
     191        if( packet_is_valid( * first )){
     192                item = * first;
    193193                do{
    194194                        if( item->order < order ){
     
    198198                                        item->next = packet->packet_id;
    199199                                        packet->previous = item->packet_id;
    200                                         return first;
     200                                        return EOK;
    201201                                }
    202202                        }else{
     
    205205                                item->previous = packet->packet_id;
    206206                                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;
    209213                        }
    210214                }while( packet_is_valid( item ));
    211215        }
    212         return packet;
     216        * first = packet;
     217        return EOK;
    213218}
    214219
  • uspace/srv/net/structures/packet/packet.h

    rbfd7aac r1e2e0c1e  
    8686 *  The queue is sorted in the ascending order.
    8787 *  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.
    8989 *  @param[in] packet The packet to be added.
    9090 *  @param[in] order The packet order value.
    9191 *  @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.
    9495 */
    95 packet_t        pq_add( packet_t first, packet_t packet, size_t order, size_t metric );
     96int     pq_add( packet_t * first, packet_t packet, size_t order, size_t metric );
    9697
    9798/** Finds the packet with the given order.
  • uspace/srv/net/structures/packet/packet_server.c

    rbfd7aac r1e2e0c1e  
    229229void packet_release( packet_t packet ){
    230230        int index;
     231        int result;
    231232
    232233        // remove debug dump
    233234//      printf( "packet %d released\n", packet->packet_id );
    234235        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 );
    237238}
    238239
  • uspace/srv/net/tl/tcp/tcp.c

    rbfd7aac r1e2e0c1e  
    613613                next_packet = pq_detach( packet );
    614614                length = packet_get_data_length( packet );
    615                 tmp_packet = pq_add( socket_data->incoming, packet, new_sequence_number, length );
    616                 if( ! tmp_packet ){
     615                if( ERROR_OCCURRED( pq_add( & socket_data->incoming, packet, new_sequence_number, length ))){
    617616                        // remove the corrupted packets
    618617                        pq_release( tcp_globals.net_phone, packet_get_id( packet ));
    619618                        pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
    620619                }else{
    621                         socket_data->incoming = tmp_packet;
    622620                        while( next_packet ){
    623621                                new_sequence_number += length;
     
    939937        packet_t        next;
    940938        packet_t        acknowledged = NULL;
    941         packet_t        first;
    942939        uint32_t        old;
    943940
     
    981978                                        }
    982979                                        // add to acknowledged or release
    983                                         first = pq_add( acknowledged, packet, 0, 0 );
    984                                         if( first ){
    985                                                 acknowledged = first;
    986                                         }else{
     980                                        if( pq_add( & acknowledged, packet, 0, 0 ) != EOK ){
    987981                                                pq_release( tcp_globals.net_phone, packet_get_id( packet ));
    988982                                        }
     
    15081502int     tcp_queue_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length ){
    15091503        ERROR_DECLARE;
    1510         packet_t                first;
    15111504
    15121505        assert( socket );
     
    15161509        ERROR_PROPAGATE( tcp_queue_prepare_packet( socket, socket_data, packet, data_length ));
    15171510
    1518         first = pq_add( socket_data->outgoing, packet, socket_data->next_outgoing, data_length );
    1519         if( ! first ){
    1520                 return tcp_release_and_return( packet, EINVAL );
    1521         }
    1522         socket_data->outgoing = first;
     1511        if( ERROR_OCCURRED( pq_add( & socket_data->outgoing, packet, socket_data->next_outgoing, data_length ))){
     1512                return tcp_release_and_return( packet, ERROR_CODE );
     1513        }
    15231514        socket_data->next_outgoing += data_length;
    15241515        return EOK;
  • uspace/srv/net/tl/udp/udp.c

    rbfd7aac r1e2e0c1e  
    604604                        return udp_release_and_return( packet, result );
    605605                }
    606                 packet = pq_add( packet, next_packet, index, 0 );
     606                if( ERROR_OCCURRED( pq_add( & packet, next_packet, index, 0 ))){
     607                        return udp_release_and_return( packet, ERROR_CODE );
     608                }
    607609                total_length += ( size_t ) result;
    608610                if( udp_globals.checksum_computing ){
Note: See TracChangeset for help on using the changeset viewer.