Commits

Anonymous committed a312c56

[svn] - rework comm_checktimeouts() to use the hashtable in an efficient manner.

Comments (0)

Files changed (3)

+nenolod     2007/03/05 17:28:27 UTC	(20070305-3233)
+  Log:
+  - clear up use of fd_table in ircd.
+  
+
+  Changes:	Modified:
+  +3 -2		trunk/src/s_serv.c (File Modified) 
+
+
 nenolod     2007/03/05 17:23:07 UTC	(20070305-3229)
   Log:
   - use a hashtable for fdlist storage. first step to making the amount of allowed clients dynamic and removing MAXCONNECTIONS.
-#define SERNO "20070305-3229"
+#define SERNO "20070305-3233"

libcharybdis/commio.c

  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: commio.c 3229 2007-03-05 17:23:07Z nenolod $
+ *  $Id: commio.c 3235 2007-03-05 17:31:35Z nenolod $
  */
 
 #include "libcharybdis.h"
 void
 comm_checktimeouts(void *notused)
 {
-	int fd;
 	PF *hdl;
 	void *data;
 	fde_t *F;
-	for (fd = 0; fd <= highest_fd; fd++)
+	dlink_list *bucket;
+	int i;
+	dlink_node *n, *n2;
+
+	for (i = 0; i <= FD_HASH_SIZE; i)
 	{
-		F = comm_locate_fd(fd);
-		if(F == NULL)
-			continue;
-		if(!F->flags.open)
-			continue;
-		if(F->flags.closing)
+		bucket = &fd_table[i];
+
+		if (dlink_list_length(bucket) <= 0)
 			continue;
 
-		/* check flush functions */
-		if(F->flush_handler &&
-		   F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
+		DLINK_FOREACH_SAFE(n, n2, bucket->head)
 		{
-			hdl = F->flush_handler;
-			data = F->flush_data;
-			comm_setflush(F->fd, 0, NULL, NULL);
-			hdl(F->fd, data);
-		}
+			F = (fde_t *) n->data;
 
-		/* check timeouts */
-		if(F->timeout_handler &&
-		   F->timeout > 0 && F->timeout < CurrentTime)
-		{
-			/* Call timeout handler */
-			hdl = F->timeout_handler;
-			data = F->timeout_data;
-			comm_settimeout(F->fd, 0, NULL, NULL);
-			hdl(F->fd, data);
+			if(F == NULL)
+				continue;
+			if(!F->flags.open)
+				continue;
+			if(F->flags.closing)
+				continue;
+
+			/* check flush functions */
+			if(F->flush_handler &&
+			   F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
+			{
+				hdl = F->flush_handler;
+				data = F->flush_data;
+				comm_setflush(F->fd, 0, NULL, NULL);
+				hdl(F->fd, data);
+			}
+
+			/* check timeouts */
+			if(F->timeout_handler &&
+			   F->timeout > 0 && F->timeout < CurrentTime)
+			{
+				/* Call timeout handler */
+				hdl = F->timeout_handler;
+				data = F->timeout_data;
+				comm_settimeout(F->fd, 0, NULL, NULL);
+				hdl(F->fd, data);
+			}
 		}
 	}
 }