--- innfeed-0.10.1.7.orig/misc.c
+++ innfeed-0.10.1.7/misc.c
@@ -207,7 +207,7 @@
     {
       char buffer [512] ;      /* gag me */
 
-      vsprintf (buffer,fmt,ap) ;
+      vsnprintf (buffer,sizeof buffer,fmt,ap) ;
       syslog (level,buffer) ;
     }
   va_end (ap) ;
--- innfeed-0.10.1.7.orig/main.c
+++ innfeed-0.10.1.7/main.c
@@ -113,7 +113,7 @@
 static char *logFile ;
 static char *newsspool ;
 
-static void sigemt (int sig) ;
+static void sigttin (int sig) ;
 static void sigalrm (int sig) ;
 static void sigchld (int sig) ;
 static void sigint (int sig) ;
@@ -522,7 +522,7 @@
   setSigHandler (SIGALRM,sigalrm) ;
 
   /* handle signal to flush all the backlog files */
-  setSigHandler (SIGEMT,sigemt) ;
+  setSigHandler (SIGTTIN,sigttin) ;
 
   /* we can increment and decrement logging levels by sending SIGUSR{1,2} */
   setSigHandler (SIGUSR1,sigusr) ;
@@ -637,7 +637,7 @@
   configHosts (talkToSelf) ;
 }
 
-static void sigemt (int sig)
+static void sigttin (int sig)
 {
   (void) sig ;
 
--- innfeed-0.10.1.7.orig/misc.h
+++ innfeed-0.10.1.7/misc.h
@@ -83,6 +83,9 @@
 int maxFds (void) ;
 
 /* if level <= loggingLevel then print */
+#if defined (__GLIBC__)
+#  define dprintf debugprintf
+#endif
 void dprintf (u_int level, const char *fmt, ...) __attribute__ ((__format__ (printf, 2, 3)));
 
 /* for the gethostbyname() error code */
--- innfeed-0.10.1.7.orig/sysconfig.h
+++ innfeed-0.10.1.7/sysconfig.h
@@ -75,10 +75,10 @@
 
 
 /*
-** LINUX
+** LINUX libc5
 */
 
-#if defined (linux)
+#if defined (__linux__) && !defined(__GLIBC__)
 
 /* Note: If you are running version 5.4.3 or better of libc, then 16 is the
    number to use. Lower than that, and you should use 1. */
@@ -89,6 +89,18 @@
 #define USE_SIGACTION
 #endif
 
+/*
+** LINUX libc6
+*/
+
+#if defined (__linux__) && defined(__GLIBC__)
+#define MAX_WRITEV_VEC 16
+#define DO_NEED_SYS_SELECT 
+#define HAVE_MMAP 1
+#define NBIO_FCNTL 1
+#define USE_SIGACTION
+#endif
+
 
 /*
 ** DEC Unix
--- innfeed-0.10.1.7.orig/procbatch.pl
+++ innfeed-0.10.1.7/procbatch.pl
@@ -33,7 +33,7 @@
 
 # If you have inn 1.5 or higher, then set $innshellvars to point at the
 # installed innshellvars.pl file. 
-$innshellvars = "/var/news/etc/innshellvars.pl" ;
+$innshellvars = "/etc/news/innshellvars.pl" ;
 
 if ( -f $innshellvars ) {
     require $innshellvars ;
@@ -43,7 +43,7 @@
     # if $inn'batch is /var/news/spool/out.going then set tapeDir to 
     # /var/news/spool/innfeed
     $tapeDir = $inn'batch ; #'
-    $tapeDir =~ s!(.*)/.*!$1! ;
+    #$tapeDir =~ s!(.*)/.*!$1! ;
     $tapeDir .= "/innfeed" ;
 
     $destDir = $inn'spooltemp ; #'
--- innfeed-0.10.1.7.orig/innfeed.conf.5
+++ innfeed-0.10.1.7/innfeed.conf.5
@@ -613,21 +613,21 @@
 # (``#''), then the whole string must be quoted
 # with double quotes.  Inside the quotes, you may
 # use the standard c-escape sequence
-# (\t,\n,\r,\f,\v,\",\').
+# (\\t,\\n,\\r,\\f,\\v,\\",\\').
 #
 # Examples:
-#       eg-string:      "New\tConfig\tfile\n"
+#       eg-string:      "New\\tConfig\\tfile\\n"
 #       eg-long-string: "A long string that goes
 #                       over multiple lines. The
 #                       newline is kept in the
 #                       string except when quoted 
-#                       with a backslash \
+#                       with a backslash \\
 #                       as here."
 #       eg-simple-string: A-no-quote-string
 #       eg-integer:     10
 #       eg-boolean:     true
 #       eg-char:        'a'
-#       eg-ctrl-g:      '\007'
+#       eg-ctrl-g:      '\\007'
 
 .fi
 .RE
--- innfeed-0.10.1.7.orig/convertconfig.pl
+++ innfeed-0.10.1.7/convertconfig.pl
@@ -49,13 +49,13 @@
 );
 
 %procDefaults = (
-'news-spool', '/var/news/spool/articles',
+'news-spool', '/var/spool/news',
 'pid-file', 'innfeed.pid',
 'debug-level', '0',
 'use-mmap', 'false',
 'log-file', 'innfeed.log',
 'stdio-fdmax', '0',
-'backlog-directory', '/var/news/spool/innfeed',
+'backlog-directory', '/var/spool/news/out.going/innfeed',
 'backlog-rotate-period', '60',
 'backlog-ckpt-period', '30',
 'backlog-newfile-period', '600',
--- innfeed-0.10.1.7.orig/innfeed-undrop
+++ innfeed-0.10.1.7/innfeed-undrop
@@ -0,0 +1,150 @@
+From rra@stanford.edu Sat Feb 24 21:34:58 2001
+Path: wonderland.linux.it!bofh.it!excite.it!feed.textport.net!newsfeed.stanford.edu!nntp.stanford.edu!not-for-mail
+From: Russ Allbery <rra@stanford.edu>
+Newsgroups: news.software.nntp
+Subject: Re: Accumulating innfeed cruft
+Date: 24 Feb 2001 11:48:51 -0800
+Organization: The Eyrie
+Lines: 85
+Message-ID: <ylsnl3aml8.fsf@windlord.stanford.edu>
+References: <978v65$eao$1@marduk.litech.org> <9790d7$kji$1@allhats.xcski.com>
+NNTP-Posting-Host: windlord.stanford.edu
+Mime-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+X-Trace: news.Stanford.EDU 983044132 1192 171.64.13.23 (24 Feb 2001 19:48:52 GMT)
+X-Complaints-To: news@news.stanford.edu
+User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)
+Xref: wonderland.linux.it news.software.nntp:38395
+
+Paul Tomblin <ptomblin@xcski.com> writes:
+> In a previous article, jeff@litech.org (Jeffrey M. Vinocur) said:
+
+>> I've been running a small INN setup for a while, and I happenned to
+>> notice some buildup of Stuff.  In particular, a couple dozen
+>> spool/innfeed/innfeed-dropped.* files.  The manpage seems to imply that
+>> these are from misconfiguring (like adding a peer to newsfeeds but
+>> forgetting about innfeed.conf), and thus I should be able to delete the
+>> old ones without doing any harm.
+
+Nope, they happen all the time, usually whenever a lot of control messages
+are acted on in a short period or you issue a whole bunch of ctlinnd
+commands.  You want to pick them up and process them.
+
+> I seem to get those when a site goes off the air for a while, even after
+> it comes back on.  I wish I knew what they are, but I just blow them
+> away.
+
+Here's the internal document I wrote here at Stanford saying how to deal
+with them:
+
+  Author: Russ Allbery <eagle@windlord.stanford.edu>
+ Subject: Processing dropped articles from innfeed
+Revision: $Id: innfeed-dropped,v 1.1 1999/12/15 23:58:57 eagle Exp $
+
+innfeed is the process on newsfeed.stanford.edu that sends outgoing
+articles to our peers (including to nntp.stanford.edu).  It will sometimes
+drop articles; this happens when innfeed can't initialize a remote site
+for whatever reason, or when INN feeds it articles for a site that isn't
+in innfeed.conf (a misconfiguration).  The most common cause of this is
+the problems that innfeed has with being stopped and restarted a bunch of
+times in active succession.  INN stops and restarts innfeed whenever it
+acts on a control message, so this can happen when a flurry of control
+messages come in; when it does, innfeed will sometimes be unable to lock a
+site for a while, and articles for that site will get dropped.
+
+Dropped articles are noted in files named innfeed-dropped.<id> where <id>
+is a unique ID for a given innfeed process.  These files should normally
+always be zero length.  If they're non-zero length, innfeed has dropped
+some articles, and those dropped article files have to be manually
+processed or those articles will never be correctly sent to peers.  A cron
+job checks every hour for such non-zero dropped article files and will
+notify news@news if they show up.
+
+To process one of these dropped article files, first make sure that the
+dropped article file doesn't correspond to a currently running innfeed.
+The easiest way of checking this is to notice that every running innfeed
+process has a dropped article file, and there are always three copies of
+innfeed running on newsfeed.stanford.edu.  If there are only three dropped
+article files, they all correspond to running innfeed processes.  You can
+also note that the digits at the end of the file name are the PID of
+innfeed and see if that process is running.
+
+If the file is owned by a running innfeed, stop and restart that instance
+of innfeed.  The easy way to do that is the command ctlinnd reload
+newsfeeds 'restart innfeed' -- the bit between single quotes is just the
+log message and is arbitrary.  The better way, which only restarts the
+innfeed you need to restart, is to use ps to determine whether the
+corresponding innfeed is the innfeed-sm instance, the innfeed-lg instance,
+or the innfeed instance (the one that doesn't take a configuration file on
+the command line), and then flush the corresponding pseudosite.  For
+example, if ps reveals that that innfeed is using the innfeed-sm.conf
+file, type ctlinnd flush innfeed-sm\!.  (All pseudosite names end in !,
+which has to be protected from the shell.)
+
+After the dropped article file is safely unowned by any running process,
+run procbatch -vm <dropped-file>.  That will generate innfeed backlog
+files for each site mentioned in the dropped article file and put them
+somewhere where innfeed will pick them up a while later.  procbatch doesn't
+delete the dropped article files itself, so after running procbatch you
+should rm the files.
+
+If the dropped articles were due to a misconfiguration, the generated
+backlog file won't correspond to any configured innfeed peer.  The best
+way of detecting this is to see if there's a .lock file for whatever
+backlog file procbatch generated (it will tell you what files it's
+generating).  If there's no .lock file, innfeed doesn't have that site
+configured as a peer, and some more tweaking and fixes to innfeed.conf
+will probably be needed to correct whatever's going wrong.
+
+-- 
+Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>
+
+          Please post questions rather than mailing me directly.
+     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
+
+From W1986@inka.de Mon Feb 26 11:44:13 2001
+Path: wonderland.linux.it!bofh.it!excite.it!newsfeed01.sul.t-online.de!t-online.de!blackbush.xlink.net!rz.uni-karlsruhe.de!schlund.de!inka.de!not-for-mail
+From: Sven Paulus <W1986@inka.de>
+Newsgroups: news.software.nntp
+Subject: Re: Accumulating innfeed cruft
+Date: 26 Feb 2001 09:57:57 GMT
+Organization: (Posted via) INKA e.V. http://www.inka.de/
+Lines: 28
+Message-ID: <97d9b5$c3r$1@sapa.inka.de>
+References: <978v65$eao$1@marduk.litech.org> <9790d7$kji$1@allhats.xcski.com> <ylsnl3aml8.fsf@windlord.stanford.edu> <7wYl6lLmw-B@khms.westfalen.de>
+NNTP-Posting-Host: puric.inka.de
+X-Trace: sapa.inka.de 983181477 12411 212.227.14.17 (26 Feb 2001 09:57:57 GMT)
+X-Complaints-To: newsmaster@inka.de
+NNTP-Posting-Date: 26 Feb 2001 09:57:57 GMT
+User-Agent: tin/1.5.7-20001104 ("Paradise Regained") (UNIX) (Linux/2.0.36 (i686))
+Xref: wonderland.linux.it news.software.nntp:38417
+
+Kai Henningsen <kaih=7wYl6lLmw-B@khms.westfalen.de> wrote:
+> There really should be a standard distributed way of coping with them.
+
+I run the following script every hour. It relies on the presence of fuser on
+the system. Of course this doesn't help if your sending articles to a site
+(in newsfeeds) which isn't configured in innfeed.conf.
+
+#! /bin/sh
+ 
+# innfeed-undrop - requeues dropped articles
+#
+# 1-Apr-'99 sven
+#
+ 
+INNFEEDDIR=/news/spool/innfeed
+ 
+cd $INNFEEDDIR || exit 1
+ 
+# check, if innfeed-dropped files exist
+ls innfeed-dropped.* > /dev/null 2> /dev/null || exit 0
+for a in innfeed-dropped.*; do
+        # still in use?
+        if /bin/fuser $a > /dev/null; then
+                continue
+        fi
+        # distribute to the feeds
+        /news/bin/filechan -d $INNFEEDDIR -f 2 < $a && rm -f $a
+done
+
--- innfeed-0.10.1.7.orig/Makefile
+++ innfeed-0.10.1.7/Makefile
@@ -9,21 +9,21 @@
 # 
 
 # Where the programs get installed.
-BINDIR		= /usr/news/local
+BINDIR		= /usr/sbin
 
 # Where your man pages live.
 MANDIR		= /usr/local/man
 
 # The compiler you want. NOTE... AIX 3.2.5 users do NOT use CC. See the 
 # comment in sysconfig.h
-CC		= gcc
+CC		= cc
 
 # How to run lex and yacc. Innfeed requires Flex (but you shouldn't need it).
 LEX		= lex -d
 YACC		= yacc -t -d
 
 # Debug option for compiler -g or -O (or both if using gcc).
-DBFLAGS		= -g 
+DBFLAGS		= -g -O2
 
 # Add any architecture specific defines, flags etc. you need
 OSFLAGS		=
@@ -143,7 +143,7 @@
 
 LOADLIBES	= $(DMALLOC_LIB) $(LIBRARIES)
 
-VERSION		= 0.10.1
+VERSION		= 0.10.1.7-debian
 COMPRESS	= gzip
 COMPRESS_EXT	= gz
 TARSRC		= $(SRC) $(INCS) Makefile README INSTALL innfeed.conf \
--- innfeed-0.10.1.7.orig/config.h
+++ innfeed-0.10.1.7/config.h
@@ -43,7 +43,7 @@
 /* the path to the run-time config file. If relative, then relative to
    TAPE_DIRECTORY (or the value of the ``-b'' option). Overridden by ``-c''
    option. */
-#define CONFIG_FILE "/var/news/etc/innfeed.conf"
+#define CONFIG_FILE "/etc/news/innfeed.conf"
 
 
 /*
@@ -54,7 +54,7 @@
  */
 
 /* in tape.c */
-#define TAPE_DIRECTORY 	      "/var/news/spool/innfeed" /* backlog-directory */
+#define TAPE_DIRECTORY 	      "/var/spool/news/out.going/innfeed" /* backlog-directory */
 #define TAPE_HIGHWATER 		5 		/* backlog-highwater */
 #define TAPE_ROTATE_PERIOD 	60 		/* backlog-rotate-period */
 #define TAPE_CHECKPOINT_PERIOD 	30 		/* backlog-ckpt-period */
@@ -62,8 +62,8 @@
 #define TAPE_DISABLE		0		/* no-backlog */
 
 /* in main.c */
-#define NEWSSPOOL 		"/var/news/spool/articles" /* news-spool */
-#define PID_FILE 		"innfeed.pid" 	/* pid-file */
+#define NEWSSPOOL 		"/var/spool/news" /* news-spool */
+#define PID_FILE 		"/var/run/innd/innfeed.pid" 	/* pid-file */
 #define LOG_FILE 		"/var/log/news/innfeed.log" /* log-file */
 
 /* in host.c */
@@ -71,7 +71,7 @@
 #define DNS_EXPIRE_PERIOD 	86400 		/* dns-expire */
 #define CLOSE_PERIOD 		(60 * 60) 	/* close-period */
 #define GEN_HTML		0 		/* gen-html */
-#define INNFEED_STATUS 		"innfeed.status" /* status-file */
+#define INNFEED_STATUS 		"/var/log/news/innfeed.status" /* status-file */
 #define LOG_CONNECTION_STATS 	0 		/* connection-stats */
 #define HOST_HIGHWATER 		10 		/* host-highwater */
 #define STATS_PERIOD 		(60 * 10) 	/* stats-period */
--- innfeed-0.10.1.7.orig/innfeed.1
+++ innfeed-0.10.1.7/innfeed.1
@@ -14,7 +14,7 @@
 innfeed.conf
 ..
 .de
-.TH INNFEED 1
+.TH INNFEED 8 ""
 .\"
 .\"
 .\"
@@ -208,7 +208,7 @@
 Innfeed will catch SIGHUP and will reload the config file. 
 See innfeed.conf(5) for more details.
 .PP
-Innfeed will catch SIGEMT and will close and reopen all backlog files.
+Innfeed will catch SIGTTIN and will close and reopen all backlog files.
 .PP 
 Innfeed will catch SIGTERM and will do an orderly shutdown.
 .PP
@@ -259,7 +259,7 @@
 by it.
 .TP
 refused
-The number of articles offered to the host that it it indicated it
+The number of articles offered to the host that it indicated it
 didn't want because it had already seen the Message-ID.  The remote
 host indicates this by sending a 435 response to an IHAVE command or
 a 438 response to a CHECK command.
--- innfeed-0.10.1.7.orig/connection.c
+++ innfeed-0.10.1.7/connection.c
@@ -2257,7 +2257,7 @@
     }
   else
     {
-      syslog (LOG_WARNING, ARTICLE_TIMEOUT_MSG, peerName, cxn->ident) ;
+      syslog (LOG_NOTICE, ARTICLE_TIMEOUT_MSG, peerName, cxn->ident) ;
       cxn->state = cxnIdleTimeoutS ;
       cxnFlush (cxn) ;
     }
@@ -2983,7 +2983,9 @@
       cxn->checkRespHead = NULL ;
     }
 
-  if (cxn->articleQTotal == 0)
+  /* Some(?) hosts return the 436 response even before we're done
+      sending */
+  if (cxn->articleQTotal == 0 && !writeIsPending(cxn->myEp))
     cxnIdle (cxn) ;
   
   hostArticleDeferred (cxn->myHost, cxn, artHolder->article) ;
@@ -3032,7 +3034,9 @@
   artHolder = cxn->takeRespHead ;
   cxn->takeRespHead = NULL ;
 
-  if (cxn->articleQTotal == 0)
+  /* Some(?) hosts return the 437 response even before we're done
+      sending */
+  if (cxn->articleQTotal == 0 && !writeIsPending(cxn->myEp))
     cxnIdle (cxn) ;
 
   hostArticleRejected (cxn->myHost, cxn, artHolder->article) ;
