[dovecot-cvs] dovecot/src/lib ioloop.c,1.35.2.7,1.35.2.8

tss at dovecot.org tss at dovecot.org
Thu Mar 15 16:28:08 EET 2007


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv11400

Modified Files:
      Tag: branch_1_0
	ioloop.c 
Log Message:
If timeout wait time was less than 1 millisecond, we wasted CPU calling
poll() (or whatever) with zero timeout multiple times until the millisecond
had passed. Now we round the waits up to next millisecond.



Index: ioloop.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop.c,v
retrieving revision 1.35.2.7
retrieving revision 1.35.2.8
diff -u -d -r1.35.2.7 -r1.35.2.8
--- ioloop.c	7 Mar 2007 16:07:59 -0000	1.35.2.7
+++ ioloop.c	15 Mar 2007 14:28:03 -0000	1.35.2.8
@@ -204,8 +204,10 @@
 		tv->tv_usec += 1000000;
 	}
 
-	if (tv->tv_sec > 0 || (tv->tv_sec == 0 && tv->tv_usec > 0))
-		return tv->tv_sec*1000 + tv->tv_usec/1000;
+	if (tv->tv_sec > 0 || (tv->tv_sec == 0 && tv->tv_usec > 0)) {
+		/* round wait times up to next millisecond */
+		return tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000;
+	}
 
 	/* no need to calculate the times again with this timeout */
         tv->tv_sec = tv->tv_usec = 0;



More information about the dovecot-cvs mailing list