Hi Anders,

Ack. Comments inline.
I hope some of these changes will reflect in later branches of 4.2.x 
i.e., on 4.3.x and default as well.

Thanks,
Ramesh.

On 12/5/2013 6:42 PM, Anders Widell wrote:
>   osaf/services/infrastructure/nid/nodeinit.c |  9 +++++++--
>   1 files changed, 7 insertions(+), 2 deletions(-)
>
>
> There were three loops in nodeinit.c that could potentially become infinite 
> if a
> system call returns -1. It is fine to try again when e.g. errno == EINTR, 
> since
> that is a temporary error that will go away eventually. In general however,
> trying again will not make the error go away and the loop would become 
> infinite.
> Also made a file descriptor non-blocking to avoid blocking indefinitely in
> read().
>
> diff --git a/osaf/services/infrastructure/nid/nodeinit.c 
> b/osaf/services/infrastructure/nid/nodeinit.c
> --- a/osaf/services/infrastructure/nid/nodeinit.c
> +++ b/osaf/services/infrastructure/nid/nodeinit.c
> @@ -46,6 +46,8 @@
>   *            any notification.                                          *
>   ************************************************************************/
>   
> +#include <unistd.h>
> +#include <fcntl.h>
>   #include <syslog.h>
>   #include <libgen.h>
>   #include <ctype.h>
> @@ -621,6 +623,8 @@ int32_t fork_daemon(NID_SPAWN_INFO *serv
>   
>       if(-1 == pipe(filedes))
>               LOG_ER("Problem creating pipe: %s", strerror(errno));
> +     else
> +             fcntl(filedes[0], F_SETFL, fcntl(filedes[0], F_GETFL) | 
> O_NONBLOCK);
>   
>       if ((pid = fork()) == 0) {
>               if (nis_fifofd > 0)
> @@ -641,10 +645,10 @@ int32_t fork_daemon(NID_SPAWN_INFO *serv
>                               continue;
>                       else if (errno == EPIPE) {
>                               LOG_ER("Reader not available to return my PID");
> -                             exit(2);
>                       } else {
>                               LOG_ER("Problem writing to pipe, err=%s", 
> strerror(errno));
>                       }
> +                     exit(2);
[Ramesh]: How about retrying for fixed number of times for EAGAIN errno.
>               }
>   
>               setsid();
> @@ -691,6 +695,7 @@ int32_t fork_daemon(NID_SPAWN_INFO *serv
>               }
>               if (errno == EINTR)
>                       continue;
> +             break;
[Ramesh]: Below of this while-loop there is a while-loop for read(), in 
this case too can we consider for retry fixed number of times for EAGAIN 
errno.
>       }
>   
>       while (read(filedes[0], &tmp_pid, sizeof(int)) < 0)
> @@ -1002,7 +1007,7 @@ uint32_t spawn_wait(NID_SPAWN_INFO *serv
>                       LOG_ER("Timed-out for response from %s", 
> service->serv_name);
>                       return NCSCC_RC_FAILURE;
>               }
> -
> +             break;
>       }
>   
>       /* Read the message from FIFO and fill in structure. */


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to