- if (!WSAEnumNetworkEvents(socket, netevent, &things)) {
- if (things.lNetworkEvents & FD_READ)
- back->msg(0, FD_READ);
- if (things.lNetworkEvents & FD_CLOSE) {
- back->msg(0, FD_CLOSE);
- break;
- }
+ enum234 e;
+ SOCKET socket;
+ extern SOCKET first_socket(enum234 *), next_socket(enum234 *);
+ extern int select_result(WPARAM, LPARAM);
+ int i;
+
+ /*
+ * We must not call select_result() for any socket
+ * until we have finished enumerating within the tree.
+ * This is because select_result() may close the socket
+ * and modify the tree.
+ */
+ /* Count the active sockets. */
+ i = 0;
+ for (socket = first_socket(&e); socket != INVALID_SOCKET;
+ socket = next_socket(&e))
+ i++;
+
+ /* Expand the buffer if necessary. */
+ if (i > sksize) {
+ sksize = i+16;
+ sklist = srealloc(sklist, sksize * sizeof(*sklist));
+ }
+
+ /* Retrieve the sockets into sklist. */
+ skcount = 0;
+ for (socket = first_socket(&e); socket != INVALID_SOCKET;
+ socket = next_socket(&e)) {
+ sklist[skcount++] = socket;