Navigation


Changeset 895:fbf77629cb7b in freeDiameter for libfdcore


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

Added received and sent timestamps in the messages; added logs on emission and reception

Location:
libfdcore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/p_out.c

    r740 r895  
    4545        int ret;
    4646        uint32_t bkp_hbh = 0;
     47        struct timespec senton;
     48        struct msg * cpy_for_logs_only;
    4749       
    4850        TRACE_ENTRY("%p %x %p %p %p", msg, flags, cnx, hbh, srl);
     
    6466        pthread_cleanup_push( free, buf );
    6567       
    66         /* Log the message */
    67         fd_msg_log( FD_MSG_LOG_SENT, *msg, "Sent to '%s'", fd_cnx_getid(cnx));
     68        cpy_for_logs_only = *msg;
    6869       
    6970        /* Save a request before sending so that there is no race condition with the answer */
    7071        if (msg_is_a_req) {
    7172                CHECK_FCT_DO( ret = fd_p_sr_store(srl, msg, &hdr->msg_hbhid, bkp_hbh), goto out );
     73        }
     74       
     75        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &senton), /* ... */ );
     76        CHECK_FCT_DO( fd_msg_ts_set_sent(cpy_for_logs_only, &senton), /* ... */ );
     77       
     78        /* Log the message */
     79        fd_msg_log( FD_MSG_LOG_SENT, cpy_for_logs_only, "Sent to '%s'", fd_cnx_getid(cnx));
     80       
     81        {
     82                struct timespec rcvon, delay;
     83               
     84                (void) fd_msg_ts_get_recv(cpy_for_logs_only, &rcvon);
     85                if (rcvon.tv_sec != 0 || rcvon.tv_nsec != 0) {
     86                        TS_DIFFERENCE( &delay, &rcvon, &senton);
     87                        fd_msg_log( FD_MSG_LOG_TIMING, cpy_for_logs_only, "Forwarded in %d.%06.6d sec", delay.tv_sec, delay.tv_nsec/1000);
     88                } else { /* We log the answer time only for answers generated locally */
     89                        if (!msg_is_a_req) {
     90                                /* get the matching request */
     91                                struct msg * req;
     92                                struct timespec reqrcvon;
     93                                (void) fd_msg_answ_getq(cpy_for_logs_only, &req);
     94                                (void) fd_msg_ts_get_recv(req, &reqrcvon);
     95                                TS_DIFFERENCE( &delay, &reqrcvon, &senton);
     96                                fd_msg_log( FD_MSG_LOG_TIMING, cpy_for_logs_only, "Answered in %d.%06.6d sec", delay.tv_sec, delay.tv_nsec/1000);
     97                        }
     98                }
    7299        }
    73100       
  • libfdcore/p_psm.c

    r767 r895  
    478478                struct msg * msg = NULL;
    479479                struct msg_hdr * hdr;
     480                struct timespec rcvon;
     481               
     482                /* Retrieve the piggytailed timestamp */
     483                memcpy(&rcvon, ev_data+ev_sz, sizeof(struct timespec));
    480484               
    481485                /* Parse the received buffer */
     
    487491                                goto psm_loop;
    488492                        } );
     493                       
     494                CHECK_FCT_DO( fd_msg_ts_set_recv(msg, &rcvon), /* ... */ );
    489495               
    490496                /* If the current state does not allow receiving messages, just drop it */
     
    515521                        /* Associate */
    516522                        CHECK_FCT_DO( fd_msg_answ_associate( msg, req ), goto psm_end );
     523                       
     524                        /* Display the delay to receive the answer */
     525                        {
     526                                struct timespec reqsent, delay;
     527                                (void) fd_msg_ts_get_sent(req, &reqsent);
     528                                TS_DIFFERENCE( &delay, &reqsent, &rcvon );
     529                                fd_msg_log( FD_MSG_LOG_TIMING, msg, "Answer received in %d.%06.6d sec.", delay.tv_sec, delay.tv_nsec / 1000 );
     530                        }
    517531                }
    518532               
Note: See TracChangeset for help on using the changeset viewer.