@@ -306,14 +306,6 @@ void run(EpmdVars *g)
306306 char * tmp = NULL ;
307307 char * token = NULL ;
308308
309- /* IPv4 and/or IPv6 loopback may not be present, for example if
310- * the protocol stack is explicitly disabled in the kernel. If
311- * any sockets to this point fail, log the error but do not exit
312- * with failure. If any socket after this (explicitly
313- * configured via addresses) fails, then consider the error
314- * fatal. */
315- nonfatal_sockets = num_sockets ;
316-
317309 if ((tmp = strdup (g -> addresses )) == NULL )
318310 {
319311 dbg_perror (g ,"cannot allocate memory" );
@@ -381,13 +373,23 @@ void run(EpmdVars *g)
381373 * INADDR_ANY if specified. */
382374 if (!(special_addresses & (EPMD_SPECIAL_ADDRESS_V4_LOOPBACK |
383375 EPMD_SPECIAL_ADDRESS_V4_ANY ))) {
376+ /* IPv4 and/or IPv6 loopback may not be present, for example if
377+ * the protocol stack is explicitly disabled in the kernel. If
378+ * any implicitly enabled sockets fail, log the error but do not exit
379+ * with failure. */
380+ ASSERT (MAX_LISTEN_SOCKETS <= 16 );
381+ nonfatal_sockets |= (1 << num_sockets );
382+
384383 SET_ADDR (iserv_addr [num_sockets ],htonl (INADDR_LOOPBACK ),sport );
385384 num_sockets ++ ;
386385 }
387386
388387#if defined(EPMD6 )
389388 if (!(special_addresses & (EPMD_SPECIAL_ADDRESS_V6_LOOPBACK |
390389 EPMD_SPECIAL_ADDRESS_V6_ANY ))) {
390+ ASSERT (MAX_LISTEN_SOCKETS <= 16 );
391+ nonfatal_sockets |= (1 << num_sockets );
392+
391393 SET_ADDR6 (iserv_addr [num_sockets ],in6addr_loopback ,sport );
392394 num_sockets ++ ;
393395 }
@@ -510,10 +512,9 @@ void run(EpmdVars *g)
510512 dbg_perror (g ,"failed to bind on ipaddr %s" ,
511513 epmd_ntop (& iserv_addr [i ],
512514 socknamebuf , sizeof (socknamebuf )));
513- if (i >= nonfatal_sockets )
515+ if (!( nonfatal_sockets & ( 1 << i ))) {
514516 epmd_cleanup_exit (g ,1 );
515- else
516- {
517+ } else {
517518 close (listensock [i ]);
518519 continue ;
519520 }
0 commit comments