You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/01/03 18:19:16 UTC
[45/50] git commit: TS-1365 Make the -t option work as intended.
TS-1365 Make the -t option work as intended.
This also adds a new configuration option, proxy.config.net.poll_timeout.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/eccb33cc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/eccb33cc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/eccb33cc
Branch: refs/heads/5.0.x
Commit: eccb33cc01b109c55d8e21ae10d7366e4044993f
Parents: 52c2da6
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Dec 31 13:38:56 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 2 15:30:53 2014 -0700
----------------------------------------------------------------------
iocore/aio/AIO.cc | 5 ++---
iocore/eventsystem/I_SocketManager.h | 3 ++-
iocore/net/I_Net.h | 8 --------
iocore/net/Net.cc | 2 +-
mgmt/RecordsConfig.cc | 8 ++++++++
proxy/Main.cc | 16 +++++++++++++++-
6 files changed, 28 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/iocore/aio/AIO.cc
----------------------------------------------------------------------
diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc
index 2e3e91f..ac8ea0f 100644
--- a/iocore/aio/AIO.cc
+++ b/iocore/aio/AIO.cc
@@ -538,9 +538,8 @@ aio_thread_main(void *arg)
op->thread->schedule_imm_signal(op);
ink_mutex_acquire(&my_aio_req->aio_mutex);
} while (1);
- timespec ten_msec_timespec = ink_based_hrtime_to_timespec(ink_get_hrtime() + HRTIME_MSECONDS(10));
- ink_cond_timedwait(&my_aio_req->aio_cond, &my_aio_req->aio_mutex,
- &ten_msec_timespec);
+ timespec timedwait_msec = ink_based_hrtime_to_timespec(ink_get_hrtime() + HRTIME_MSECONDS(net_config_poll_timeout));
+ ink_cond_timedwait(&my_aio_req->aio_cond, &my_aio_req->aio_mutex, &timedwait_msec);
}
return 0;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/iocore/eventsystem/I_SocketManager.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_SocketManager.h b/iocore/eventsystem/I_SocketManager.h
index 57802f4..d294a5c 100644
--- a/iocore/eventsystem/I_SocketManager.h
+++ b/iocore/eventsystem/I_SocketManager.h
@@ -40,6 +40,7 @@
#define DEFAULT_OPEN_MODE 0644
class Thread;
+extern int net_config_poll_timeout;
#define SOCKET int
@@ -85,7 +86,7 @@ struct SocketManager
int epoll_create(int size);
int epoll_close(int eps);
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
- int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);
+ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout = net_config_poll_timeout);
#endif
#if TS_USE_KQUEUE
int kqueue();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/iocore/net/I_Net.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_Net.h b/iocore/net/I_Net.h
index d6464e5..78f3d62 100644
--- a/iocore/net/I_Net.h
+++ b/iocore/net/I_Net.h
@@ -62,14 +62,6 @@
static int const NO_FD = -1;
-static unsigned int const DEFAULT_POLL_TIMEOUT =
-#if defined(solaris)
- 30 /* mseconds */
-#else
- 10 /* mseconds */
-#endif
- ;
-
extern int net_config_poll_timeout;
#define NET_EVENT_OPEN (NET_EVENT_EVENTS_START)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/iocore/net/Net.cc
----------------------------------------------------------------------
diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc
index 2ae2c99..485aef1 100644
--- a/iocore/net/Net.cc
+++ b/iocore/net/Net.cc
@@ -32,7 +32,7 @@
#include "P_Net.h"
RecRawStatBlock *net_rsb = NULL;
-int net_config_poll_timeout = DEFAULT_POLL_TIMEOUT;
+int net_config_poll_timeout = -1; // This will get set via either command line or records.config.
static inline void
configure_net(void)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 134e029..72a905f 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -796,6 +796,14 @@ RecordElement RecordsConfig[] = {
,
{RECT_CONFIG, "proxy.config.net.sock_mss_in", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
+ {RECT_CONFIG, "proxy.config.net.poll_timeout", RECD_INT,
+#if defined(solaris)
+ "30",
+#else
+ "10",
+#endif
+ RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+ ,
//##############################################################################
//#
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eccb33cc/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 114ade8..1947621 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -153,6 +153,7 @@ HttpBodyFactory *body_factory = NULL;
static int accept_mss = 0;
static int cmd_line_dprintf_level = 0; // default debug output level from ink_dprintf function
+static int poll_timeout = -1; // No value set.
// 1: delay listen, wait for cache.
// 0: Do not delay, start listen ASAP.
@@ -213,7 +214,7 @@ static const ArgumentDescription argument_descriptions[] = {
#endif
{"accept_mss", ' ', "MSS for client connections", "I", &accept_mss, NULL, NULL},
- {"poll_timeout", 't', "poll timeout in milliseconds", "I", &net_config_poll_timeout, NULL, NULL},
+ {"poll_timeout", 't', "poll timeout in milliseconds", "I", &poll_timeout, NULL, NULL},
{"help", 'h', "HELP!", NULL, NULL, NULL, usage},
};
@@ -1451,6 +1452,19 @@ main(int /* argc ATS_UNUSED */, char **argv)
size_t stacksize;
REC_ReadConfigInteger(stacksize, "proxy.config.thread.default.stacksize");
+ // This has some special semantics, in that providing this configuration on
+ // command line has higher priority than what is set in records.config.
+ if (-1 != poll_timeout) {
+ net_config_poll_timeout = poll_timeout;
+ } else {
+ REC_ReadConfigInteger(net_config_poll_timeout, "proxy.config.net.poll_timeout");
+ }
+
+ // This shouldn't happen, but lets make sure we run somewhat reasonable.
+ if (net_config_poll_timeout < 0) {
+ net_config_poll_timeout = 30; // This is the solaris default value.
+ }
+
ink_event_system_init(makeModuleVersion(1, 0, PRIVATE_MODULE_HEADER));
ink_net_init(makeModuleVersion(1, 0, PRIVATE_MODULE_HEADER));
ink_aio_init(makeModuleVersion(1, 0, PRIVATE_MODULE_HEADER));