OSSP CVS Repository

ossp - Check-in [3137]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3137
Date: 2003-Feb-03 16:26:03 (local)
2003-Feb-03 15:26:03 (UTC)
User:thl
Branch:
Comment: handle/log failed NNTP connections; retry all of them every time
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.62 -> 1.63     11 inserted, 13 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.62 -> 1.63

--- lmtp2nntp_main.c     2003/01/30 19:45:20     1.62
+++ lmtp2nntp_main.c     2003/02/03 15:26:03     1.63
@@ -775,6 +775,7 @@
     char         str[STDSTRLEN];
     int          bOk;
     int          i;
+    int          is;
     nntp_io_t    nntp_io;
 
     logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing LHLO command < %s", req->msg);
@@ -822,6 +823,7 @@
     if (ctx->option_operationmode == OPERATIONMODE_FAKE)
         logbook(ctx->l2, L2_LEVEL_NOTICE, "NNTP running in fake mode, network connections will be executed but result is ignored");
     i = 0;
+    is = 0;
     do {
         logbook(ctx->l2, L2_LEVEL_DEBUG, "trying ns[%d]", i);
         bOk = TRUE;
@@ -871,24 +873,18 @@
 
         if (bOk) {
             logbook(ctx->l2, L2_LEVEL_INFO, "NNTP session to ${option.destination[%d]} successfully established", i);
-            i++;
+            is++;
         }
         else {
             logbook(ctx->l2, L2_LEVEL_WARNING, "NNTP session establishment to ${option.destination[%d]} failed", i);
-            logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME-CURRENTLY-NOT removing ns[%d] from list", i);
             lmtp_gfs_ns(&ctx->pns[i]);
-            /*FIXME #1 this code is a leftover from the static ns array with nsc counter
-              FIXME #2 this code removes the newsservice forever!? What is the scope, what should the scope be - gateway, child process, session, posting lifetime? What is the intention of the user?
-            if (i < --ctx->nns) {
-                memcpy(&ctx->pns[i], &ctx->pns[i+1], (ctx->nns - i ) * sizeof(struct ns));
-            }
-            */
-            i++; /* FIXME this is just to avoid infinite loop */
         }
+        i++;
     } while (i < ctx->nns);
+    logbook(ctx->l2, L2_LEVEL_INFO, "NNTP network connections tried %d, successful %d", i, is);
 
     if (ctx->option_operationmode == OPERATIONMODE_FAKE)
-        logbook(ctx->l2, L2_LEVEL_NOTICE, "NNTP running in fake mode, network connections successfully established=%d but ignored", ctx->nns);
+        logbook(ctx->l2, L2_LEVEL_NOTICE, "NNTP running in fake mode, ignoring status of real network connections");
     else
     {
         /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   421 <domain> Service not available
@@ -896,7 +892,7 @@
          *  RFC1893 3.5 Network and Routing Status          X.4.1   No answer from host
          */
         logbook(ctx->l2, L2_LEVEL_DEBUG, "check if at least one NNTP session successfully established");
-        if (ctx->nns == 0) {
+        if (is == 0) {
             logbook(ctx->l2, L2_LEVEL_ERROR, "no NNTP session established");
             res.statuscode = "421";
             res.dsncode    = "4.4.1";
@@ -1545,10 +1541,12 @@
                 ctx->pns[i].rc = NNTP_FAKE;
                 break;
             case OPERATIONMODE_POST:
-                ctx->pns[i].rc = nntp_post(ctx->pns[i].nntp, ctx->msg);
+                if (ctx->pns[i].nntp)
+                    ctx->pns[i].rc = nntp_post(ctx->pns[i].nntp, ctx->msg);
                 break;
             case OPERATIONMODE_FEED:
-                ctx->pns[i].rc = nntp_feed(ctx->pns[i].nntp, ctx->msg);
+                if (ctx->pns[i].nntp)
+                    ctx->pns[i].rc = nntp_feed(ctx->pns[i].nntp, ctx->msg);
                 break;
         }
         if (ctx->pns[i].rc == NNTP_OK)

CVSTrac 2.0.1