> On Nov 4, 2014, at 4:20 PM, Brian Geffon <[email protected]> wrote:
>
> This should be self explanatory and IMO we should land for 5.2, the
> following patch is also attached to TS-1432.
+1 on the API
For the implementation, I think you should take reference counting into
account. Maybe something along these lines:
void
TSMutexDestroy(TSMutex m)
{
ProxyMutex * mutexp = (ProxyMutex *)m;
sdk_assert(sdk_sanity_check_null_ptr((void*)mutexp) == TS_SUCCESS);
sdk_assert(mutexp->nthread_holding == 0);
if (mutexp->refcount() == 0) {
mutexp->free();
} else {
if (REF_COUNT_OBJ_REFCOUNT_DEC(mutexp) == 0) {
mutextp->free();
}
}
}
>
> Brian
>
>
>
> diff --git a/proxy/InkIOCoreAPI.cc b/proxy/InkIOCoreAPI.cc
> index 26f3298..091d7a2 100644
> --- a/proxy/InkIOCoreAPI.cc
> +++ b/proxy/InkIOCoreAPI.cc
> @@ -189,6 +189,11 @@ TSMutexCreate()
> return (TSMutex)mutexp;
> }
>
> +void
> +TSMutexDestroy(TSMutex m) {
> + ((ProxyMutex *)m)->free();
> +}
> +
> /* The following two APIs are for Into work, actually, APIs of Mutex
> should allow plugins to manually increase or decrease the refcount
> of the mutex pointer, plugins may want more control of the creation
> diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
> index 3a6eed6..07a8760 100644
> --- a/proxy/api/ts/ts.h
> +++ b/proxy/api/ts/ts.h
> @@ -1129,6 +1129,7 @@ extern "C"
> /*
> --------------------------------------------------------------------------
> Mutexes */
> tsapi TSMutex TSMutexCreate(void);
> + tsapi void TSMutexDestroy(TSMutex mutexp);
> tsapi void TSMutexLock(TSMutex mutexp);
> tsapi TSReturnCode TSMutexLockTry(TSMutex mutexp);