Another diagnostics patch to libmilter. This one will also log I/O errors it encounters.

This will (hopefully) determine whether or not the descriptor connecting the filter to the MTA is being prematurely closed and, if so, which end is doing it.

Jukka, if you're still out there and willing, please give this one a try.
Index: comm.c
===================================================================
RCS file: /cvs/libmilter/comm.c,v
retrieving revision 8.67
diff -u -r8.67 comm.c
--- comm.c      2 Nov 2006 17:54:44 -0000       8.67
+++ comm.c      21 May 2008 18:16:28 -0000
@@ -133,7 +133,10 @@
        (void) memcpy((void *) &expl, (void *) &(data[0]), MILTER_LEN_BYTES);
        expl = ntohl(expl) - 1;
        if (expl <= 0)
+       {
+               smi_log(SMI_LOG_INFO, "mi_rd_cmd(%d) on fd %d", *cmd, sd);
                return NULL;
+       }
        if (expl > Maxdatasize)
        {
                *cmd = SMFIC_TOOBIG;
@@ -197,6 +200,10 @@
                        /* makes life simpler for common string routines */
                        buf[expl] = '\0';
 #endif /* _FFR_ADD_NULL */
+
+                       smi_log(SMI_LOG_INFO, "mi_rd_cmd(%d) on fd %d", *cmd,
+                               sd);
+
                        return buf;
                }
                i += len;
@@ -353,6 +360,8 @@
                iovcnt = 2;
        }
 
+       smi_log(SMI_LOG_INFO, "mi_wr_cmd(%d) on fd %d", cmd, sd);
+
        l = retry_writev(sd, iov, iovcnt, timeout);
        if (l == MI_FAILURE)
                return MI_FAILURE;
Index: engine.c
===================================================================
RCS file: /cvs/libmilter/engine.c,v
retrieving revision 8.162
diff -u -r8.162 engine.c
--- engine.c    27 Feb 2008 01:34:14 -0000      8.162
+++ engine.c    21 May 2008 18:16:28 -0000
@@ -648,6 +648,8 @@
                }
        }
 
+       errno = 0;
+
        switch (r)
        {
          case SMFIS_CONTINUE:
@@ -718,9 +720,23 @@
                                        0);
                }
                break;
+         case _SMFIS_KEEP:
+         case _SMFIS_FAIL:
+               break;
          default:      /* don't send a reply */
+               smi_log(SMI_LOG_ERR,
+                       "%s: milter returned bogus status %d in state %d\n",
+                       ctx->ctx_smfi->xxfi_name, r, ctx->ctx_state);
                break;
        }
+
+       if (ret == MI_FAILURE)
+       {
+               smi_log(SMI_LOG_ERR,
+                       "%s: mi_wr_cmd(reply code %d) on fd %d failed, errno = 
%d",
+                       ctx->ctx_smfi->xxfi_name, r, sd, errno);
+       }
+
        return ret;
 }
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dkim-milter-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dkim-milter-discuss

Reply via email to