Changeset a63ff7d in mainline


Ignore:
Timestamp:
2010-11-04T22:59:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60898b6
Parents:
de229f8e
Message:

Do not leak the packet on error in udp_recvfrom_message().

If we don't make it to copying the user data to the client application, do not
forget to release the packet so that it can be used for something else. Also,
pop the packet ID from the socket received queue immediately or else the queue
would become inconsitent on error.

Another approach could be to keep the packet ID in the socket received queue
until the data is successfully copied to the client (just as it was done until
now) and not release the packet in case of error (just as it was done until now,
but for all cases).

The second approach could work better for transient errors as packets would not
be dropped needlessly, but for permanent errors this would render the client
unable to receive any further data.

Rather than complicate the matter, we behave conservatively and drop the packet
whenever we can't deliver it to the client.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/udp/udp.c

    rde229f8e ra63ff7d  
    626626
    627627        // get the next received packet
    628         packet_id = dyn_fifo_value(&socket->received);
     628        packet_id = dyn_fifo_pop(&socket->received);
    629629        if (packet_id < 0)
    630630                return NO_DATA;
     
    650650        rc = data_reply(addr, *addrlen);
    651651        if (rc != EOK)
    652                 return rc;
     652                return udp_release_and_return(packet, rc);
    653653
    654654        // trim the header
    655655        rc = packet_trim(packet, UDP_HEADER_SIZE, 0);
    656656        if (rc != EOK)
    657                 return rc;
     657                return udp_release_and_return(packet, rc);
    658658
    659659        // reply the packets
    660660        rc = socket_reply_packets(packet, &length);
    661661        if (rc != EOK)
    662                 return rc;
    663 
    664         dyn_fifo_pop(&socket->received);
     662                return udp_release_and_return(packet, rc);
    665663
    666664        // release the packet and return the total length
Note: See TracChangeset for help on using the changeset viewer.