Enable the statistics timer again, so that !stats provide up to date network statistics.
This commit is contained in:
parent
c670d13369
commit
304ecda16a
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
#define USERMANAGER_TIMER
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This callback function is used to clear user objects from the userlist.
|
* This callback function is used to clear user objects from the userlist.
|
||||||
* Should only be used in uman_shutdown().
|
* Should only be used in uman_shutdown().
|
||||||
@ -40,7 +38,6 @@ static void clear_user_list_callback(void* ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uman_update_stats(struct hub_info* hub)
|
void uman_update_stats(struct hub_info* hub)
|
||||||
{
|
{
|
||||||
const int factor = TIMEOUT_STATS;
|
const int factor = TIMEOUT_STATS;
|
||||||
@ -58,7 +55,6 @@ void uman_update_stats(struct hub_info* hub)
|
|||||||
net_stats_reset();
|
net_stats_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uman_print_stats(struct hub_info* hub)
|
void uman_print_stats(struct hub_info* hub)
|
||||||
{
|
{
|
||||||
LOG_INFO("Statistics users=" PRINTF_SIZE_T " (peak_users=" PRINTF_SIZE_T "), net_tx=%d KB/s, net_rx=%d KB/s (peak_tx=%d KB/s, peak_rx=%d KB/s)",
|
LOG_INFO("Statistics users=" PRINTF_SIZE_T " (peak_users=" PRINTF_SIZE_T "), net_tx=%d KB/s, net_rx=%d KB/s (peak_tx=%d KB/s, peak_rx=%d KB/s)",
|
||||||
@ -70,6 +66,13 @@ void uman_print_stats(struct hub_info* hub)
|
|||||||
(int) hub->stats.net_rx_peak / 1024);
|
(int) hub->stats.net_rx_peak / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void timer_statistics(struct timeout_evt* t)
|
||||||
|
{
|
||||||
|
struct hub_info* hub = (struct hub_info*) t->ptr;
|
||||||
|
uman_update_stats(hub);
|
||||||
|
timeout_queue_reschedule(net_backend_get_timeout_queue(), hub->users->timeout, TIMEOUT_STATS);
|
||||||
|
}
|
||||||
|
|
||||||
int uman_init(struct hub_info* hub)
|
int uman_init(struct hub_info* hub)
|
||||||
{
|
{
|
||||||
struct hub_user_manager* users = NULL;
|
struct hub_user_manager* users = NULL;
|
||||||
@ -90,6 +93,10 @@ int uman_init(struct hub_info* hub)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users->timeout = hub_malloc_zero(sizeof(struct timeout_evt));
|
||||||
|
timeout_evt_initialize(users->timeout, timer_statistics, hub);
|
||||||
|
timeout_queue_insert(net_backend_get_timeout_queue(), users->timeout, TIMEOUT_STATS);
|
||||||
|
|
||||||
hub->users = users;
|
hub->users = users;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -100,6 +107,9 @@ int uman_shutdown(struct hub_info* hub)
|
|||||||
if (!hub || !hub->users)
|
if (!hub || !hub->users)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
timeout_queue_remove(net_backend_get_timeout_queue(), hub->users->timeout);
|
||||||
|
hub_free(hub->users->timeout);
|
||||||
|
|
||||||
if (hub->users->list)
|
if (hub->users->list)
|
||||||
{
|
{
|
||||||
list_clear(hub->users->list, &clear_user_list_callback);
|
list_clear(hub->users->list, &clear_user_list_callback);
|
||||||
@ -108,6 +118,8 @@ int uman_shutdown(struct hub_info* hub)
|
|||||||
sid_pool_destroy(hub->users->sids);
|
sid_pool_destroy(hub->users->sids);
|
||||||
hub_free(hub->users);
|
hub_free(hub->users);
|
||||||
hub->users = 0;
|
hub->users = 0;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ struct hub_user_manager
|
|||||||
uint64_t shared_size; /**<< "The total number of shared bytes among fully connected users." */
|
uint64_t shared_size; /**<< "The total number of shared bytes among fully connected users." */
|
||||||
uint64_t shared_files; /**<< "The total number of shared files among fully connected users." */
|
uint64_t shared_files; /**<< "The total number of shared files among fully connected users." */
|
||||||
struct linked_list* list; /**<< "Contains all logged in users" */
|
struct linked_list* list; /**<< "Contains all logged in users" */
|
||||||
|
struct timeout_evt* timeout; /**<< "Timeout handler for statistics" */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,15 +110,16 @@ int net_backend_process()
|
|||||||
size_t secs = timeout_queue_get_next_timeout(&g_backend->timeout_queue, g_backend->now);
|
size_t secs = timeout_queue_get_next_timeout(&g_backend->timeout_queue, g_backend->now);
|
||||||
LOG_TRACE("epoll_wait: fd=%d, events=%x, max=%zu, seconds=%d", g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), (int) secs);
|
LOG_TRACE("epoll_wait: fd=%d, events=%x, max=%zu, seconds=%d", g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), (int) secs);
|
||||||
int res = epoll_wait(g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), secs * 1000);
|
int res = epoll_wait(g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), secs * 1000);
|
||||||
|
|
||||||
|
g_backend->now = time(0);
|
||||||
|
timeout_queue_process(&g_backend->timeout_queue, g_backend->now);
|
||||||
|
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
LOG_WARN("epoll_wait returned -1");
|
LOG_WARN("epoll_wait returned -1");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_backend->now = time(0);
|
|
||||||
timeout_queue_process(&g_backend->timeout_queue, g_backend->now);
|
|
||||||
|
|
||||||
for (n = 0; n < res; n++)
|
for (n = 0; n < res; n++)
|
||||||
{
|
{
|
||||||
struct net_connection_epoll* con = (struct net_connection_epoll*) g_backend->events[n].data.ptr;
|
struct net_connection_epoll* con = (struct net_connection_epoll*) g_backend->events[n].data.ptr;
|
||||||
|
@ -117,15 +117,15 @@ int net_backend_process()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int res = select(maxfd+1, &g_backend->rfds, &g_backend->wfds, 0, &tval);
|
int res = select(maxfd+1, &g_backend->rfds, &g_backend->wfds, 0, &tval);
|
||||||
|
g_backend->now = time(0);
|
||||||
|
timeout_queue_process(&g_backend->timeout_queue, g_backend->now);
|
||||||
|
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
LOG_WARN("select returned -1");
|
LOG_WARN("select returned -1");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_backend->now = time(0);
|
|
||||||
timeout_queue_process(&g_backend->timeout_queue, g_backend->now);
|
|
||||||
|
|
||||||
for (n = 0, found = 0; found < res && n < (maxfd+1); n++)
|
for (n = 0, found = 0; found < res && n < (maxfd+1); n++)
|
||||||
{
|
{
|
||||||
struct net_connection_select* con = g_backend->conns[n];
|
struct net_connection_select* con = g_backend->conns[n];
|
||||||
|
Loading…
Reference in New Issue
Block a user