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

Problems with fd allocation?



I was just wondering about FD allocation in a couple parts of ZMailer.

We've been rebuilding some of our configuration and I was running some
tests on using the standard configuration without the mail.conf.

When I try running the router in interactive mode (just want to see the
parsing of router.cf) we get the following error messages:

ZMailer router (2.99.26 #19: Wed Mar  6 15:31:18 PST 1996)
  driley@orb:/source/source/work/zmailer-2.99.26/router
  Copyright 1992 Rayan S. Zachariassen
  Copyright 1992-1996 Matti Aarnio

  router: missing /var/zmailer/mail/mail.conf: using the following values:
  router: pipe prediction wrong: got 5|3 not 6|5
  Usage: canon key
  orgdomain=
  hostname=
  mydomain=
  orb.direct.ca
  start newaliases... printaliases: no aliases found!
  "/var/zmailer/mail/db/aliases" rebuilding aborted


The aliases file is currently missing (that shouldn't have an effect on
the parsing of router.cf) and this is on an Ultra as I've mentioned before.

Trying it interactively I get different results again.  (They're all
set as orb if I do a mailconf and then the three echo statements).

After coming up with this, I looked further into a problem we had before
with our routers dying because of an abort() from this fragment
in router/rfc822.c:

/* XX: DEBUG STUFF! */
if (FILENO(e->e_fp) < 3) {
  fprintf(stderr,"RFC822: While opening mail-file '%s', got fd=%d  AARGH! (fds 0..2 should never close on us!)",
          file, FILENO(e->e_fp));
  fflush(stderr);
  /* abort(); */
}

However, when I looked at the truss results on running the router and then
through further examination of lib/detach.c I see the following:

#ifdef  USE_SETSID
        if (fork() != 0)
                exit(0);        /* setsid() can be called only once per proc. */
        setsid();
#else   /* !USE_SETSID */
#ifdef  USE_BSDSETPGRP
        if ((fd = open("/dev/tty", O_RDWR, 0)) >= 0) {
                ioctl(fd, TIOCNOTTY, 0);        /* lose controlling terminal */
                close(fd);
        }
        setpgrp(0, getpid());   /* change process group */
#else   /* !USE_BSDSETPGRP */
        /* lose controlling terminal and change process group */
        setpgrp();
        SIGNAL_IGNORE(SIGHUP);  /* immune from pgrp leader death */
        if (fork() != 0)        /* become non-pgrp-leader */
                exit(0);        /* first child */
        /* second child */
#endif  /* USE_BSDSETPGRP */
#endif  /* USE_SETSID */

out:
        close(0);
#if     0
        for (fd = 3; fd < getdtablesize(); ++fd)
                close(fd);      /* close almost all file descriptors */
#endif  /* notdef */
        umask(022); /* clear any inherited file mode creation mask */

>From the truss, I see that it does the setsid(), close() and then the umask().

Any idea?

And one final thing, with regard to that patch that Tom posted (and you 
corrected) in the mailing list, you mention that it should be needed.  We
were exhibiting the problem with the standard SMTP+UUCP.cf, FYI.

Thanks for any assistance you can give.

David Riley         - University of Waterloo
driley@direct.ca    - Internet Direct (Vancouver, B.C.)