bug-cfengine
[Top][All Lists]
Advanced

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

Re: [patch 2.1.0p1] cfservd: improved handling of EINTR from select()


From: Mark . Burgess
Subject: Re: [patch 2.1.0p1] cfservd: improved handling of EINTR from select()
Date: Sun, 11 Jan 2004 13:04:00 +0100 (MET)

Patch checked and applied
M

On 13 Dec, address@hidden wrote:
> The following patch to cfengine 2.1.0p1's cfservd.c corrects problems that 
> may be triggered when the select() system call is interrupted. Whenever 
> select() returns -1, the fd_set arguments become undefined. 
> Also, it's best not to proceed to the accept() call in such
> circumstances since there is no guarantee that the descriptor is ready.
> 
> --- orig/src/cfservd.c
> +++ mod/src/cfservd.c
> @@ -601,8 +601,6 @@
>     }
>   
>  ageing = 0;
> -FD_ZERO(&rset);
> -FD_SET(sd,&rset);
>  
>  /* Andrew Stribblehill <address@hidden> -- close sd on exec */ 
>  fcntl(sd, F_SETFD, FD_CLOEXEC);
> @@ -614,10 +612,19 @@
>        CheckFileChanges(argc,argv,sd);
>        }
>     
> -   if ((select((sd+1),&rset,NULL,NULL,NULL) == -1) && (errno != EINTR))
> +   FD_ZERO(&rset);
> +   FD_SET(sd,&rset);
> +   if (select((sd+1),&rset,NULL,NULL,NULL) == -1)
>        {
> -      CfLog(cferror, "select failed", "select");
> -      exit(1);
> +      if (errno == EINTR)
> +      {
> +      continue;
> +      }
> +      else
> +         {
> +         CfLog(cferror, "select failed", "select");
> +         exit(1);
> +         }
>        }
>     
>     if ((sd_reply = accept(sd,(struct sockaddr *)&cin,&addrlen)) != -1)
> 
> 
> 
> 
> _______________________________________________
> Bug-cfengine mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-cfengine



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  address@hidden
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





reply via email to

[Prev in Thread] Current Thread [Next in Thread]