[comp.mail.sendmail] Bad File Number

levitz@fsucs.UUCP (Hilbert Levitz) (11/02/90)

We would be grateful for any advice concerning the following
malfunction. It occurs intermittently but  with intolerable freqeuncy.
It has persisted through various kinds of sendmail,  both the  Ultrix
sendmail, and the currently installed Berkeley 5.61 .

The equipment  in  question  is  a  VAX  11/780   running  Ultrix
V2.0-1.

During the mail passing stage  of the  SMTP dialog  if connection
breaks off, the  mail  goes  on  the  queue  with  the error  message
"Bad File Number".  From this there is no automatic recovery.  The item
will hang on the queue with an asterisk, and no delivery of the mail
will be made, even during  later  passes  of  the  queue.
Reoriginating  the  mail frequently succeeds.

			Hilbert Levitz
			Dept. Computer Science
			Florida State University
			levitz@cs.fsu.edu

levitz@fsucs.UUCP (Hilbert Levitz) (11/02/90)

Please excuse this second posting of the same article. It
seems that the address on the "From:" field of the header
is incorrect - another problem - so I would like to ask
resondents to reply to the address on the signature at
the bottom. 


We would be grateful for any advice concerning the following
malfunction. It occurs intermittently but  with intolerable freqeuncy.
It has persisted through various kinds of sendmail,  both the  Ultrix
sendmail, and the currently installed Berkeley 5.61 .

The equipment  in  question  is  a  VAX  11/780   running  Ultrix
V2.0-1.

During the mail passing stage  of the  SMTP dialog  if connection
breaks off, the  mail  goes  on  the  queue  with  the error  message
"Bad File Number".  From this there is no automatic recovery.  The item
will hang on the queue with an asterisk, and no delivery of the mail
will be made, even during  later  passes  of  the  queue.
Reoriginating  the  mail frequently succeeds.

		Hilbert Levitz
		Dept. Of Computer Science
		Florida State University
		Tallahassee, Florida 32306
                (904) 6441796
		levitz@cs.fsu.edu

e07@nikhefh.nikhef.nl (Eric Wassenaar) (11/05/90)

levitz@fsucs.UUCP (Hilbert Levitz) writes:
> ...
> During the mail passing stage  of the  SMTP dialog  if connection
> breaks off, the  mail  goes  on  the  queue  with  the error  message
> "Bad File Number".  From this there is no automatic recovery.  The item
> ...

This bug has been solved since version 5.64.
If you have an older version, proceed as follows:

In the module smtpquit() in usersmtp.c you find the code
	(void) fclose(SmtpIn);
	(void) fclose(SmtpOut);
which actually closes the same (socket) fileno twice.
The second fclose sets errno to EBADF.

The solution is to change in makeconnection() in daemon.c
the line
	*infile = fdopen(s, "r");
to
	*infile = fdopen(dup(s), "r");

Another solution is to save errno before the first fclose,
and to restore it after the second fclose in smtpquit().

Eric Wassenaar
-- 
Organization: NIKHEF-H, National Institute for Nuclear and High-Energy Physics
Address: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
Phone: +31 20 592 0412, Home: +31 20 909449, Telefax: +31 20 592 5155
Internet: e07@nikhef.nl