smtp_server_connection_next_reply(struct smtp_server_connection *conn)
{
struct smtp_server_command *cmd;
- const char *error = NULL;
unsigned int i;
cmd = conn->command_queue_head;
cmd->state = SMTP_SERVER_COMMAND_STATE_PROCESSING;
break;
}
- if (smtp_server_reply_send(reply, &error) < 0) {
- if (error != NULL) {
- smtp_server_connection_error(conn,
- "Failed to send reply: %s", error);
- smtp_server_connection_close(&conn,
- "Write failure");
- } else {
- smtp_server_connection_debug(conn,
- "Failed to send reply: "
- "Remote disconnected");
- smtp_server_connection_close(&conn,
- "Remote closed connection");
- }
+ if (smtp_server_reply_send(reply) < 0)
return FALSE;
- }
}
if (cmd->state == SMTP_SERVER_COMMAND_STATE_PROCESSING)
return FALSE;
void smtp_server_reply_free(struct smtp_server_command *cmd);
-int smtp_server_reply_send(struct smtp_server_reply *resp,
- const char **error_r);
+int smtp_server_reply_send(struct smtp_server_reply *resp);
const char *smtp_server_reply_get_one_line(struct smtp_server_reply *reply);
return str_c(str);
}
-static int smtp_server_reply_send_real(struct smtp_server_reply *reply,
- const char **error_r)
+static int smtp_server_reply_send_real(struct smtp_server_reply *reply)
{
struct smtp_server_command *cmd = reply->command;
struct smtp_server_connection *conn = cmd->context.conn;
char *text;
int ret = 0;
- *error_r = NULL;
-
i_assert(reply->content != NULL);
textbuf = reply->content->text;
i_assert(str_len(textbuf) > 0);
}
if (o_stream_send(output, str_data(textbuf), str_len(textbuf)) < 0) {
- if (output->stream_errno != EPIPE &&
- output->stream_errno != ECONNRESET) {
- *error_r = t_strdup_printf("write(%s) failed: %s",
- o_stream_get_name(output),
- o_stream_get_error(output));
- }
- ret = -1;
+ smtp_server_connection_handle_output_error(conn);
+ return -1;
}
if (set->debug) {
return ret;
}
-int smtp_server_reply_send(struct smtp_server_reply *reply,
- const char **error_r)
+int smtp_server_reply_send(struct smtp_server_reply *reply)
{
int ret;
return 0;
T_BEGIN {
- ret = smtp_server_reply_send_real(reply, error_r);
+ ret = smtp_server_reply_send_real(reply);
} T_END;
reply->sent = TRUE;