]> diplodocus.org Git - mdeliver/commitdiff
Ouch, was bombing when talking to spamd failed for any reason, leaving
authorepg <>
Wed, 19 Apr 2006 19:41:22 +0000 (19:41 +0000)
committerepg <>
Wed, 19 Apr 2006 19:41:22 +0000 (19:41 +0000)
messages in mdp.  spamd failures aren't hard failures, just consider
messages where that happens not to be spam.

processor.c

index 2c015c68e69a465219c6435e5a99bce9bd85a7dd..2ebca536c55d825cca02c8522b8fd5f42c4911ce 100644 (file)
@@ -28,6 +28,8 @@ static int flags = SPAMC_CHECK_ONLY | SPAMC_RAW_MODE;
 
 #define err(n, ...) _err(n, true, __FILE__, __LINE__, __VA_ARGS__)
 #define errx(n, ...) _err(n, false, __FILE__, __LINE__, __VA_ARGS__)
+#define warn(...) _err(0, true, __FILE__, __LINE__, __VA_ARGS__)
+#define warnx(...) _err(0, false, __FILE__, __LINE__, __VA_ARGS__)
 
 void
 _err(int exitcode, bool want_strerror, char *fn, int lineno, char *format, ...)
@@ -95,7 +97,7 @@ logname()
     return p->pw_name;
 }
 
-static void
+static bool
 get_transport(struct transport *t)
 {
     int status;
@@ -106,11 +108,14 @@ get_transport(struct transport *t)
     t->port = T_PORT;
 
     if ((status = transport_setup(t, 0)) != EX_OK) {
-        errx(status, "transport_setup");
+        warnx("non-fatal: transport_setup");
+        return false;
     }
+
+    return true;
 }
 
-static void
+static bool
 get_message(char *fn, struct message *m)
 {
     int fd;
@@ -127,8 +132,11 @@ get_message(char *fn, struct message *m)
     }
 
     if ((status = message_read(fd, flags, m)) != EX_OK) {
-        errx(status, "message_read");
+        warnx("non-fatal: message_read");
+        return false;
     }
+
+    return true;
 }
 
 static bool
@@ -138,11 +146,16 @@ is_spam(char *message)
     struct message m;
     int status;
 
-    get_transport(&t);
-    get_message(message, &m);
+    if (!get_transport(&t)) {
+        return false;
+    }
+    if (!get_message(message, &m)) {
+        return false;
+    }
 
     if ((status = message_filter(&t, logname(), flags, &m)) != EX_OK) {
-        errx(status, "message_filter");
+        warnx("non-fatal: message_filter");
+        return false;
     }
 
     if (m.is_spam == EX_ISSPAM) {
@@ -151,8 +164,7 @@ is_spam(char *message)
         return false;
     }
 
-    errx(m.is_spam, "message_filter");
-    /*NOTREACHED*/
+    warnx("non-fatal: message_filter returned %d", m.is_spam);
     return false;
 }
 
@@ -164,6 +176,7 @@ process(char *tmp)
     /* 5 for spam/ and 1 for terminating null */
     char *new = malloc(len + 5 + 1);
 
+    /* Nothing to do about a malloc failure but dump core. */
     strcpy(errfn, "err");
     strcat(errfn, tmp + 3);