Navigation


Changeset 1195:16f2d2f15e5b in freeDiameter for extensions/test_app/test_app.c


Ignore:
Timestamp:
Jun 11, 2013, 3:05:33 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Allow better usage in benchmark mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_app/test_app.c

    r1127 r1195  
    4444static struct ta_conf _conf;
    4545static pthread_t ta_stats_th = (pthread_t)NULL;
     46static struct fd_hook_hdl * hookhdl = NULL;
    4647
    4748static int ta_conf_init(void)
     
    9697        while (1) {
    9798                /* Display statistics every XX seconds */
    98                 sleep(ta_conf->bench_duration * 3);
     99                sleep(ta_conf->bench_duration + 3);
    99100               
    100101                /* Now, get the current stats */
     
    136137}
    137138
     139static 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
     141}
     142
     143
    138144/* entry point */
    139145static int ta_entry(char * conffile)
     
    172178        CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) );
    173179       
     180        if (ta_conf->mode & MODE_BENCH) {
     181                /* Register an empty hook to disable the default handling */
     182                CHECK_FCT( fd_hook_register( (1<<HOOK_LAST) - 1,
     183                                        ta_hook_cb, NULL, NULL, &hookhdl) );
     184               
     185        }
     186       
    174187        /* Start the statistics thread */
    175188        CHECK_POSIX( pthread_create(&ta_stats_th, NULL, ta_stats, NULL) );
     
    185198        if (ta_conf->mode & MODE_SERV)
    186199                ta_serv_fini();
     200        if (hookhdl)
     201                fd_hook_unregister( hookhdl );
    187202        CHECK_FCT_DO( fd_thr_term(&ta_stats_th), );
    188203        CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
Note: See TracChangeset for help on using the changeset viewer.