[sheepdog] [PATCH 09/10] sheep: add a checker for thread type

Liu Yuan namei.unix at gmail.com
Wed Aug 7 19:41:42 CEST 2013


On Thu, Aug 08, 2013 at 12:49:07AM +0900, MORITA Kazutaka wrote:
> From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> 
> This introduces a two maker "main_fn" and "worker_fn".  If the
> function must be called in the main thread, add "main_fn" to it.  If
> the function must be called in the worker thread, add "worker_fn" to
> it.  The markers are used only when we run configure with
> --enable-thread-checker.  The check is done at the entry point of the
> function upon tracer infrastracture.
> 
> Adding the marker is simpler and easier than writing assert.  In
> addition, programmers can easily understand which function must be
> called in the main/worker thread.
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
>  configure.ac         |   15 ++++++++++++++-
>  sheep/Makefile.am    |    4 ++++
>  sheep/group.c        |   31 ++++++++++++++++---------------
>  sheep/request.c      |   11 ++++-------
>  sheep/sheep_priv.h   |   22 ++++++++++++++++++++++
>  sheep/thread_check.c |   37 +++++++++++++++++++++++++++++++++++++
>  sheep/trace/trace.c  |    6 ++++++
>  sheep/trace/trace.h  |    1 +
>  8 files changed, 104 insertions(+), 23 deletions(-)
>  create mode 100644 sheep/thread_check.c
> 
> diff --git a/configure.ac b/configure.ac
> index 49544a4..645f82b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -208,8 +208,13 @@ AC_ARG_WITH([initddir],
>  	[ INITDDIR="$withval" ],
>  	[ INITDDIR="$sysconfdir/init.d" ])
>  
> +AC_ARG_ENABLE([thread-check],
> +	[  --enable-thread-check   : enable thread check],,
> +	[ enable_thread_check="${enable_debug}" ],)
> +AM_CONDITIONAL(BUILD_THREAD_CHECK, test x$enable_thread_check = xyes)
> +
>  AC_ARG_ENABLE([trace],
> -	[  --enable-trace           : enable trace],,
> +	[  --enable-trace          : enable trace],,
>  	[ enable_trace="no" ],)
>  AM_CONDITIONAL(BUILD_TRACE, test x$enable_trace = xyes)
>  
> @@ -281,6 +286,14 @@ if test "x${enable_zookeeper}" = xyes; then
>  	PACKAGE_FEATURES="$PACKAGE_FEATURES zookeeper"
>  fi
>  
> +if test "x${enable_thread_check}" = xyes; then
> +	AC_MSG_NOTICE([thread check requires tracer feature])
> +	enable_trace="yes"
> +	AM_CONDITIONAL(BUILD_TRACE, test x$enable_trace = xyes)
> +	AC_DEFINE_UNQUOTED([HAVE_THREAD_CHECK], 1, [have thread check])
> +	PACKAGE_FEATURES="$PACKAGE_FEATURES thread_check"
> +fi

I think enable it automatically when --enable-trace is specified. No need for
another configure option

Thanks
Yuan



More information about the sheepdog mailing list