Navigation


Changeset 894:43fb27a9037f in freeDiameter for libfdcore/sctp.c


Ignore:
Timestamp:
Nov 30, 2012, 6:51:49 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Intrumented socket reception to store the timestamp along the received buffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/sctp.c

    r817 r894  
    10681068        size_t                   mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */
    10691069        int                      timedout = 0;
     1070        struct timespec          recv_on;
    10701071       
    10711072        TRACE_ENTRY("%p %p %p %p %p", conn, strid, buf, len, event);
     
    10861087        /* We will loop while all data is not received. */
    10871088incomplete:
    1088         if (datasize == bufsz) {
     1089        if (datasize == bufsz - sizeof(struct timespec)) {
    10891090                /* The buffer is full, enlarge it */
    10901091                bufsz += mempagesz;
    1091                 CHECK_MALLOC( data = realloc(data, bufsz) );
     1092                CHECK_MALLOC( data = realloc(data, bufsz ) );
    10921093        }
    10931094        /* the new data will be received following the preceding */
    10941095        memset(&iov,  0, sizeof(iov));
    10951096        iov.iov_base = data + datasize ;
    1096         iov.iov_len  = bufsz - datasize;
     1097        iov.iov_len  = bufsz - sizeof(struct timespec) - datasize;
    10971098
    10981099        /* Receive data from the socket */
     
    11881189        }
    11891190       
     1191        /* Piggy-tail the timestamp of reception */
     1192        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &recv_on), /* continue */ );
     1193        memcpy(data + datasize, &recv_on, sizeof(struct timespec));
     1194               
    11901195        /* From this point, we have received a message */
    11911196        *event = FDEVP_CNX_MSG_RECV;
Note: See TracChangeset for help on using the changeset viewer.