[ovs-dev] [PATCH 1/5] ovs-thread: Add a comment

Ben Pfaff blp at nicira.com
Tue Feb 4 21:46:24 UTC 2014


On Wed, Jan 15, 2014 at 12:41:20PM +0900, YAMAMOTO Takashi wrote:
> Add a comment about implicit synchronization which
> fat-rwlock seems to rely on.
> 
> Signed-off-by: YAMAMOTO Takashi <yamamoto at valinux.co.jp>
> ---
>  lib/ovs-thread.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h
> index 8cf2ecc..dab7510 100644
> --- a/lib/ovs-thread.h
> +++ b/lib/ovs-thread.h
> @@ -447,6 +447,14 @@ void xpthread_join(pthread_t, void **);
>   * Compared to pthread_key_t, ovsthread_key_t has the follow limitations:
>   *
>   *    - Destructors must not access thread-specific data (via ovsthread_key).
> + *
> + * Unlike pthread_key_t, this API implicitly serializes key removal
> + * (ovsthread_key_delete) and thread exit. (destructor)
> + * I.e.
> + *    - ovsthread_key_delete ensures the completion of destructors for
> + *      the key.
> + *    - Once ovsthread_key_delete completed, no destructors for the key
> + *      will be executed on thread exit.
>   */
>  typedef struct ovsthread_key *ovsthread_key_t;

I think I understand what you are saying, but I think that I would
phrase it differently.  Does the following express what you mean?

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index a20b2fd..18e524e 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -592,7 +592,8 @@ ovsthread_key_create(ovsthread_key_t *keyp, void (*destructor)(void *))
 }
 
 /* Frees 'key'.  The destructor supplied to ovsthread_key_create(), if any, is
- * not called.
+ * not called.  This function returns only after any running destructors for
+ * 'key' complete execution.
  *
  * This function is similar to xpthread_key_delete(). */
 void




More information about the dev mailing list