Navigation


Changeset 1199:2c62bba0ef4b in freeDiameter for extensions


Ignore:
Timestamp:
Jun 14, 2013, 11:13:22 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Add some hooks in test_app in becnhmark mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_app/test_app.c

    r1198 r1199  
    4444static struct ta_conf _conf;
    4545static pthread_t ta_stats_th = (pthread_t)NULL;
    46 static struct fd_hook_hdl * hookhdl = NULL;
    4746
    4847static int ta_conf_init(void)
     
    137136}
    138137
    139 static void ta_hook_cb(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) {
    140 
     138static struct fd_hook_hdl * hookhdl[2] = { NULL, NULL };
     139static void ta_hook_cb_silent(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) {
     140}
     141static void ta_hook_cb_oneline(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) {
     142        char * buf = NULL;
     143        size_t len;
     144       
     145        CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 0),
     146                { LOG_E("Error while dumping a message"); return; } );
     147       
     148        LOG_N("{%d} %s: %s", type, (char *)other ?:"<nil>", buf ?:"<nil>");
     149
     150        free(buf);
    141151}
    142152
     
    180190        if (ta_conf->mode & MODE_BENCH) {
    181191                /* Register an empty hook to disable the default handling */
    182                 CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_DATA_RECEIVED, HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_SENT, HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL ),
    183                                         ta_hook_cb, NULL, NULL, &hookhdl) );
     192                CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_DATA_RECEIVED, HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_SENT, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL ),
     193                                        ta_hook_cb_silent, NULL, NULL, &hookhdl[0]) );
     194                CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED ),
     195                                        ta_hook_cb_oneline, NULL, NULL, &hookhdl[1]) );
    184196               
    185197        }
     
    198210        if (ta_conf->mode & MODE_SERV)
    199211                ta_serv_fini();
    200         if (hookhdl)
    201                 fd_hook_unregister( hookhdl );
     212        if (hookhdl[0])
     213                fd_hook_unregister( hookhdl[0] );
     214        if (hookhdl[1])
     215                fd_hook_unregister( hookhdl[1] );
    202216        CHECK_FCT_DO( fd_thr_term(&ta_stats_th), );
    203217        CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
Note: See TracChangeset for help on using the changeset viewer.