diald 0.12 takes all the CPU time with kernel 1.3.81

Oliver Jowett (oliver@sa-search.massey.ac.nz)
Wed, 3 Apr 1996 08:53:26 +1200 (NZST)


I have an intermittent problem, where diald will end up taking almost all
of the CPU:

PID USER PRI NI SIZE RES SHRD STAT %CPU %MEM TIME COMMAND
25273 root 17 0 932 364 252 R 94.8 5.1394:19 diald /dev/ttyS0 -f /home/Pdiald/options -- auth

strace'ing diald gives this rather ugly result:

select(100, [1 2 4], NULL, NULL, {0, 200000}) = 1 (in [1], left {0, 200000})
read(1, "", 1024) = 0
time(NULL) = 828476680
time(NULL) = 828476680
select(100, [1 2 4], NULL, NULL, {0, 200000}) = 1 (in [1], left {0, 200000})
read(1, "", 1024) = 0
time(NULL) = 828476680
time(NULL) = 828476680
select(100, [1 2 4], NULL, NULL, {0, 200000}) = 1 (in [1], left {0, 200000})
read(1, "", 1024) = 0
time(NULL) = 828476680
time(NULL) = 828476680

[... and so on ...]

root@sa-ra1:/proc/25273/fd# ls -l
total 0
lrwx------ 1 root root 64 Apr 3 08:25 0 -> [0000]:712281
lr-x------ 1 root root 64 Apr 3 08:25 1 -> [0341]:71003
lrwx------ 1 root root 64 Apr 3 08:25 2 -> [0000]:712284
lrwx------ 1 root root 64 Apr 3 08:25 3 -> [0000]:712259
lrwx------ 1 root root 64 Apr 3 08:25 4 -> [0341]:4185
lrwx------ 1 root root 64 Apr 3 08:25 5 -> [0341]:4384

[0341]:71003 corresponds to the diald command FIFO, /etc/diald/fifo.

The bit of code which does this is in diald.c:
/* wait up to a second for an event */
FD_ZERO(&readfds);
if (fifo_fd != -1)
FD_SET(fifo_fd,&readfds);
FD_SET(proxy_mfd,&readfds);
FD_SET(snoopfd,&readfds);
sel = select(100,&readfds,0,0,&timeout);
if (sel > 0) {
/* read user commands off the fifo */
if (fifo_fd != -1 && FD_ISSET(fifo_fd,&readfds)) fifo_read();

I'd assume this problem comes about because of the changes to the named
pipe code in 1.3.81. Any suggestions?

Oliver

--
     "C makes it easy to shoot yourself in the foot.  C++ makes it
      harder, but when you do, it blows away your whole leg."

-- Bjarne Stroustrup on C++