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


Ignore:
Timestamp:
2012-07-14T11:18:40Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
804d9b6
Parents:
0747468 (diff), f0348c8 (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.

Text conflict in boot/arch/arm32/Makefile.inc:

Trivial conflict around ifeq condition.

Text conflict in kernel/arch/arm32/include/mm/page.h:

Added defines and set_pt_levelx_present function.
COnflict looked horrible because of the armv4/v7 split.

File:
1 edited

Legend:

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

    r0747468 r97c7682  
    3636
    3737#include <socket_core.h>
    38 #include <packet_client.h>
    39 #include <packet_remote.h>
    4038#include <net/socket_codes.h>
    4139#include <net/in.h>
    4240#include <net/inet.h>
    43 #include <net/packet.h>
    44 #include <net/modules.h>
    4541#include <stdint.h>
    4642#include <stdlib.h>
     
    9288        }
    9389       
    94         /* Release all received packets */
    95         int packet_id;
    96         while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
    97                 pq_release_remote(sess, packet_id);
    98        
    99         dyn_fifo_destroy(&socket->received);
    10090        dyn_fifo_destroy(&socket->accepted);
    10191       
     
    448438        socket->key_length = 0;
    449439        socket->specific_data = specific_data;
    450         rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     440       
     441        rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
    451442        if (rc != EOK) {
    452443                free(socket);
    453444                return rc;
    454445        }
    455        
    456         rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
    457         if (rc != EOK) {
    458                 dyn_fifo_destroy(&socket->received);
    459                 free(socket);
    460                 return rc;
    461         }
    462446        socket->socket_id = *socket_id;
    463447        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
    464448        if (rc < 0) {
    465                 dyn_fifo_destroy(&socket->received);
    466449                dyn_fifo_destroy(&socket->accepted);
    467450                free(socket);
     
    506489        socket_destroy_core(sess, socket, local_sockets, global_sockets,
    507490            socket_release);
    508        
    509         return EOK;
    510 }
    511 
    512 /** Replies the packet or the packet queue data to the application via the
    513  * socket.
    514  *
    515  * Uses the current message processing fibril.
    516  *
    517  * @param[in] packet    The packet to be transfered.
    518  * @param[out] length   The total data length.
    519  * @return              EOK on success.
    520  * @return              EBADMEM if the length parameter is NULL.
    521  * @return              ENOMEM if there is not enough memory left.
    522  * @return              Other error codes as defined for the data_reply()
    523  *                      function.
    524  */
    525 int socket_reply_packets(packet_t *packet, size_t *length)
    526 {
    527         packet_t *next_packet;
    528         size_t fragments;
    529         size_t *lengths;
    530         size_t index;
    531         int rc;
    532 
    533         if (!length)
    534                 return EBADMEM;
    535 
    536         next_packet = pq_next(packet);
    537         if (!next_packet) {
    538                 /* Write all if only one fragment */
    539                 rc = data_reply(packet_get_data(packet),
    540                     packet_get_data_length(packet));
    541                 if (rc != EOK)
    542                         return rc;
    543                 /* Store the total length */
    544                 *length = packet_get_data_length(packet);
    545         } else {
    546                 /* Count the packet fragments */
    547                 fragments = 1;
    548                 next_packet = pq_next(packet);
    549                 while ((next_packet = pq_next(next_packet)))
    550                         ++fragments;
    551                
    552                 /* Compute and store the fragment lengths */
    553                 lengths = (size_t *) malloc(sizeof(size_t) * fragments +
    554                     sizeof(size_t));
    555                 if (!lengths)
    556                         return ENOMEM;
    557                
    558                 lengths[0] = packet_get_data_length(packet);
    559                 lengths[fragments] = lengths[0];
    560                 next_packet = pq_next(packet);
    561                
    562                 for (index = 1; index < fragments; ++index) {
    563                         lengths[index] = packet_get_data_length(next_packet);
    564                         lengths[fragments] += lengths[index];
    565                         next_packet = pq_next(packet);
    566                 }
    567                
    568                 /* Write the fragment lengths */
    569                 rc = data_reply(lengths, sizeof(int) * (fragments + 1));
    570                 if (rc != EOK) {
    571                         free(lengths);
    572                         return rc;
    573                 }
    574                 next_packet = packet;
    575                
    576                 /* Write the fragments */
    577                 for (index = 0; index < fragments; ++index) {
    578                         rc = data_reply(packet_get_data(next_packet),
    579                             lengths[index]);
    580                         if (rc != EOK) {
    581                                 free(lengths);
    582                                 return rc;
    583                         }
    584                         next_packet = pq_next(next_packet);
    585                 }
    586                
    587                 /* Store the total length */
    588                 *length = lengths[fragments];
    589                 free(lengths);
    590         }
    591491       
    592492        return EOK;
Note: See TracChangeset for help on using the changeset viewer.