Changeset cb569e6 in mainline for uspace/lib/net/tl/socket_core.c


Ignore:
Timestamp:
2010-11-18T21:58:27Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e5c7ba
Parents:
69e0d6d (diff), 45f04f8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/tl/socket_core.c

    r69e0d6d rcb569e6  
    4848#include <stdlib.h>
    4949#include <errno.h>
    50 #include <err.h>
    5150
    5251#include <adt/dynamic_fifo.h>
     
    164163    const char *key, size_t key_length)
    165164{
    166         ERROR_DECLARE;
    167 
    168165        socket_core_ref *socket_ref;
     166        int rc;
    169167
    170168        // create a wrapper
     
    175173        *socket_ref = socket;
    176174        // add the wrapper
    177         if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key,
    178             key_length, socket_ref))) {
     175        rc = socket_port_map_add(&socket_port->map, key, key_length,
     176            socket_ref);
     177        if (rc != EOK) {
    179178                free(socket_ref);
    180                 return ERROR_CODE;
     179                return rc;
    181180        }
    182181       
     
    204203    int port)
    205204{
    206         ERROR_DECLARE;
    207 
    208205        socket_port_ref socket_port;
     206        int rc;
    209207
    210208        // create a wrapper
     
    214212
    215213        socket_port->count = 0;
    216         if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) ||
    217             ERROR_OCCURRED(socket_port_add_core(socket_port, socket,
    218             SOCKET_MAP_KEY_LISTENING, 0))) {
    219                 socket_port_map_destroy(&socket_port->map);
    220                 free(socket_port);
    221                 return ERROR_CODE;
    222         }
     214        rc = socket_port_map_initialize(&socket_port->map);
     215        if (rc != EOK)
     216                goto fail;
     217       
     218        rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
     219            0);
     220        if (rc != EOK)
     221                goto fail;
    223222       
    224223        // register the incomming port
    225         ERROR_CODE = socket_ports_add(global_sockets, port, socket_port);
    226         if (ERROR_CODE < 0) {
    227                 socket_port_map_destroy(&socket_port->map);
    228                 free(socket_port);
    229                 return ERROR_CODE;
    230         }
     224        rc = socket_ports_add(global_sockets, port, socket_port);
     225        if (rc < 0)
     226                goto fail;
    231227       
    232228        socket->port = port;
    233229        return EOK;
     230
     231fail:
     232        socket_port_map_destroy(&socket_port->map);
     233        free(socket_port);
     234        return rc;
     235       
    234236}
    235237
     
    416418    void *specific_data, int *socket_id)
    417419{
    418         ERROR_DECLARE;
    419 
    420420        socket_core_ref socket;
    421         int res;
    422421        int positive;
     422        int rc;
    423423
    424424        if (!socket_id)
     
    447447        socket->key_length = 0;
    448448        socket->specific_data = specific_data;
    449         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,
    450             SOCKET_INITIAL_RECEIVED_SIZE))) {
     449        rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     450        if (rc != EOK) {
    451451                free(socket);
    452                 return ERROR_CODE;
    453         }
    454         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted,
    455             SOCKET_INITIAL_ACCEPTED_SIZE))) {
     452                return rc;
     453        }
     454       
     455        rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
     456        if (rc != EOK) {
    456457                dyn_fifo_destroy(&socket->received);
    457458                free(socket);
    458                 return ERROR_CODE;
     459                return rc;
    459460        }
    460461        socket->socket_id = *socket_id;
    461         res = socket_cores_add(local_sockets, socket->socket_id, socket);
    462         if (res < 0) {
     462        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
     463        if (rc < 0) {
    463464                dyn_fifo_destroy(&socket->received);
    464465                dyn_fifo_destroy(&socket->accepted);
    465466                free(socket);
    466                 return res;
     467                return rc;
    467468        }
    468469       
     
    523524int socket_reply_packets(packet_t packet, size_t *length)
    524525{
    525         ERROR_DECLARE;
    526 
    527526        packet_t next_packet;
    528527        size_t fragments;
    529528        size_t *lengths;
    530529        size_t index;
     530        int rc;
    531531
    532532        if (!length)
     
    536536        if (!next_packet) {
    537537                // write all if only one fragment
    538                 ERROR_PROPAGATE(data_reply(packet_get_data(packet),
    539                     packet_get_data_length(packet)));
     538                rc = data_reply(packet_get_data(packet),
     539                    packet_get_data_length(packet));
     540                if (rc != EOK)
     541                        return rc;
    540542                // store the total length
    541543                *length = packet_get_data_length(packet);
     
    564566               
    565567                // write the fragment lengths
    566                 if (ERROR_OCCURRED(data_reply(lengths,
    567                     sizeof(int) * (fragments + 1)))) {
     568                rc = data_reply(lengths, sizeof(int) * (fragments + 1));
     569                if (rc != EOK) {
    568570                        free(lengths);
    569                         return ERROR_CODE;
     571                        return rc;
    570572                }
    571573                next_packet = packet;
     
    573575                // write the fragments
    574576                for (index = 0; index < fragments; ++index) {
    575                         ERROR_CODE = data_reply(packet_get_data(next_packet),
     577                        rc = data_reply(packet_get_data(next_packet),
    576578                            lengths[index]);
    577                         if (ERROR_OCCURRED(ERROR_CODE)) {
     579                        if (rc != EOK) {
    578580                                free(lengths);
    579                                 return ERROR_CODE;
     581                                return rc;
    580582                        }
    581583                        next_packet = pq_next(next_packet);
     
    680682    socket_core_ref socket, const char *key, size_t key_length)
    681683{
    682         ERROR_DECLARE;
    683 
    684684        socket_port_ref socket_port;
     685        int rc;
    685686
    686687        // find ports
     
    690691       
    691692        // add the socket
    692         ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key,
    693             key_length));
     693        rc = socket_port_add_core(socket_port, socket, key, key_length);
     694        if (rc != EOK)
     695                return rc;
    694696       
    695697        socket->port = port;
Note: See TracChangeset for help on using the changeset viewer.