[ 
https://issues.apache.org/jira/browse/TS-3245?focusedWorklogId=26237&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-26237
 ]

ASF GitHub Bot logged work on TS-3245:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Aug/16 22:34
            Start Date: 08/Aug/16 22:34
    Worklog Time Spent: 10m 
      Work Description: GitHub user pbchou opened a pull request:

    https://github.com/apache/trafficserver/pull/845

    TS-3245: Allow multiple plugins to safely use getopt(3).

    Request back-port to 6.2.x branch. This was cherry-picked from "master", 
and it was clean except for some spacing issues introduced by clang-format 
setting changes.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/pbchou/trafficserver TS-3245-backport-6.2.x

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/845.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #845
    
----
commit 92b20a567bf8e0df3621f00f8e81f2bfd2e39078
Author: Peter Chou <[email protected]>
Date:   2016-06-06T23:31:43Z

    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.
    
    Back-ported from "master" [7.0.0] branch.

----


Issue Time Tracking
-------------------

            Worklog Id:     (was: 26237)
            Time Spent: 10m
    Remaining Estimate: 0h

> 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
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to