Skip to content

Commit

Permalink
lmtp: Moved rcpt_anvil_lookup_callback() from commands.c to lmtp-loca…
Browse files Browse the repository at this point in the history
…l.c.
  • Loading branch information
stephanbosch committed Dec 7, 2017
1 parent 1d2e367 commit a3259cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
31 changes: 0 additions & 31 deletions src/lmtp/commands.c
Expand Up @@ -388,37 +388,6 @@ static bool client_proxy_rcpt(struct client *client,
return TRUE;
}

static void rcpt_anvil_lookup_callback(const char *reply, void *context)
{
struct mail_recipient *rcpt = context;
struct client *client = rcpt->client;
const struct mail_storage_service_input *input;
unsigned int parallel_count = 0;

rcpt->anvil_query = NULL;
if (reply == NULL) {
/* lookup failed */
} else if (str_to_uint(reply, &parallel_count) < 0) {
i_error("Invalid reply from anvil: %s", reply);
}

if (parallel_count >= client->lmtp_set->lmtp_user_concurrency_limit) {
client_send_line(client, ERRSTR_TEMP_USERDB_FAIL_PREFIX
"Too many concurrent deliveries for user",
smtp_address_encode(rcpt->address));
mail_storage_service_user_unref(&rcpt->service_user);
} else if (cmd_rcpt_finish(client, rcpt)) {
rcpt->anvil_connect_sent = TRUE;
input = mail_storage_service_user_get_input(rcpt->service_user);
master_service_anvil_send(master_service, t_strconcat(
"CONNECT\t", my_pid, "\t", master_service_get_name(master_service),
"/", input->username, "\n", NULL));
}

client_io_reset(client);
client_input_handle(client);
}

int cmd_rcpt(struct client *client, const char *args)
{
struct mail_recipient *rcpt;
Expand Down
32 changes: 32 additions & 0 deletions src/lmtp/lmtp-local.c
Expand Up @@ -14,6 +14,7 @@
#include "lmtp-local.h"

#define ERRSTR_TEMP_MAILBOX_FAIL "451 4.3.0 <%s> Temporary internal error"
#define ERRSTR_TEMP_USERDB_FAIL_PREFIX "451 4.3.0 <%s> "

void client_rcpt_anvil_disconnect(const struct mail_recipient *rcpt)
{
Expand Down Expand Up @@ -109,3 +110,34 @@ bool cmd_rcpt_finish(struct client *client, struct mail_recipient *rcpt)
client_send_line(client, "250 2.1.5 OK");
return TRUE;
}

void rcpt_anvil_lookup_callback(const char *reply, void *context)
{
struct mail_recipient *rcpt = context;
struct client *client = rcpt->client;
const struct mail_storage_service_input *input;
unsigned int parallel_count = 0;

rcpt->anvil_query = NULL;
if (reply == NULL) {
/* lookup failed */
} else if (str_to_uint(reply, &parallel_count) < 0) {
i_error("Invalid reply from anvil: %s", reply);
}

if (parallel_count >= client->lmtp_set->lmtp_user_concurrency_limit) {
client_send_line(client, ERRSTR_TEMP_USERDB_FAIL_PREFIX
"Too many concurrent deliveries for user",
smtp_address_encode(rcpt->address));
mail_storage_service_user_unref(&rcpt->service_user);
} else if (cmd_rcpt_finish(client, rcpt)) {
rcpt->anvil_connect_sent = TRUE;
input = mail_storage_service_user_get_input(rcpt->service_user);
master_service_anvil_send(master_service, t_strconcat(
"CONNECT\t", my_pid, "\t", master_service_get_name(master_service),
"/", input->username, "\n", NULL));
}

client_io_reset(client);
client_input_handle(client);
}
2 changes: 2 additions & 0 deletions src/lmtp/lmtp-local.h
Expand Up @@ -11,4 +11,6 @@ void client_send_line_overquota(struct client *client,

bool cmd_rcpt_finish(struct client *client, struct mail_recipient *rcpt);

void rcpt_anvil_lookup_callback(const char *reply, void *context);

#endif

0 comments on commit a3259cc

Please sign in to comment.