Skip to content

Commit

Permalink
submission: Implement basic client vfuncs.
Browse files Browse the repository at this point in the history
Currently, only client_destroy can be overriden.
  • Loading branch information
stephanbosch authored and cmouse committed Oct 11, 2018
1 parent abd6484 commit 79e4f34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/submission/submission-client.c
Expand Up @@ -41,11 +41,12 @@
/* Disconnect client after idling this many milliseconds */
#define CLIENT_IDLE_TIMEOUT_MSECS (10*60*1000)

static const struct smtp_server_callbacks smtp_callbacks;
static const struct submission_client_vfuncs submission_client_vfuncs;

struct client *submission_clients;
unsigned int submission_client_count;

static const struct smtp_server_callbacks smtp_callbacks;

static void client_input_pre(void *context)
{
struct client *client = context;
Expand Down Expand Up @@ -195,6 +196,7 @@ struct client *client_create(int fd_in, int fd_out,
pool = pool_alloconly_create("submission client", 2048);
client = p_new(pool, struct client, 1);
client->pool = pool;
client->v = submission_client_vfuncs;
client->user = user;
client->service_user = service_user;
client->set = set;
Expand Down Expand Up @@ -277,6 +279,13 @@ static void client_state_reset(struct client *client)

void client_destroy(struct client *client, const char *prefix,
const char *reason)
{
client->v.destroy(client, prefix, reason);
}

static void
client_default_destroy(struct client *client, const char *prefix,
const char *reason)
{
if (client->destroyed)
return;
Expand Down Expand Up @@ -508,3 +517,7 @@ static const struct smtp_server_callbacks smtp_callbacks = {
.conn_disconnect = client_connection_disconnect,
.conn_destroy = client_connection_destroy,
};

static const struct submission_client_vfuncs submission_client_vfuncs = {
client_default_destroy,
};
8 changes: 7 additions & 1 deletion src/submission/submission-client.h
Expand Up @@ -17,11 +17,17 @@ struct client_state {
uoff_t data_size;
};

struct submission_client_vfuncs {
void (*destroy)(struct client *client, const char *prefix,
const char *reason);
};

struct client {
struct client *prev, *next;
pool_t pool;

const char *session_id;
struct submission_client_vfuncs v;
char *session_id;

const struct setting_parser_info *user_set_info;
const struct submission_settings *set;
Expand Down

0 comments on commit 79e4f34

Please sign in to comment.