ngx_mail_smtp_create_buffer()
Igor Sysoev
14 years ago
10 | 10 | |
11 | 11 | |
12 | 12 | 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); | |
13 | 15 | |
14 | 16 | static ngx_int_t ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c); |
15 | 17 | static ngx_int_t ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c); |
50 | 52 | } |
51 | 53 | } |
52 | 54 | |
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 | ||
68 | 55 | timeout = cscf->smtp_greeting_delay ? cscf->smtp_greeting_delay: |
69 | 56 | cscf->timeout; |
70 | 57 | ngx_add_timer(c->read, timeout); |
118 | 105 | } else { |
119 | 106 | |
120 | 107 | 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 | } | |
121 | 114 | |
122 | 115 | if (ngx_mail_smtp_discard_command(s, c, |
123 | 116 | "client was rejected before greeting: \"%V\"") |
153 | 146 | |
154 | 147 | s = c->data; |
155 | 148 | |
149 | if (s->buffer == NULL) { | |
150 | if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) { | |
151 | return; | |
152 | } | |
153 | } | |
154 | ||
156 | 155 | s->mail_state = ngx_smtp_start; |
157 | 156 | c->read->handler = ngx_mail_smtp_auth_state; |
158 | 157 | |
159 | 158 | 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; | |
160 | 181 | } |
161 | 182 | |
162 | 183 |