OSSP CVS Repository

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

Check-in Number: 1101
Date: 2001-Oct-08 15:21:58 (local)
2001-Oct-08 13:21:58 (UTC)
User:thl
Branch:
Comment: commit for getting rid of fd merger
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.65 -> 1.66     25 inserted, 6 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.65 -> 1.66

--- lmtp2nntp.c  2001/10/08 10:28:42     1.65
+++ lmtp2nntp.c  2001/10/08 13:21:58     1.66
@@ -199,12 +199,29 @@
 {
     lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
     ssize_t rc;
+    sa_rc_t saRc;
+    size_t bufdone;
 
-    rc = read(d, buf, nbytes);
+    log0(ctx, DEBUG, "trace_lmtp_read() begin");
+    if (ctx->saAltio == NULL) {
+        log0(ctx, DEBUG, "read()");
+        rc = read(d, buf, nbytes);
+    }
+    else {
+        log0(ctx, DEBUG, "saread()");
+        saRc = sa_read(ctx->saAltio, buf, nbytes, &bufdone);
+        if (saRc != SA_OK) {
+            log1(ctx, DEBUG, "LMTP saread error: %d", saRc);
+            rc = -1;
+        }
+        else
+            rc = (ssize_t)bufdone;
+    }
     if (rc == -1)
         log0(ctx, TRACE, "LMTP read error: %m");
     else
         log3(ctx, TRACE, "LMTP %5d << \"%{text}D\"", rc, buf, rc);
+    log1(ctx, DEBUG, "trace_lmtp_read() return, rc=%d", rc);
     return rc;
 }
 
@@ -290,6 +307,7 @@
             log1(ctx, NOTICE, "caught signal %d - wait for child", sig);
             pid = wait(NULL);
             log2(ctx, NOTICE, "caught signal %d - child [%ld] terminated", sig, (long)pid);
+            l2_stream_flush(ctx->l2);
             return;
         } else
             log1(ctx, PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig);
@@ -383,7 +401,7 @@
                     fprintf(stderr, "%s:Error: Creating address failed for -i option (%d)\n", 
                             ctx->progname, rc);
                 }
-                if ((rc = sa_addr_u2a(ctx->saaAltio, "%s", optarg)) != SA_OK) {
+                if ((rc = sa_addr_u2a(ctx->saaAltio, "inet://%s", optarg)) != SA_OK) {
                     fprintf(stderr, "%s:Error: Parsing inputbind address failed for \"%s\" (%d)\n", 
                             ctx->progname, optarg, rc);
                     CU(ERR_EXECUTION);
@@ -417,7 +435,7 @@
                     fprintf(stderr, "%s:Error: Creating address failed for -b option (%d)\n", 
                             ctx->progname, rc);
                 }
-                if ((rc = sa_addr_u2a(ctx->saaBind, "tcp://%s:%s", ctx->cpBindh, ctx->cpBindp)) != SA_OK) {
+                if ((rc = sa_addr_u2a(ctx->saaBind, "inet://%s:%s", ctx->cpBindh, ctx->cpBindp)) != SA_OK) {
                     fprintf(stderr, "%s:Error: Parsing bind address failed for \"%s:%s\" (%d)\n", 
                             ctx->progname, ctx->cpBindh, ctx->cpBindp, rc);
                     CU(ERR_EXECUTION);
@@ -497,7 +515,7 @@
                         fprintf(stderr, "%s:Error: Creating address failed for -h option (%d)\n", 
                             ctx->progname, rc);
                     }
-                    if ((rc = sa_addr_u2a(ctx->ns[ctx->nsc].saa, "tcp://%s:%s", 
+                    if ((rc = sa_addr_u2a(ctx->ns[ctx->nsc].saa, "inet://%s:%s", 
                                      ctx->ns[ctx->nsc].h, ctx->ns[ctx->nsc].p)) != SA_OK) {
                         fprintf(stderr, "%s:Error: Parsing host address failed for \"%s:%s\" (%d)\n", 
                                 ctx->progname, ctx->ns[ctx->nsc].h, ctx->ns[ctx->nsc].p, rc);
@@ -720,6 +738,8 @@
         pid = getpid();
         daemonize();
         log1(ctx, NOTICE, "startup daemonized, previous pid[%d]", pid); l2_stream_flush(ctx->l2);
+        //FIXME sa_timeout(ctx->saAltio, SA_TIMEOUT_ALL,    3, 0);
+        sa_timeout(ctx->saAltio, SA_TIMEOUT_ACCEPT, 0, 0);
         while ((rc = sa_accept(ctx->saAltio, &caddr, &csa)) == SA_OK) {
             sa_getfd(csa, &fd);
             l2_stream_flush(ctx->l2); /* must flush before fork() */
@@ -735,7 +755,6 @@
             }
             log1(ctx, NOTICE, "startup new child process, parent pid[%d]", getppid());
             
-            fprintf(stderr, "DEBUG: fd=%d\n", fd);
             /* initialize LMTP context */
             lmtp_io.ctx    = ctx;
             lmtp_io.select = NULL;
@@ -908,7 +927,7 @@
 
         if (bOk && (ctx->option_waittime > 0)) {
             log1(ctx, DEBUG, "timeout configured through waittime=%d", ctx->option_waittime);
-            sa_timeout(ctx->ns[i].sa, ctx->option_waittime, 0);
+            sa_timeout(ctx->ns[i].sa, SA_TIMEOUT_ALL, ctx->option_waittime, 0);
             }
 
         if (bOk) {

CVSTrac 2.0.1