GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
const struct GNUNET_NETWORK_FDSet *src)
{
+#ifndef MINGW
int nfds;
for (nfds = src->nsds; nfds > 0; nfds--)
if (nfds + 1 > dst->nsds)
dst->nsds = nfds + 1;
}
-#ifdef MINGW
+#else
+ /* This is MinGW32-specific implementation that relies on the code that
+ * winsock2.h defines for FD_SET. Namely, it relies on FD_SET checking
+ * that fd being added is not already in the set.
+ * Also relies on us knowing what's inside fd_set (fd_count and fd_array).
+ */
+ int i;
+ for (i = 0; i < src->sds.fd_count; i++)
+ FD_SET (src->sds.fd_array[i], &dst->sds);
+ if (src->nsds > dst->nsds)
+ dst->nsds = src->nsds;
+
GNUNET_CONTAINER_slist_append (dst->handles, src->handles);
#endif
}
/* Copy all the writes to the except, so we can detect connect() errors */
for (i = 0; i < awrite.fd_count; i++)
- {
- if (awrite.fd_array[i] != 0 && awrite.fd_array[i] != -1)
- FD_SET (awrite.fd_array[i], &aexcept);
- }
+ FD_SET (awrite.fd_array[i], &aexcept);
if (aread.fd_count > 0 || awrite.fd_count > 0 || aexcept.fd_count > 0)
selectret = select (1, (rfds != NULL) ? &aread : NULL,
(wfds != NULL) ? &awrite : NULL, &aexcept, &select_timeout);
have checked that descriptors were in awrite originally before re-adding them from
aexcept. Luckily, GNUnet never uses aexcept for anything, so this does not become a problem (yet). */
for (i = 0; i < aexcept.fd_count; i++)
- {
- if (aexcept.fd_array[i] != 0 && aexcept.fd_array[i] != -1)
- FD_SET (aexcept.fd_array[i], &awrite);
- }
+ FD_SET (aexcept.fd_array[i], &awrite);
/* If our select returned something or is a 0-timed request, then also check the pipes and get out of here! */
/* Sadly, it means code duplication :( */
* but we don't use OOB data.
*/
for (i = 0; i < awrite.fd_count; i++)
- {
- if (awrite.fd_array[i] != 0 && awrite.fd_array[i] != -1)
- FD_SET (awrite.fd_array[i], &aexcept);
- }
+ FD_SET (awrite.fd_array[i], &aexcept);
ResetEvent (select_finished_event);
SetEvent (select_standby_event);
}
}
/* Check aexcept, add its contents to awrite */
for (i = 0; i < aexcept.fd_count; i++)
- {
- if (aexcept.fd_array[i] != 0 && aexcept.fd_array[i] != -1)
- FD_SET (aexcept.fd_array[i], &awrite);
- }
+ FD_SET (aexcept.fd_array[i], &awrite);
}
returnedpos = returncode - WAIT_OBJECT_0;