[
https://issues.apache.org/jira/browse/TS-3245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15285313#comment-15285313
]
ASF GitHub Bot commented on TS-3245:
------------------------------------
Github user pbchou commented on the pull request:
https://github.com/apache/trafficserver/pull/571#issuecomment-219549881
I think this depends on whether GNU extensions are being used or not since
the man page does say that you "must" reinitialize with optind = 0 if you go
back and forth between traditional and GNU extensions between scans. I am not
certain what constitutes a GNU extension in the opstring, but I can report that
two of the plugins included in this PR (background_fetch and regex_revalidate),
which both use optind = 1 currently, do not play well together.
background_fetch uses opstring "lc" while regex_revalidate uses "c:l:" so I
suspect the colons are considered GNU extensions since that is the only
difference besides the order of the letters. So sounds like glibc requires 0
and other libraries require 1 so this would need an #ifdef then. Note, there
are actually 15 plugins using getopt (11 use optind=0 and 4 use optind=1).
> 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)