[
https://issues.apache.org/jira/browse/TS-3245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15321034#comment-15321034
]
ASF subversion and git services commented on TS-3245:
-----------------------------------------------------
Commit 590edf6a9c0577b1109d8d061b2b96356b9d4de1 in trafficserver's branch
refs/heads/master from [~pbchou]
[ https://git-wip-us.apache.org/repos/asf?p=trafficserver.git;h=590edf6 ]
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.
> getopt doesn't work correctly when used in plugin chaining
> ----------------------------------------------------------
>
> Key: TS-3245
> URL: https://issues.apache.org/jira/browse/TS-3245
> Project: Traffic Server
> Issue Type: Improvement
> Components: Plugins
> Affects Versions: 5.1.1
> Reporter: Sudheer Vinukonda
> Priority: Minor
> Labels: newbie
> Fix For: sometime
>
>
> When multiple plugins that use getopt are chained, it doesn't work correctly
> for the subsequent plugins after the first plugin. [[email protected]] and
> [~zwoop] suggested that the getopt globals need to be reset (example,
> {{optind = opterr = optopt = 0}}) before using it and would be better to do
> it in the core during plugin loading to keep it simple/transparent from
> plugin development.
> Note that, if a plugin itself uses getopt multiple times on different argv's,
> it would have to reset the globals between them.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)