aboutsummaryrefslogtreecommitdiff
path: root/src/mail/ngx_mail_smtp_handler.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-09-14 14:13:25 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-09-14 14:13:25 +0000
commitdac63a2f28e12d49432cbe5c6cb6817b16ed8600 (patch)
tree91daa40cfccd990a23d89005a8185984d483b30a /src/mail/ngx_mail_smtp_handler.c
parent2422950571cfe7233bc402001d2f9dd1ffd6f26c (diff)
downloadnginx-dac63a2f28e12d49432cbe5c6cb6817b16ed8600.tar.gz
nginx-dac63a2f28e12d49432cbe5c6cb6817b16ed8600.zip
ngx_mail_smtp_create_buffer()
Diffstat (limited to 'src/mail/ngx_mail_smtp_handler.c')
-rw-r--r--src/mail/ngx_mail_smtp_handler.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/mail/ngx_mail_smtp_handler.c b/src/mail/ngx_mail_smtp_handler.c
index 26b1da92e..5bc667cf3 100644
--- a/src/mail/ngx_mail_smtp_handler.c
+++ b/src/mail/ngx_mail_smtp_handler.c
@@ -11,6 +11,8 @@
static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev);
+static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s,
+ ngx_connection_t *c);
static ngx_int_t ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c);
static ngx_int_t ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c);
@@ -51,21 +53,6 @@ ngx_mail_smtp_init_session(ngx_mail_session_t *s, ngx_connection_t *c)
}
}
- if (s->buffer == NULL) {
- if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t))
- == NGX_ERROR)
- {
- ngx_mail_session_internal_server_error(s);
- return;
- }
-
- s->buffer = ngx_create_temp_buf(c->pool, cscf->smtp_client_buffer_size);
- if (s->buffer == NULL) {
- ngx_mail_session_internal_server_error(s);
- return;
- }
- }
-
timeout = cscf->smtp_greeting_delay ? cscf->smtp_greeting_delay:
cscf->timeout;
ngx_add_timer(c->read, timeout);
@@ -120,6 +107,12 @@ ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev)
ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "invalid pipelining");
+ if (s->buffer == NULL) {
+ if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) {
+ return;
+ }
+ }
+
if (ngx_mail_smtp_discard_command(s, c,
"client was rejected before greeting: \"%V\"")
!= NGX_OK)
@@ -154,6 +147,12 @@ ngx_mail_smtp_init_protocol(ngx_event_t *rev)
s = c->data;
+ if (s->buffer == NULL) {
+ if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) {
+ return;
+ }
+ }
+
s->mail_state = ngx_smtp_start;
c->read->handler = ngx_mail_smtp_auth_state;
@@ -161,6 +160,28 @@ ngx_mail_smtp_init_protocol(ngx_event_t *rev)
}
+static ngx_int_t
+ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, ngx_connection_t *c)
+{
+ ngx_mail_core_srv_conf_t *cscf;
+
+ if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) == NGX_ERROR) {
+ ngx_mail_session_internal_server_error(s);
+ return NGX_ERROR;
+ }
+
+ cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
+
+ s->buffer = ngx_create_temp_buf(c->pool, cscf->smtp_client_buffer_size);
+ if (s->buffer == NULL) {
+ ngx_mail_session_internal_server_error(s);
+ return NGX_ERROR;
+ }
+
+ return NGX_OK;
+}
+
+
void
ngx_mail_smtp_auth_state(ngx_event_t *rev)
{