[ovs-dev] [threads 05/17] process: Add thread safety comments.

Alex Wang alexw at nicira.com
Mon Jun 10 18:02:37 UTC 2013


looks good to me,

this also maks the completion of review for patches 02/17-05/17


On Wed, Jun 5, 2013 at 1:05 PM, Ben Pfaff <blp at nicira.com> wrote:

> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  lib/process.c |    4 ++++
>  lib/process.h |   14 ++++++++++----
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/lib/process.c b/lib/process.c
> index 22dd266..c09737a 100644
> --- a/lib/process.c
> +++ b/lib/process.c
> @@ -60,6 +60,8 @@ static void sigchld_handler(int signr OVS_UNUSED);
>  /* Initializes the process subsystem (if it is not already initialized).
>  Calls
>   * exit() if initialization fails.
>   *
> + * This function may not be called after creating any additional threads.
> + *
>   * Calling this function is optional; it will be called automatically by
>   * process_start() if necessary.  Calling it explicitly allows the client
> to
>   * prevent the process from exiting at an unexpected time. */
> @@ -167,6 +169,8 @@ process_register(const char *name, pid_t pid)
>   * argv[0] is used as the name of the process.  Searches the PATH
> environment
>   * variable to find the program to execute.
>   *
> + * This function may not be called after creating any additional threads.
> + *
>   * All file descriptors are closed before executing the subprocess,
> except for
>   * fds 0, 1, and 2.
>   *
> diff --git a/lib/process.h b/lib/process.h
> index d17737d..3feac7e 100644
> --- a/lib/process.h
> +++ b/lib/process.h
> @@ -21,21 +21,27 @@
>  #include <sys/types.h>
>
>  struct process;
> +
> +/* Starting and monitoring subprocesses.
> + *
> + * process_init() and process_start() may safely be called only from a
> + * single-threaded parent process.  The parent process may safely create
> + * additional threads afterward, as long as the remaining functions in
> this
> + * group are called only from a single thread at any given time. */
>  void process_init(void);
> -char *process_escape_args(char **argv);
>  int process_start(char **argv, struct process **);
>  void process_destroy(struct process *);
>  int process_kill(const struct process *, int signr);
> -
>  pid_t process_pid(const struct process *);
>  const char *process_name(const struct process *);
>  bool process_exited(struct process *);
>  int process_status(const struct process *);
> -char *process_status_msg(int);
> -
>  void process_run(void);
>  void process_wait(struct process *);
>
> +/* These functions are thread-safe. */
> +char *process_status_msg(int);
> +char *process_escape_args(char **argv);
>  char *process_search_path(const char *);
>
>  #endif /* process.h */
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130610/ecdf8703/attachment-0003.html>


More information about the dev mailing list