Jorgen Lundman:
> However, I found that this works:
> 
>     char buffer[1];
>     if ((write(fd, buffer, 0) < 0) && (errno == EPIPE)) {
>         msg_warn("write_wait() connection reset %d", fd);
>         return 0;
>     }

Try:

        return -1;

Then it won't send "221 Bye".

        Wietse

>     pollfd.fd = fd;
>     pollfd.events = POLLOUT;
>     for (;;) {
>         switch (poll(&pollfd, 1, timeout < 0 ?
>                      WAIT_FOR_EVENT : timeout * 1000)) {
> 
> 
> Which truss shows as:
> 
> 22179:   0.0000 read(11, " Q U I T\r\n", 4096)                  = 6
> 22179:   0.0001 ioctl(11, FIONREAD, 0x08047614)                 Err#131
> ECONNRESET
> 22179:   0.0000 write(11, 0x0804782F, 0)                        Err#32 EPIPE
> 22179:   0.0001     Received signal #13, SIGPIPE [ignored]
> 22179:   0.0000 write(11, " 2 2 1   2 . 0 . 0   B y".., 15)     Err#32 EPIPE
> 22179:   0.0000     Received signal #13, SIGPIPE [ignored]
> 22179:   0.0001 close(11)                                       = 0
> 
> 
> It is interesting to note the errno changed to EPIPE when calling write()
> instead of read().
> 
> Is a write(  ,0) always non-blocking? Probably needs answering.
> 
> 
> Running with L4 health checks for 20mins and:
> 
> # ps -edaf| grep smtpd | wc -l
>        2
> 
> 
> Everything "appears to work" but I have no put it on production. I do wish
> there was a nicer way to detect the problem than to use a zero-write.
> Possibly signal the problem in peekfd(), and act on it in write_wait().
> 
> 
> 
> -- 
> Jorgen Lundman       | <lund...@lundman.net>
> Unix Administrator   | +81 (0)3 -5456-2687 ext 1017 (work)
> Shibuya-ku, Tokyo    | +81 (0)90-5578-8500          (cell)
> Japan                | +81 (0)3 -3375-1767          (home)
> 

Reply via email to