You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Joseph Hindin (JIRA)" <ji...@apache.org> on 2015/11/22 18:28:10 UTC

[jira] [Created] (TS-4035) SImple plugin code is wrong

Joseph Hindin created TS-4035:
---------------------------------

             Summary: SImple plugin code is wrong
                 Key: TS-4035
                 URL: https://issues.apache.org/jira/browse/TS-4035
             Project: Traffic Server
          Issue Type: Bug
          Components: Documentation
            Reporter: Joseph Hindin


The simple plugin code, presented in the [plugin development documentation|https://trafficserver.readthedocs.org/en/latest/developer-guide/plugins/getting-started/plugin-registration-and-version-checking.en.html] , contains the following code snippet:
{code:title=hello-world.c}
if (!TSPluginRegister(&info))  {
         TSError ("[plugin_name] Plugin registration failed.");
} 
{code}

But the header file defines the return code in the following way:

{code:title=ts/apidef.h}
typedef enum { TS_ERROR = -1, TS_SUCCESS = 0 } TSReturnCode;
{code}

Apparently, in case of success the return code is 0 and non-zero in case of failure, so the sample code is expected to be
{code:title=hello-world.c suggested fix for condition}
if (TSPluginRegister(&info))  {
         TSError ("[plugin_name] Plugin registration failed.");
} 
{code}

Also, it seems that on error {{TSPlugInit}} function should return immediately, like in the following suggestion:
{code:title=hello-world.c suggested fix}
if (TSPluginRegister(&info))  {
         TSError ("[plugin_name] Plugin registration failed.");
         return;
} 
{code}





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)