Klaus Demo nginx / dac63a2
ngx_mail_smtp_create_buffer() Igor Sysoev 14 years ago
1 changed file(s) with 36 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
1010
1111
1212 static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev);
13 static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s,
14 ngx_connection_t *c);
1315
1416 static ngx_int_t ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c);
1517 static ngx_int_t ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c);
5052 }
5153 }
5254
53 if (s->buffer == NULL) {
54 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t))
55 == NGX_ERROR)
56 {
57 ngx_mail_session_internal_server_error(s);
58 return;
59 }
60
61 s->buffer = ngx_create_temp_buf(c->pool, cscf->smtp_client_buffer_size);
62 if (s->buffer == NULL) {
63 ngx_mail_session_internal_server_error(s);
64 return;
65 }
66 }
67
6855 timeout = cscf->smtp_greeting_delay ? cscf->smtp_greeting_delay:
6956 cscf->timeout;
7057 ngx_add_timer(c->read, timeout);
118105 } else {
119106
120107 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "invalid pipelining");
108
109 if (s->buffer == NULL) {
110 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) {
111 return;
112 }
113 }
121114
122115 if (ngx_mail_smtp_discard_command(s, c,
123116 "client was rejected before greeting: \"%V\"")
153146
154147 s = c->data;
155148
149 if (s->buffer == NULL) {
150 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) {
151 return;
152 }
153 }
154
156155 s->mail_state = ngx_smtp_start;
157156 c->read->handler = ngx_mail_smtp_auth_state;
158157
159158 ngx_mail_smtp_auth_state(rev);
159 }
160
161
162 static ngx_int_t
163 ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, ngx_connection_t *c)
164 {
165 ngx_mail_core_srv_conf_t *cscf;
166
167 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) == NGX_ERROR) {
168 ngx_mail_session_internal_server_error(s);
169 return NGX_ERROR;
170 }
171
172 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
173
174 s->buffer = ngx_create_temp_buf(c->pool, cscf->smtp_client_buffer_size);
175 if (s->buffer == NULL) {
176 ngx_mail_session_internal_server_error(s);
177 return NGX_ERROR;
178 }
179
180 return NGX_OK;
160181 }
161182
162183