This is an automated email from the ASF dual-hosted git repository.
jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 590edf6 TS-3245: Allow multiple plugins to safely use getopt(3).
590edf6 is described below
commit 590edf6a9c0577b1109d8d061b2b96356b9d4de1
Author: Peter Chou
AuthorDate: Mon Jun 6 16:31:43 2016 -0700
TS-3245: Allow multiple plugins to safely use getopt(3).
Allow multiple global plugins to co-exist in the plugin.config
file. Also, made the same changes to allow remap plugins
to co-exist with each other in the remap.config file.
Specifically, on freebsd and darwin platforms we use 'optreset =
1' to reset the getopt_long() command line parser. On Linux/glibc
we use 'optind = 0' to reset the parser. The parser must be reset
between uses such as first loading one plugin and then another.
The setting of these variables is now performed in ATS core before
the plugin initialization functions are called. The setting of these
variables inside of the individual plugins has been removed. If a
plugin needs to call getopt_long() outside of the plugin global or
remap intializations, it should use the code in proxy/Plugin.cc as
an example.
This closes #696.
---
plugins/experimental/acme/acme.c | 1 -
plugins/experimental/authproxy/authproxy.cc | 5 -
plugins/experimental/background_fetch/background_fetch.cc | 1 -
plugins/experimental/balancer/balancer.cc | 1 -
plugins/experimental/cache_promote/cache_promote.cc | 1 -
plugins/experimental/cachekey/configs.cc | 1 -
plugins/experimental/esi/esi.cc | 2 --
plugins/experimental/regex_revalidate/regex_revalidate.c | 1 -
plugins/experimental/remap_stats/remap_stats.c| 1 -
plugins/experimental/s3_auth/s3_auth.cc | 1 -
plugins/experimental/sslheaders/sslheaders.cc | 5 -
.../stale_while_revalidate/stale_while_revalidate.c | 1 -
plugins/experimental/xdebug/xdebug.cc | 2 --
plugins/stats_over_http/stats_over_http.c | 1 -
plugins/tcpinfo/tcpinfo.cc| 1 -
proxy/Plugin.cc | 10 ++
proxy/http/remap/RemapConfig.cc | 11 +++
17 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/plugins/experimental/acme/acme.c b/plugins/experimental/acme/acme.c
index cb0244f..ffe891a 100644
--- a/plugins/experimental/acme/acme.c
+++ b/plugins/experimental/acme/acme.c
@@ -307,7 +307,6 @@ TSPluginInit(int argc, const char *argv[])
};
memset(, 0, sizeof(gConfig));
- optind = 0;
while (true) {
int opt = getopt_long(argc, (char *const *)argv, "", longopt, NULL);
diff --git a/plugins/experimental/authproxy/authproxy.cc
b/plugins/experimental/authproxy/authproxy.cc
index 3d534c6..3eac60d 100644
--- a/plugins/experimental/authproxy/authproxy.cc
+++ b/plugins/experimental/authproxy/authproxy.cc
@@ -694,11 +694,6 @@ AuthParseOptions(int argc, const char **argv)
options->transform = AuthWriteRedirectedRequest;
- // We might parse arguments multiple times if we are loaded as a global
- // plugin and a remap plugin. Reset optind so that getopt_long() does the
- // right thing (ie. work instead of crash).
- optind = 0;
-
for (;;) {
int opt;
diff --git a/plugins/experimental/background_fetch/background_fetch.cc
b/plugins/experimental/background_fetch/background_fetch.cc
index a6c88d6..d703086 100644
--- a/plugins/experimental/background_fetch/background_fetch.cc
+++ b/plugins/experimental/background_fetch/background_fetch.cc
@@ -568,7 +568,6 @@ TSPluginInit(int argc, const char *argv[])
gConfig = new BgFetchConfig(cont);
gConfig->acquire(); // Inc refcount, although this global config should
never go out of scope
- optind = 1;
while (true) {
int opt = getopt_long(argc, (char *const *)argv, "lc", longopt, NULL);
diff --git a/plugins/experimental/balancer/balancer.cc
b/plugins/experimental/balancer/balancer.cc
index d763622..9bcff35 100644
--- a/plugins/experimental/balancer/balancer.cc
+++ b/plugins/experimental/balancer/balancer.cc
@@ -113,7 +113,6 @@ TSRemapNewInstance(int argc, char *argv[], void **instance,
char *errbuf, int er
argc--;
argv++;
- optind = 0;
for (;;) {
int opt;
diff --git a/plugins/experimental/cache_promote/cache_promote.cc
b/plugins/experimental/cache_promote/cache_promote.cc
index d25c54a..a501d2d 100644
--- a/plugins/experimental/cache_promote/cache_promote.cc
+++ b/plugins/experimental/cache_promote/cache_promote.cc
@@ -351,7 +351,6 @@