[JDEV] Minor 'bug'let ?

Jeremie jeremie at jeremie.com
Thu Jan 7 21:41:42 CST 1999


On the FD_SETSIZE issue in io.c, I updated it to track the largest
descriptor and use that value... attached is the diff I'm going to check
in tonight, let me know if it's wrong or broken...

Thanks for letting me know about this :)

Jer
-------------- next part --------------
Index: io.c
===================================================================
RCS file: /work/cvs/jap/common/io.c,v
retrieving revision 1.9
diff -u -r1.9 io.c
--- io.c	1999/01/05 20:30:10	1.9
+++ io.c	1999/01/08 03:25:58
@@ -13,7 +13,7 @@
 void collect_packets(conn *(*handle_packet)())
 {
 	char buffer[MAXMSG];
-	int new, nbytes, err, first = 1;
+	int new, nbytes, err, maxfd = 0, first = 1;
 	fd_set active_fd_set, read_fd_set, write_fd_set;
 	struct sockaddr_in sa;
 	size_t size = sizeof(sa);
@@ -37,7 +37,7 @@
 		if(!first)
 		{
 			DBUG("IO: waiting ","")
-			h_err(select(FD_SETSIZE, &read_fd_set, &write_fd_set, NULL, NULL),"select");
+			h_err(select(maxfd + 1, &read_fd_set, &write_fd_set, NULL, NULL),"select");
 
 			FD_ZERO(&active_fd_set);
 		}else{
@@ -63,6 +63,8 @@
 					c = conn_add(c,new);
 					c->name = strdup(inet_ntoa(sa.sin_addr));
 					c->ver = strdup(c_count->name); /* express the parent socket that it was created from */
+					if(new > maxfd)
+						maxfd = new;
 					FD_SET(new, &active_fd_set);
 				}else{
 					DBUG("IO: reading data from ",c_count->name)
@@ -86,6 +88,8 @@
 					}
 				}
 			}
+			if(c_count->id > maxfd)
+				maxfd = c_count->id;
 			FD_SET(c_count->id, &active_fd_set);
 			c_count = c_count->next;
 		}


More information about the JDev mailing list