INN commit: trunk (include/nntp.h innd/nc.c)

INN Commit rra at isc.org
Sun Nov 8 12:27:29 UTC 2009


    Date: Sunday, November 8, 2009 @ 04:27:29
  Author: iulius
Revision: 8720

When XBATCH answers 501, it is because of an invalid size,
not a missing size (the new parser takes care of it before
calling XBATCH).

Modified:
  trunk/include/nntp.h
  trunk/innd/nc.c

----------------+
 include/nntp.h |   10 ----------
 innd/nc.c      |   34 +++++++++++++++++++++-------------
 2 files changed, 21 insertions(+), 23 deletions(-)

Modified: include/nntp.h
===================================================================
--- include/nntp.h	2009-11-08 10:54:53 UTC (rev 8719)
+++ include/nntp.h	2009-11-08 12:27:29 UTC (rev 8720)
@@ -46,13 +46,3 @@
 **  MODE CANCEL extension.
 */
 #define NNTP_OK_CANCELLED       "289"
-
-/*
-**  XBATCH feed extension.
-*/
-#define NNTP_OK_XBATCHED	"239"
-#define NNTP_CONT_XBATCH_STR	"339"
-/* and one more meaning for the 436 code NNTP_FAIL_IHAVE_DEFER */
-#define NNTP_RESENDIT_XBATCHERR	"436 xbatch failed: "
-/* and one more meaning for the 501 code NNTP_SYNTAX_USE */
-#define NNTP_XBATCH_BADSIZE	"501 Invalid or missing size for xbatch"

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2009-11-08 10:54:53 UTC (rev 8719)
+++ innd/nc.c	2009-11-08 12:27:29 UTC (rev 8720)
@@ -730,6 +730,8 @@
 static void
 NCxbatch(CHANNEL *cp)
 {
+    char *buff = NULL;
+
     cp->Start = cp->Next;
 
     if (cp->XBatchSize) {
@@ -745,15 +747,19 @@
     if (cp->XBatchSize <= 0 || ((innconf->maxartsize != 0) &&
                                 (innconf->maxartsize < (unsigned long) cp->XBatchSize))) {
         syslog(L_NOTICE, "%s got bad xbatch size %d",
-	       CHANname(cp), cp->XBatchSize);
-	NCwritereply(cp, NNTP_XBATCH_BADSIZE);
-	return;
+               CHANname(cp), cp->XBatchSize);
+        xasprintf(&buff, "%d Invalid size for XBATCH", NNTP_ERR_SYNTAX);
+        NCwritereply(cp, buff);
+        free(buff);
+        return;
     }
 
     /* We prefer not to touch the buffer; NCreader() does enough magic
      * with it. */
     cp->State = CSgetxbatch;
-    NCwritereply(cp, NNTP_CONT_XBATCH_STR);
+    xasprintf(&buff, "%d Send batch", NNTP_CONT_XBATCH);
+    NCwritereply(cp, buff);
+    free(buff);
 }
 
 /*
@@ -1450,16 +1456,16 @@
 	  failed = 1;
 	  syslog(L_ERROR, "%s cannot open outfile %s for xbatch: %m",
 	    CHANname(cp), buff);
-	  snprintf(buff, sizeof(buff), "%s cant create file: %s",
-                   NNTP_RESENDIT_XBATCHERR, strerror(oerrno));
+          snprintf(buff, sizeof(buff), "%d XBATCH failed -- cant create file: %s",
+                   NNTP_FAIL_XBATCH, strerror(oerrno));
 	  NCwritereply(cp, buff);
 	} else {
 	  if (write(fd, cp->In.data, cp->XBatchSize) != cp->XBatchSize) {
 	    oerrno = errno;
 	    syslog(L_ERROR, "%s cant write batch to file %s: %m", CHANname(cp),
 	      buff);
-	    snprintf(buff, sizeof(buff), "%s cant write batch to file: %s",
-                     NNTP_RESENDIT_XBATCHERR, strerror(oerrno));
+            snprintf(buff, sizeof(buff), "%d XBATCH failed -- cant write batch to file: %s",
+                     NNTP_FAIL_XBATCH, strerror(oerrno));
 	    NCwritereply(cp, buff);
 	    failed = 1;
 	  }
@@ -1468,8 +1474,8 @@
 	  oerrno = errno;
 	  syslog(L_ERROR, "%s error closing batch file %s: %m", CHANname(cp),
 	    failed ? "" : buff);
-	  snprintf(buff, sizeof(buff), "%s error closing batch file: %s",
-                   NNTP_RESENDIT_XBATCHERR, strerror(oerrno));
+          snprintf(buff, sizeof(buff), "%d XBATCH failed -- error closing batch file: %s",
+                   NNTP_FAIL_XBATCH, strerror(oerrno));
 	  NCwritereply(cp, buff);
 	  failed = 1;
 	}
@@ -1479,14 +1485,16 @@
 	  oerrno = errno;
 	  syslog(L_ERROR, "%s cant rename %s to %s: %m", CHANname(cp),
 	    failed ? "" : buff, buff2);
-	  snprintf(buff, sizeof(buff), "%s cant rename batch to %s: %s",
-                   NNTP_RESENDIT_XBATCHERR, buff2, strerror(oerrno));
+          snprintf(buff, sizeof(buff), "%d XBATCH failed -- cant rename batch to %s: %s",
+                   NNTP_FAIL_XBATCH, buff2, strerror(oerrno));
 	  NCwritereply(cp, buff);
 	  failed = 1;
 	}
 	cp->Reported++;
 	if (!failed) {
-	  NCwritereply(cp, NNTP_OK_XBATCHED);
+          snprintf(buff, sizeof(buff), "%d Batch transferred OK",
+                   NNTP_OK_XBATCH);
+          NCwritereply(cp, buff);
 	  cp->Received++;
 	} else {
           /* Only reject, no call to ARTlog() because it will not be




More information about the inn-committers mailing list