1 /* XXX: this program knows quite a bit about tcpto's internals */
5 #include "auto_qmail.h"
14 void die(n) int n; { substdio_flush(subfdout); _exit(n); }
20 substdio_puts(subfdout,s);
21 substdio_puts(subfdout,": ");
22 substdio_puts(subfdout,x);
23 substdio_puts(subfdout,"\n");
26 void die_chdir() { warn("fatal: unable to chdir"); die(111); }
27 void die_open() { warn("fatal: unable to open tcpto"); die(111); }
28 void die_lock() { warn("fatal: unable to lock tcpto"); die(111); }
29 void die_read() { warn("fatal: unable to read tcpto"); die(111); }
33 char tmp[FMT_ULONG + IPFMT];
46 if (chdir(auto_qmail) == -1) die_chdir();
47 if (chdir("queue/lock") == -1) die_chdir();
49 fdlock = open_write("tcpto");
50 if (fdlock == -1) die_open();
51 fd = open_read("tcpto");
52 if (fd == -1) die_open();
53 if (lock_ex(fdlock) == -1) die_lock();
54 r = read(fd,tcpto_buf,sizeof(tcpto_buf));
58 if (r == -1) die_read();
68 byte_copy(&ip,4,record);
69 when = (unsigned long) (unsigned char) record[11];
70 when = (when << 8) + (unsigned long) (unsigned char) record[10];
71 when = (when << 8) + (unsigned long) (unsigned char) record[9];
72 when = (when << 8) + (unsigned long) (unsigned char) record[8];
74 substdio_put(subfdout,tmp,ip_fmt(tmp,&ip));
75 substdio_puts(subfdout," timed out ");
76 substdio_put(subfdout,tmp,fmt_ulong(tmp,(unsigned long) (start - when)));
77 substdio_puts(subfdout," seconds ago; # recent timeouts: ");
78 substdio_put(subfdout,tmp,fmt_ulong(tmp,(unsigned long) (unsigned char) record[4]));
79 substdio_puts(subfdout,"\n");