diff options
author | Stijn Buys <ingar@osirion.org> | 2011-01-27 12:25:36 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-01-27 12:25:36 +0000 |
commit | 45b93da49b74acd7389e4faa1cfd5dba6cd75c95 (patch) | |
tree | 256f8c7037810598427116414f4e74cf7cbd0357 /src/core | |
parent | c3182222bd3fef6009f98205c0203d61a7509b11 (diff) |
Added net_selecttimeout cvar and changed the default timeout to 10,000 microseconds.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/application.cc | 3 | ||||
-rw-r--r-- | src/core/cvar.cc | 1 | ||||
-rw-r--r-- | src/core/cvar.h | 1 | ||||
-rw-r--r-- | src/core/netserver.cc | 11 |
4 files changed, 15 insertions, 1 deletions
diff --git a/src/core/application.cc b/src/core/application.cc index dc08595..5c7e4e7 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -150,6 +150,9 @@ void Application::init(int count, char **arguments) Cvar::net_framerate = Cvar::get("net_framerate", "25"); Cvar::net_framerate->set_info("[int] network framerate in frames/sec"); + Cvar::net_selecttimeout = Cvar::get("net_selecttimeout", "10000"); + Cvar::net_framerate->set_info("[int] network select() call timeout, in microseconds"); + Cvar::mem_vertex = core::Cvar::get("mem_vertex", "64" , core::Cvar::Archive); Cvar::mem_vertex->set_info("[int] amount of video memory reserved for model geometry, in megabytes"); diff --git a/src/core/cvar.cc b/src/core/cvar.cc index 100f31f..66da4d4 100644 --- a/src/core/cvar.cc +++ b/src/core/cvar.cc @@ -31,6 +31,7 @@ Cvar *Cvar::net_port = 0; Cvar *Cvar::net_maxclients = 0; Cvar *Cvar::net_timeout = 0; Cvar *Cvar::net_framerate = 0; +Cvar *Cvar::net_selecttimeout = 0; Cvar *Cvar::mem_vertex = 0; diff --git a/src/core/cvar.h b/src/core/cvar.h index 4c55fad..ffc11bf 100644 --- a/src/core/cvar.h +++ b/src/core/cvar.h @@ -165,6 +165,7 @@ public: static Cvar *net_maxclients;// maximum number of connected clients static Cvar *net_timeout; // network timeout in seconds static Cvar *net_framerate; // client network send framerate + static Cvar *net_selecttimeout; // timeout for select() call, in microseconds static Cvar *mem_vertex; // amount of video memory reserved for model geometry, in megabytes diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 4769f68..937d91b 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -187,7 +187,16 @@ void NetServer::receive() timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = 2500; + + // 1,000,000 microseconds = 1 second, default is 2500 + timeout.tv_usec = (long) Cvar::net_selecttimeout->value(); + if (timeout.tv_usec < 0) + timeout.tv_usec = 0; + else if (timeout.tv_usec > 1000000) { + timeout.tv_sec = timeout.tv_usec / 1000000; + timeout.tv_usec %= 1000000; + } + fd_set readset = serverset; int nb = select(fd() + 1, &readset, NULL, NULL, &timeout); |