paul@umix.cc.umich.edu ('da Kingfish) (11/11/87)
Someone mentioned sfgets() being slow because of timers or signalhandling, or whatever ... I don't know about that, but here is something that makes it really "slow." I sent this in via sendbug, but thought this group would be interested as well. Subject: sendmail: collect() calls sfgets() with bad arg, causing infinite loop Index: usr.lib/sendmail/src/collect.c 4.3BSD Description: When sfgets() is called with a buffer size of -1, it will never return. collect() calls it with a size of -1 when it is reading succeeding indented header lines that have a combined length greater than MAXFIELD. Repeat-By: Get enough mail via tcp/smtp from an IBM VM/CMS site. Or construct your own header, and send it. Symptoms of the bug are seeing things like this from ps(1), even when the corresponding tcp connections are gone, and do not show up in netstat(). Notice the cpu consumption. Also, notice the hosts tend to be VM machines. root 23591 7.1 2.2 276 141 ? R 9:10 -AA23591 MITVMA.MIT.EDU: DATA (sendmail) root 23835 7.2 2.2 276 146 ? R 7:06 -AA23835 MITVMA.MIT.EDU: DATA (sendmail) root 24081 7.2 2.1 276 140 ? R 5:44 -AA24081 WISCVM.WISC.EDU: DATA (sendmail) root 24156 7.1 2.2 276 147 ? R 5:24 -AA24156 MITVMA.MIT.EDU: DATA (sendmail) root 24391 7.0 2.3 276 150 ? R 3:42 -AA24391 WISCVM.WISC.EDU: DATA (sendmail) root 24452 7.3 2.2 276 144 ? R 3:20 -AA24452 MITVMA.MIT.EDU: DATA (sendmail) root 24654 7.4 2.5 276 165 ? R 1:49 -AA24654 WISCVM.WISC.EDU: DATA (sendmail) root 24731 7.1 2.5 276 165 ? R 1:32 -AA24731 MITVMA.MIT.EDU: DATA (sendmail) Fix: In collect() change the code that calls sfgets() while lines start with space or tab to be aware of when its buffer is full. If it is, throw output away, which sendmail does do for the first portion of each header line read. -- Trying everything that whiskey cures in Ann Arbor, Michigan. Over one billion messages read.