I'm thinking perhaps we should instead pass a const pointer to: typedef struct {
TSReturnCode (*globalArgIndexReserve)(const char * name, const char * description, int * arg_idx); TSReturnCode (*globalArgIndexNameLookup)(const char * name, int * arg__idx, const char ** description); TSReturnCode (*globalArgIndexLookup)(int arg_idx, const char ** name, const char ** description); void (*globalArgSet)(TSHttpTxn txnp, int arg_idx, void * arg); } TSCallInPluginInitFuncs; to TSPluginInit() (new parameter), and only define one new TS API function (the get function). More idiot proof. Would it trigger an assert if arg set was called more than once for a particular index? Do we need both a Reserve and a NameLookup, can't the lookup create the index if it doesn't exist? On Thu, Feb 27, 2020 at 11:13 AM Leif Hedstrom <zw...@apache.org> wrote: > Hi all, > > This is an idea from Bryan Call, which he suggested as a solution for > reloadable plugins changes that are now in 9.0.x. I recently ran into a > different use case (thanks Miles …), which could really benefit > (performance wise) with such APIs. I *could* use the TxnArg APIs instead, > but these new global arg APIs would make it noticeable faster (and less > locking). So, I’m writing up this proposal based on these ideas, for > discussion / adjustments. > > First off, I’m modeling these completely after the existing ConnArg / > SsnArg / TxnArg, with the exception that they won’t have a limit on the > number of slots (why bother?). > > TSReturnCode TSGlobalArgIndexReserve(const char * name, const char * > description, int * arg_idx) > TSReturnCode TSGlobalArgIndexNameLookup(const char * name, int * > arg__idx, const char ** description) > TSReturnCode TSGlobalArgIndexLookup(int arg_idx, const char ** name, > const char ** description) > void TSGlobalArgSet(TSHttpTxn txnp, int arg_idx, void * arg) > void * TSGlobalArgGet(TSHttpTxn txnp, int arg_idx) > > I’m thinking a simple std::vector here (with a lock for good measure) for > reserving and looking up slots by name. As for lookup performance, I don’t > think this is a problem though, I imagine the use case here is to call > TSGlobalArgIndexReserve() and TSGlobalArgIndexNameLookup() in the Init() > functions of plugins that need access to a global slot, and from thereon > use the index only. The vector will simply store a void*, the name and > description. > > And discuss. > > — Leif > >