Navigation


Changeset 894:43fb27a9037f in freeDiameter for libfdcore/cnxctx.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/cnxctx.c

    r816 r894  
    641641        }
    642642       
     643        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &conn->cc_tls_para.recvon), /* continue */ );
     644       
    643645        return ret;
    644646}
     
    696698                ssize_t ret = 0;
    697699                size_t  received = 0;
     700                struct timespec recv_on;
    698701
    699702                do {
     
    718721
    719722                /* Ok, now we can really receive the data */
    720                 CHECK_MALLOC_DO(  newmsg = malloc( length ), goto fatal );
     723                CHECK_MALLOC_DO(  newmsg = malloc( length + sizeof(struct timespec) ), goto fatal );
    721724                memcpy(newmsg, header, sizeof(header));
    722725
     
    732735                        received += ret;
    733736                }
     737               
     738                /* Piggy-tail the timestamp of reception */
     739                CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &recv_on), /* continue */ );
     740                memcpy(newmsg + length, &recv_on, sizeof(struct timespec));
    734741               
    735742                /* We have received a complete message, pass it to the daemon */
     
    782789                        continue;
    783790                }
    784                
     791                /* Note: the real size of buf is bufsz + struct timespec */
    785792                CHECK_FCT_DO( fd_event_send( fd_cnx_target_queue(conn), event, bufsz, buf), goto fatal );
    786793               
     
    920927int fd_tls_rcvthr_core(struct cnxctx * conn, gnutls_session_t session)
    921928{
     929        struct timespec * rcv_on;
     930       
     931        void * ptr = gnutls_transport_get_ptr(session);
     932        if (ptr == conn) {
     933                rcv_on = &conn->cc_tls_para.recvon;
     934        } else {
     935                struct sctps_ctx * ctx = (struct sctps_ctx *) ptr;
     936                rcv_on = &ctx->recvon;
     937        }
     938       
     939       
    922940        /* No guarantee that GnuTLS preserves the message boundaries, so we re-build it as in TCP */
    923941        do {
     
    927945                ssize_t ret = 0;
    928946                size_t  received = 0;
     947                struct timespec recv_on;
    929948
    930949                do {
     
    949968
    950969                /* Ok, now we can really receive the data */
    951                 CHECK_MALLOC(  newmsg = malloc( length ) );
     970                CHECK_MALLOC(  newmsg = malloc( length + sizeof(struct timespec)) );
    952971                memcpy(newmsg, header, sizeof(header));
    953972
     
    963982                        received += ret;
    964983                }
     984               
     985                /* The timestamp of the last TLS chunk received for this rebuilt message lives close to the session pointer, we piggyback it */
     986                memcpy(newmsg + length, rcv_on, sizeof(struct timespec));
    965987               
    966988                /* We have received a complete message, pass it to the daemon */
Note: See TracChangeset for help on using the changeset viewer.