+ if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
+ sctx->serviceName, "TOLERANT"))
+ {
+ if (GNUNET_SYSERR ==
+ (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+ sctx->serviceName,
+ "TOLERANT")))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Specified value for `%s' of service `%s' is invalid\n"),
+ "TOLERANT",
+ sctx->serviceName);
+ return GNUNET_SYSERR;
+ }
+ }
+ else
+ tolerant = GNUNET_NO;
+
+#ifndef MINGW
+ errno = 0;
+ if ( (NULL != (lpid = getenv ("LISTEN_PID"))) &&
+ (1 == sscanf (lpid, "%u", &pid)) &&
+ (getpid () == (pid_t) pid) &&
+ (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
+ (1 == sscanf (nfds, "%u", &cnt)) &&
+ (cnt > 0) &&
+ (cnt < FD_SETSIZE) &&
+ (cnt + 4 < FD_SETSIZE) )
+ {
+ sctx->lsocks = GNUNET_malloc (sizeof(struct GNUNET_NETWORK_Handle*) * (cnt+1));
+ while (0 < cnt--)
+ {
+ flags = fcntl (3 + cnt, F_GETFD);
+ if ( (flags < 0) ||
+ (0 != (flags & FD_CLOEXEC)) ||
+ (NULL == (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not access pre-bound socket %u, will try to bind myself\n"),
+ (unsigned int) 3 +cnt);
+ cnt++;
+ while (sctx->lsocks[cnt] != NULL)
+ GNUNET_break (0 == GNUNET_NETWORK_socket_close (sctx->lsocks[cnt++]));
+ GNUNET_free (sctx->lsocks);
+ sctx->lsocks = NULL;
+ break;
+ }
+ }
+ unsetenv ("LISTEN_PID");
+ unsetenv ("LISTEN_FDS");
+ }
+#endif