Re: [PATCH 2/7] clstated: reattempt the pipe open if it fails on ENOENT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/14/2011 08:57 AM, Jeff Layton wrote:
> Generally, we want this daemon started before nfsd starts. Deal with the
> situation where the pipe hasn't shown up yet.
This can be done with your systemd start up script. Plus I'm not sure its 
a good idea to steal cpu cycles waiting for an event that may never happen...

steved.

> 
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
>  utils/clstated/clstated.c |   15 +++++++++++----
>  1 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/utils/clstated/clstated.c b/utils/clstated/clstated.c
> index 93a2710..aab09a7 100644
> --- a/utils/clstated/clstated.c
> +++ b/utils/clstated/clstated.c
> @@ -75,10 +75,17 @@ usage(char *progname)
>  static int
>  clstate_pipe_open(struct clstate_client *clnt)
>  {
> -	clnt->cl_fd = open(pipepath, O_RDWR, 0);
> -	if (clnt->cl_fd < 0) {
> -		xlog(L_ERROR, "%s: unable to open %s: %m", __func__, pipepath);
> -		return clnt->cl_fd;
> +	/* loop until the pipe is present or open fails for another reason */
> +	for (;;) {
> +		clnt->cl_fd = open(pipepath, O_RDWR, 0);
> +		if (clnt->cl_fd >= 0) {
> +			break;
> +		} else if (errno != ENOENT) {
> +			xlog(D_GENERAL, "%s: unable to open %s: %m", __func__,
> +					pipepath);
> +			return clnt->cl_fd;
> +		}
> +		sleep(1);
>  	}
>  
>  	event_set(&clnt->cl_event, clnt->cl_fd, EV_READ, clstatecb, clnt);
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux