mupdate uses to much cpu when a connection reaches its timeout_mark (patch)

Guillaume Bailleul guillaume.bailleul at atosorigin.com
Tue Oct 10 09:14:53 EDT 2006


Hi all,

We encountered a problem with the mupdate master process when a client
stays connected to master sending nothing for hours. After 3 hours
(value found in mupdate.c), the "session" is in "read_timeout". 

the master process try prot_fill on the connection but with nothing to
read from the client, this function returns EOF and EAGAIN. Quite normal
in a non blocking mode. In this case, the timeout mark of the protstream
is not changed.

mupdates threads are calling prot_select to find active connections.
Because of a timeout_mark "in the past", the prot_select always call
select with sleep for 0. That explains why to many cpu is used.

We think that the problem is in prot.c :

when prot_fill is called in a non blocking context (here, function docmd
of mupdate.c), there is nothing special done if s->timeout_mark is
reached. prot_fill returns like a normal "nothing read in non blocking
mode".

We suggest a patch that raise an error "idle for to long" when this
timeout is reached. The result is the same than an idle for to long in
blocking mode.

Don't know if we are right but it seems to work well.


The patch :

--- prot.c      2006-10-10 14:45:04.000000000 +0200
+++ prot.c.patch        2006-10-10 14:44:37.000000000 +0200
@@ -447,6 +447,9 @@
                if (!s->dontblock) {
                    s->error = xstrdup("idle for too long");
                    return EOF;
+               } else if (s->timeout_mark <= now) {
+                   s->error = xstrdup("idle for too long");
+                   return EOF;
                } else {
                    errno = EAGAIN;
                    return EOF;




Guillaume Bailleul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prot.c.nonblockingtimeout.patch
Type: text/x-patch
Size: 384 bytes
Desc: not available
Url : https://lists.andrew.cmu.edu/mailman/private/cyrus-devel/attachments/20061010/dcb4c275/prot.c.nonblockingtimeout.bin


More information about the Cyrus-devel mailing list