mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-03 15:15:01 +00:00
Make sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) generally available instead
of being private to tcp_timer.c. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 3 days
This commit is contained in:
parent
9512e32664
commit
a4684d742d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155758
|
@ -822,6 +822,32 @@ sysctl_handle_int(SYSCTL_HANDLER_ARGS)
|
|||
return (error);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Based on on sysctl_handle_int() convert milliseconds into ticks.
|
||||
*/
|
||||
|
||||
int
|
||||
sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int error, s, tt;
|
||||
|
||||
tt = *(int *)oidp->oid_arg1;
|
||||
s = (int)((int64_t)tt * 1000 / hz);
|
||||
|
||||
error = sysctl_handle_int(oidp, &s, 0, req);
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
tt = (int)((int64_t)s * hz / 1000);
|
||||
if (tt < 1)
|
||||
return (EINVAL);
|
||||
|
||||
*(int *)oidp->oid_arg1 = tt;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle a long, signed or unsigned. arg1 points to it.
|
||||
*/
|
||||
|
|
|
@ -63,26 +63,6 @@
|
|||
#include <netinet/tcp_debug.h>
|
||||
#endif
|
||||
|
||||
static int
|
||||
sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int error, s, tt;
|
||||
|
||||
tt = *(int *)oidp->oid_arg1;
|
||||
s = (int)((int64_t)tt * 1000 / hz);
|
||||
|
||||
error = sysctl_handle_int(oidp, &s, 0, req);
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
tt = (int)((int64_t)s * hz / 1000);
|
||||
if (tt < 1)
|
||||
return (EINVAL);
|
||||
|
||||
*(int *)oidp->oid_arg1 = tt;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int tcp_keepinit;
|
||||
SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPINIT, keepinit, CTLTYPE_INT|CTLFLAG_RW,
|
||||
&tcp_keepinit, 0, sysctl_msec_to_ticks, "I", "");
|
||||
|
|
|
@ -168,6 +168,7 @@ struct sysctl_oid {
|
|||
#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
|
||||
|
||||
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
|
||||
|
|
Loading…
Reference in a new issue