Change location in the APIs to be type specific
-----------------------------------------------

                 Key: TS-686
                 URL: https://issues.apache.org/jira/browse/TS-686
             Project: Traffic Server
          Issue Type: Improvement
          Components: TS API
    Affects Versions: 2.1.6
            Reporter: Bryan Call
            Priority: Minor
             Fix For: 2.1.7


Change arguments for APIs to use type specific combinations of buffer and 
location instead of having generic types (e.g., TSMBuffer, TSMLoc) that can be 
interchanged.

Leif and I talked about this more after I sent and email to dev@ and we agreed 
that combining the buffer and location would be better unless there are a lot 
of APIs that require then to passed in separately.  Looking over the APIs I 
don't think this is the case.

Also, we talked about possibly having request and response being the same type, 
so there wouldn't be two version of some of the APIs (e.g., TSHttpHdrUrlGet())

Parts of my email to dev@:
Looking at the three APIs below it is hard to tell the location/offset 
really point to:

  tsapi TSReturnCode TSHttpTxnClientReqGet(TSHttpTxn txnp, TSMBuffer* 
bufp, TSMLoc* offset);
  tsapi TSReturnCode TSHttpHdrUrlGet(TSMBuffer bufp, TSMLoc offset, 
TSMLoc* locp);
  tsapi const char* TSUrlSchemeGet(TSMBuffer bufp, TSMLoc offset, int 
*length);

In a specific case that happened last week a person was taking bufp and 
offset from TSHttpTxnClientReqGet() and passing the values to 
TSUrlSchemeGet().  Since it didn't give him compile errors he only saw 
the problem when the server was under load and it would core dump.

One way to fix this would be to change locations to specific types.  If 
we want to take it a step further the buffer and location could be 
combined and given a specific type simplifying the APIs.

Example of combining buffer and location and making specific types (IMO 
cleaner):
  tsapi TSReturnCode TSHttpTxnClientReqGet(TSHttpTxn txnp, TSRequest 
*request);
  tsapi TSReturnCode TSHttpHdrUrlGet(TSRequest request, TSUrl *url);
  tsapi const char* TSUrlSchemeGet(TSUrl url, int *length);

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to