]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lda: Added smtp_client_abort()
authorTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2014 09:02:21 +0000 (12:02 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2014 09:02:21 +0000 (12:02 +0300)
src/lib-lda/smtp-client.c
src/lib-lda/smtp-client.h

index 08be256b8dd033aee56f742d23de39eacbd55a0f..6d0536ff2d94b6727e8c21b1aca2adb62607b7eb 100644 (file)
@@ -324,6 +324,23 @@ smtp_client_send_flush(struct smtp_client *smtp_client, const char **error_r)
        }
 }
 
+void smtp_client_abort(struct smtp_client **_client)
+{
+       struct smtp_client *client = *_client;
+
+       *_client = NULL;
+
+       o_stream_ignore_last_errors(client->output);
+       if (!client->use_smtp) {
+               if (client->pid != (pid_t)-1)
+                       (void)kill(client->pid, SIGTERM);
+               (void)smtp_client_deinit_sendmail(client);
+       } else {
+               o_stream_destroy(&client->output);
+               pool_unref(&client->pool);
+       }
+}
+
 int smtp_client_deinit(struct smtp_client *client, const char **error_r)
 {
        int ret;
@@ -339,8 +356,7 @@ int smtp_client_deinit(struct smtp_client *client, const char **error_r)
        /* the mail has been written to a file. now actually send it. */
        ret = smtp_client_send_flush(client, error_r);
 
-       o_stream_destroy(&client->output);
-       pool_unref(&client->pool);
+       smtp_client_abort(&client);
        return ret;
 }
 
index e4ec1a3a63064febec014bb3f9a3ea8be2b45f6b..cb35e627f0c31c948770732ce3d731baf7ce4846 100644 (file)
@@ -8,6 +8,7 @@ void smtp_client_add_rcpt(struct smtp_client *client, const char *address);
 /* Get an output stream where the message can be written to. The recipients
    must already be added before calling this. */
 struct ostream *smtp_client_send(struct smtp_client *client);
+void smtp_client_abort(struct smtp_client **client);
 /* Returns 1 on success, 0 on permanent failure (e.g. invalid destination),
    -1 on temporary failure. */
 int smtp_client_deinit(struct smtp_client *client, const char **error_r);