trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leif Hedstrom <zw...@apache.org>
Subject [API REVIEW] Modify string ownership for TSRedirectUrlSet()
Date Wed, 02 Apr 2014 15:46:53 GMT
Hi all,

as part of the v5.0.0 API fixup’s, I’d like to change the string ownership “contract”
for TSRedirectUrlSet(). Today, the incoming URL string is basically strdup()’ed, and in
most use cases I can think of, it’d be more logical to stick to how we do other similar
APIs, which is to assume the caller has allocated the memory. This also significantly improves
efficiency for many use cases. For example, a typical plugin use case would be something like
this:

          url_str = TSUrlStringGet(mbuf, url, &url_len);
          TSRedirectUrlSet(txn, url_str, url_len);
	  TSfree(url_str);  // I’d like to eliminate this!

In the current implementations, this causes malloc() / strcpy() of the url_str twice; once
in the plugin, and then once again in the TSRedirectUrlSet() API. This is a waste :). I understand
this breaks implementations using this API, but I’m still on the mindset that we should
take this opportunity to improve on the APIs in v5.0.0. We haven’t done so since v2.0, and
we’ve learned a lot since then. We will provide tools (such as the existing perl script)
that helps people migrate their plugins, and of course, all core plugins will be fixed.

I filed a Jira on this, at

	https://issues.apache.org/jira/browse/TS-2693


— Leif


Mime
View raw message