Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-4035

Simple plugin code is wrong

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.1.0
    • Component/s: Documentation
    • Labels:
      None

      Description

      The simple plugin code, presented in the plugin development documentation , contains the following code snippet:

      hello-world.c
      if (!TSPluginRegister(&info))  {
               TSError ("[plugin_name] Plugin registration failed.");
      } 
      

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

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

      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

      hello-world.c suggested fix for condition
      if (TSPluginRegister(&info))  {
               TSError ("[plugin_name] Plugin registration failed.");
      } 
      

      Also, it seems that on error TSPlugInit function should return immediately, like in the following suggestion:

      hello-world.c suggested fix
      if (TSPluginRegister(&info))  {
               TSError ("[plugin_name] Plugin registration failed.");
               return;
      } 
      

        Attachments

          Activity

            People

            • Assignee:
              jamespeach James Peach
              Reporter:
              jhindin Joseph Hindin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: