diff --git a/infra/monitor/monitor_private.h b/infra/monitor/monitor_private.h index f366d06..b6a0f37 100644 --- a/infra/monitor/monitor_private.h +++ b/infra/monitor/monitor_private.h @@ -243,7 +243,6 @@ extern "C" struct timeval time_now; struct stm_stat *stat; struct stm_spinlock *lock; // for dynamic register command, conn_close_cb - int (*gettime_cb)(struct timeval *tv, void *tz); struct monitor_connection current_conn; struct stm_pktdump_runtime *packet_dump; @@ -282,7 +281,6 @@ extern "C" /************************************************************************************************************/ /* monitor call gettimeofday(2) by default */ struct stellar_monitor_config *stellar_monitor_config_new(const char *toml); - int stellar_monitor_set_gettime_callback(struct stellar_monitor *stm, int (*gettime_cb)(struct timeval *tv, void *tz)); struct stellar_monitor *stellar_monitor_get(void); struct stm_connection_manager *stm_connection_insert(struct evhttp_connection *evconn); void stm_connection_update(struct stm_connection_manager *conn_mgr, const struct evhttp_connection *evconn); diff --git a/infra/monitor/monitor_server.c b/infra/monitor/monitor_server.c index cd617d3..d2b187a 100644 --- a/infra/monitor/monitor_server.c +++ b/infra/monitor/monitor_server.c @@ -194,16 +194,6 @@ static void stm_server_set_default_cfg(struct stellar_monitor_config *config) config->output_interval_ms = STM_STAT_OUTPUT_INTERVAL_MS; } -int stellar_monitor_set_gettime_callback(struct stellar_monitor *stm, int (*gettime_cb)(struct timeval *tv, void *tz)) -{ - if (NULL == gettime_cb) - { - return -1; - } - stm->gettime_cb = gettime_cb; - return 0; -} - struct stellar_monitor_config *stellar_monitor_config_new(const char *toml_file) { struct stellar_monitor_config *config = CALLOC(struct stellar_monitor_config, 1); @@ -532,7 +522,6 @@ struct stellar_monitor *monitor_new(const char *toml_file, struct module_manager stm->lock = stm_spinlock_new(); stm->worker_thread_num = module_manager_get_max_thread_num(mod_mgr); assert(stm->worker_thread_num > 0); - stm->gettime_cb = gettimeofday; stm->aide = stm_cmd_assistant_new(); if (stm_event_http_init(stm) < 0) { diff --git a/infra/monitor/monitor_transaction.c b/infra/monitor/monitor_transaction.c index 0f9aba8..312361f 100644 --- a/infra/monitor/monitor_transaction.c +++ b/infra/monitor/monitor_transaction.c @@ -18,7 +18,7 @@ struct stm_connection_manager *stm_connection_insert(struct evhttp_connection *e { if (ele->conn == evconn) { - stm->gettime_cb(&ele->last_active_time, NULL); + gettimeofday(&ele->last_active_time, NULL); return ele; } } @@ -33,7 +33,7 @@ struct stm_connection_manager *stm_connection_insert(struct evhttp_connection *e strncpy(new_conn->peer_ipaddr, tmp_ip_addr, INET6_ADDRSTRLEN - 1); } new_conn->peer_port_host_order = tmp_port; - stm->gettime_cb(&new_conn->link_start_time, NULL); + gettimeofday(&new_conn->link_start_time, NULL); new_conn->last_active_time = new_conn->link_start_time; new_conn->conn = evconn; DL_APPEND(stm->connection_mgr, new_conn); @@ -58,13 +58,12 @@ void stm_connection_delete(struct evhttp_connection *evconn) void stm_connection_update(struct stm_connection_manager *conn_mgr, const struct evhttp_connection *evconn) { - struct stellar_monitor *stm = stellar_monitor_get(); struct stm_connection_manager *ele, *tmp; DL_FOREACH_SAFE(conn_mgr, ele, tmp) { if (ele->conn == evconn) { - stm->gettime_cb(&ele->last_active_time, NULL); + gettimeofday(&ele->last_active_time, NULL); } } }