From d2aa036bf831a28b2e0208e6b8385eeb5453cd39 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 2 Apr 2017 12:12:56 +0100 Subject: [PATCH] tidying --- src/src/structs.h | 3 +-- src/src/transport.c | 23 +++++++++++++---------- src/src/transports/smtp.c | 15 +++++++++++---- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/src/structs.h b/src/src/structs.h index 38b095f06..60e7ccd9d 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -230,8 +230,7 @@ typedef struct transport_info { #define tc_chunk_last BIT(1) /* annotate chunk SMTP cmd as LAST */ struct transport_context; -typedef int (*tpt_chunk_cmd_cb)(int fd, struct transport_context * tctx, - unsigned len, unsigned flags); +typedef int (*tpt_chunk_cmd_cb)(struct transport_context *, unsigned, unsigned); /* Structure for information about a delivery-in-progress */ diff --git a/src/src/transport.c b/src/src/transport.c index 1a53690cc..974b786ad 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -435,9 +435,9 @@ for (ptr = start; ptr < end; ptr++) if (tctx && tctx->options & topt_use_bdat && tctx->chunk_cb) { - if ( tctx->chunk_cb(fd, tctx, (unsigned)len, 0) != OK + if ( tctx->chunk_cb(tctx, (unsigned)len, 0) != OK || !transport_write_block(fd, deliver_out_buffer, len) - || tctx->chunk_cb(fd, tctx, 0, tc_reap_prev) != OK + || tctx->chunk_cb(tctx, 0, tc_reap_prev) != OK ) return FALSE; } @@ -979,20 +979,20 @@ if (tctx->options & topt_use_bdat) { DEBUG(D_transport) debug_printf("sending small initial BDAT; hsize=%d\n", hsize); - if ( tctx->chunk_cb(fd, tctx, hsize, 0) != OK + if ( tctx->chunk_cb(tctx, hsize, 0) != OK || !transport_write_block(fd, deliver_out_buffer, hsize) - || tctx->chunk_cb(fd, tctx, 0, tc_reap_prev) != OK + || tctx->chunk_cb(tctx, 0, tc_reap_prev) != OK ) return FALSE; chunk_ptr = deliver_out_buffer; size -= hsize; } - /* Emit a LAST datachunk command. */ + /* Emit a LAST datachunk command, and unmark the context for further + BDAT commands. */ - if (tctx->chunk_cb(fd, tctx, size, tc_chunk_last) != OK) + if (tctx->chunk_cb(tctx, size, tc_chunk_last) != OK) return FALSE; - tctx->options &= ~topt_use_bdat; } @@ -1141,15 +1141,18 @@ if (options & topt_use_bdat) if (siglen + k_file_size > DELIVER_OUT_BUFFER_SIZE && siglen > 0) { - if ( tctx->chunk_cb(out_fd, tctx, siglen, 0) != OK + if ( tctx->chunk_cb(tctx, siglen, 0) != OK || !transport_write_block(out_fd, dkim_signature, siglen) - || tctx->chunk_cb(out_fd, tctx, 0, tc_reap_prev) != OK + || tctx->chunk_cb(tctx, 0, tc_reap_prev) != OK ) goto err; siglen = 0; } - if (tctx->chunk_cb(out_fd, tctx, siglen + k_file_size, tc_chunk_last) != OK) + /* Send the BDAT command for the entire message, as a single LAST-marked + chunk. */ + + if (tctx->chunk_cb(tctx, siglen + k_file_size, tc_chunk_last) != OK) goto err; } diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index c4626b3e9..0bfab5388 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1347,15 +1347,22 @@ return checks; If given a nonzero size, first flush any buffered SMTP commands then emit the command. -Reap previous SMTP command responses if requested. -Reap one SMTP command response if requested. +Reap previous SMTP command responses if requested, and always reap +the response from a previous BDAT command. + +Args: + tctx transport context + chunk_size value for SMTP BDAT command + flags + tc_chunk_last add LAST option to SMTP BDAT command + tc_reap_prev reap response to previous SMTP commands Returns: OK or ERROR */ static int -smtp_chunk_cmd_callback(int fd, transport_ctx * tctx, - unsigned chunk_size, unsigned flags) +smtp_chunk_cmd_callback(transport_ctx * tctx, unsigned chunk_size, + unsigned flags) { smtp_transport_options_block * ob = (smtp_transport_options_block *)(tctx->tblock->options_block); -- 2.30.2