Skip to content

Commit

Permalink
submission: Move relay part of RSET command to submission-backend-rel…
Browse files Browse the repository at this point in the history
…ay.c.
  • Loading branch information
stephanbosch authored and villesavolainen committed Feb 12, 2019
1 parent 85ad60b commit 353f551
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/submission/Makefile.am
Expand Up @@ -35,7 +35,6 @@ submission_DEPENDENCIES = \

cmds = \
cmd-data.c \
cmd-rset.c \
cmd-noop.c \
cmd-quit.c \
cmd-vrfy.c
Expand Down
49 changes: 0 additions & 49 deletions src/submission/cmd-rset.c

This file was deleted.

42 changes: 42 additions & 0 deletions src/submission/submission-backend-relay.c
Expand Up @@ -381,3 +381,45 @@ int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
return 0;
}

/*
* RSET command
*/

struct cmd_rset_context {
struct client *client;
struct smtp_server_cmd_ctx *cmd;

struct smtp_client_command *cmd_proxied;
};

static void cmd_rset_proxy_cb(const struct smtp_reply *proxy_reply,
struct cmd_rset_context *rset_cmd)
{
struct smtp_server_cmd_ctx *cmd = rset_cmd->cmd;
struct client *client = rset_cmd->client;
struct smtp_reply reply;

/* finished proxying MAIL command to relay server */
i_assert(rset_cmd != NULL);
rset_cmd->cmd_proxied = NULL;

if (!client_command_handle_proxy_reply(client, proxy_reply, &reply))
return;

/* forward reply */
smtp_server_reply_forward(cmd, &reply);
}

int cmd_rset_relay(struct client *client, struct smtp_server_cmd_ctx *cmd)
{
struct cmd_rset_context *rset_cmd;

rset_cmd = p_new(cmd->pool, struct cmd_rset_context, 1);
rset_cmd->cmd = cmd;
rset_cmd->client = client;

rset_cmd->cmd_proxied = smtp_client_command_rset_submit
(client->proxy_conn, 0, cmd_rset_proxy_cb, rset_cmd);
return 0;
}

1 change: 1 addition & 0 deletions src/submission/submission-backend-relay.h
Expand Up @@ -7,5 +7,6 @@ int cmd_mail_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_mail *data);
int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_cmd_rcpt *data);
int cmd_rset_relay(struct client *client, struct smtp_server_cmd_ctx *cmd);

#endif
1 change: 0 additions & 1 deletion src/submission/submission-commands.h
Expand Up @@ -4,7 +4,6 @@
bool client_command_handle_proxy_reply(struct client *client,
const struct smtp_reply *reply, struct smtp_reply *reply_r);

int cmd_rset_relay(struct client *client, struct smtp_server_cmd_ctx *cmd);
int cmd_data_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
struct smtp_server_transaction *trans,
struct istream *data_input);
Expand Down

0 comments on commit 353f551

Please sign in to comment.