[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

conversion to zmpoll - scheduler busyloops



We (I now have a colleague who assists me in mail system maintenance)
noticed that after recent changes scheduler busyloops on poll().
Investigation of the source revealed that the loop on cpids[] terminates
on condition "i < maxf", where maxf is max file descriptor rather than
max used cpids[] slot.

The following patch helps:

--- scheduler/transport.c.orig  2006-10-26 20:40:01.000000000 +0400
+++ scheduler/transport.c       2006-10-26 20:40:46.000000000 +0400
@@ -1191,7 +1191,7 @@

          if (cpids != NULL) {

-           for (proc = cpids, i = 0; i < maxf; ++i, ++proc) {
+           for (proc = cpids, i = 0; i < scheduler_nofiles ; ++i, ++proc) {
              /* sfprintf(sfstderr,"**** QX i = %d QX ***\n", i); */

              timed_log_reinit();

but I find the line 1083:

              zmpoll_addfd(&fds, &highfd, i, -1, &(proc->fdpfrom));

very suspicious: is the file descriptor indeed used as the index for the
TA processes array?  If it is, then the proper fix would be:

--- scheduler/transport.c.orig  2006-10-26 20:40:01.000000000 +0400
+++ scheduler/transport.c       2006-10-26 20:40:46.000000000 +0400
@@ -1191,7 +1191,7 @@

          if (cpids != NULL) {

-           for (proc = cpids, i = 0; i < maxf; ++i, ++proc) {
+           for (proc = cpids, i = 0; i <= maxf ; ++i, ++proc) {
              /* sfprintf(sfstderr,"**** QX i = %d QX ***\n", i); */

              timed_log_reinit();

I also noticed that maxf and highfd are (almost) redundant, aren't they?

Eugene

OpenPGP digital signature