}
-#ifndef MINGW
/**
* Make a socket non-inheritable to child processes
*
static int
socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
{
+#ifndef MINGW
int i;
-
i = fcntl (h->fd, F_GETFD);
if (i < 0)
return GNUNET_SYSERR;
i |= FD_CLOEXEC;
if (fcntl (h->fd, F_SETFD, i) < 0)
return GNUNET_SYSERR;
+#else
+ BOOL b;
+ SetLastError (0);
+ b = SetHandleInformation (h->fd, HANDLE_FLAG_INHERIT, 0);
+ if (!b)
+ {
+ SetErrnoFromWinsockError (WSAGetLastError ());
+ return GNUNET_SYSERR;
+ }
+#endif
return GNUNET_OK;
}
-#endif
#ifdef DARWIN
errno = EMFILE;
return GNUNET_SYSERR;
}
+#endif
if (GNUNET_OK != socket_set_inheritable (h))
LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"socket_set_inheritable");
-#endif
+
if (GNUNET_SYSERR == socket_set_blocking (h, GNUNET_NO))
{
GNUNET_break (0);
#endif
)
{
+ GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_ERROR,
_
("Fatal internal logic error, process hangs in `%s' (abort with CTRL-C)!\n"),
"select");
- GNUNET_break (0);
}
#ifndef MINGW
tv.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value;
fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&i,
NULL);
- if (fh->type == GNUNET_PIPE)
+ if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
/* Read zero bytes to check the status of the pipe */
LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n",
fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&i,
NULL);
- if (fh->type == GNUNET_PIPE)
+ if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL))
{
i, readArray[i]->h, bret, waitstatus, error);
if (bret == 0)
{
- if (error != ERROR_BROKEN_PIPE)
+ /* TODO: either add more errors to this condition, or eliminate it
+ * entirely (failed to peek -> pipe is in serious trouble, should
+ * be selected as readable).
+ */
+ if (error != ERROR_BROKEN_PIPE && error != ERROR_INVALID_HANDLE)
continue;
}
else if (waitstatus <= 0)
fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&t,
NULL);
- if (fh->type == GNUNET_PIPE)
+ if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
CancelIo (fh->h);
}