Improve accuracy of DCC LIST speed and ETA calculations
Switch from using whole-second time_t values to fractional values calculated with time_since().
This commit is contained in:
14
source/dcc.c
14
source/dcc.c
@@ -2573,7 +2573,7 @@ void dcc_glist(char *command, char *args)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < get_max_fd() + 1; i++, count++)
|
for (i = 0; i < get_max_fd() + 1; i++, count++)
|
||||||
{
|
{
|
||||||
time_t xtime;
|
double xtime;
|
||||||
char *filename, *p;
|
char *filename, *p;
|
||||||
const char *type_name;
|
const char *type_name;
|
||||||
|
|
||||||
@@ -2584,10 +2584,14 @@ void dcc_glist(char *command, char *args)
|
|||||||
type = s->flags & DCC_TYPES;
|
type = s->flags & DCC_TYPES;
|
||||||
tdcc = s->flags & DCC_TDCC;
|
tdcc = s->flags & DCC_TDCC;
|
||||||
type_name = dcc_type_name(type, tdcc);
|
type_name = dcc_type_name(type, tdcc);
|
||||||
xtime = now - n->starttime.tv_sec;
|
|
||||||
|
|
||||||
if (xtime <= 0)
|
if (s->flags & DCC_ACTIVE)
|
||||||
xtime = 1;
|
xtime = time_since(&n->starttime);
|
||||||
|
else
|
||||||
|
xtime = time_since(&n->lasttime);
|
||||||
|
|
||||||
|
if (xtime <= 0.0)
|
||||||
|
xtime = 1e-3;
|
||||||
|
|
||||||
filename = LOCAL_COPY(n->filename);
|
filename = LOCAL_COPY(n->filename);
|
||||||
p = filename;
|
p = filename;
|
||||||
@@ -2598,8 +2602,6 @@ void dcc_glist(char *command, char *args)
|
|||||||
if (!(s->flags & DCC_ACTIVE) ||
|
if (!(s->flags & DCC_ACTIVE) ||
|
||||||
(type == DCC_CHAT) || (type == DCC_RAW) || (type == DCC_BOTMODE) || (type == DCC_FTPOPEN))
|
(type == DCC_CHAT) || (type == DCC_RAW) || (type == DCC_BOTMODE) || (type == DCC_FTPOPEN))
|
||||||
{
|
{
|
||||||
if (!(s->flags & DCC_ACTIVE))
|
|
||||||
xtime = now - n->lasttime.tv_sec;
|
|
||||||
if (do_hook(DCC_STAT_LIST, "%d %s %s %s %s %s %s",
|
if (do_hook(DCC_STAT_LIST, "%d %s %s %s %s %s %s",
|
||||||
n->dccnum, type_name, s->server,
|
n->dccnum, type_name, s->server,
|
||||||
dcc_get_state(s),
|
dcc_get_state(s),
|
||||||
|
|||||||
Reference in New Issue
Block a user