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

Eliminate string copies in the SDK

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1.5
    • TS API
    • None

    Description

      There are a small'ish number of APIs, that (for legacy reasons I believe) makes copies of the marshalled header strings, just to make them NULL terminated. None of these APIs claim to guarantee the strings to be NULL terminated, and all of our APIs pretty much says that you should never expect strings to be NULL terminated.

      Eliminating this string duplication will make the APIs easier to use (since now TSHandleStringRelease() is completely unecessary), and will also make plugins faster (no mallocs and frees for these strings).

      The APIs that are affected, only by contract (no API changes) are

      const char * TSUrlSchemeGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlUserGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlPasswordGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlHostGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlPathGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlHttpParamsGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlHttpQueryGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSUrlHttpFragmentGet(TSMBuffer bufp, TSMLoc obj, int *length);

      const char *TSMimeHdrFieldNameGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int *length);
      const char *TSHttpHdrMethodGet(TSMBuffer bufp, TSMLoc obj, int *length);
      const char *TSHttpHdrReasonGet(TSMBuffer bufp, TSMLoc obj, int *length);

      TSReturnCode TSMimeHdrFieldValueStringGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx, const char **value_ptr, int *value_len_ptr);

      From now on, these will never be NULL terminated.

      Attachments

        1. TS-579.diff
          82 kB
          Leif Hedstrom

        Activity

          People

            zwoop Leif Hedstrom
            zwoop Leif Hedstrom
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: