comparison src/mail/ngx_mail_smtp_handler.c @ 2488:ac695b3e981c

avoid deep nested calls, flatten call tree
author Igor Sysoev <igor@sysoev.ru>
date Sat, 31 Jan 2009 20:34:26 +0000
parents 722b5aff05ae
children a59b26eee816
comparison
equal deleted inserted replaced
2487:9b4dce95c744 2488:ac695b3e981c
10 #include <ngx_mail.h> 10 #include <ngx_mail.h>
11 #include <ngx_mail_smtp_module.h> 11 #include <ngx_mail_smtp_module.h>
12 12
13 13
14 static void ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx); 14 static void ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx);
15 static void ngx_mail_smtp_resolve_name(ngx_event_t *rev);
15 static void ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx); 16 static void ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx);
16 static void ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c); 17 static void ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c);
17 static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev); 18 static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev);
18 static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, 19 static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s,
19 ngx_connection_t *c); 20 ngx_connection_t *c);
89 90
90 91
91 static void 92 static void
92 ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx) 93 ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx)
93 { 94 {
94 ngx_connection_t *c; 95 ngx_connection_t *c;
95 ngx_mail_session_t *s; 96 ngx_mail_session_t *s;
96 ngx_mail_core_srv_conf_t *cscf;
97 97
98 s = ctx->data; 98 s = ctx->data;
99 c = s->connection; 99 c = s->connection;
100 100
101 if (ctx->state) { 101 if (ctx->state) {
131 131
132 ngx_resolve_addr_done(ctx); 132 ngx_resolve_addr_done(ctx);
133 133
134 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, 134 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
135 "address resolved: %V", &s->host); 135 "address resolved: %V", &s->host);
136
137 c->read->handler = ngx_mail_smtp_resolve_name;
138
139 ngx_post_event(c->read, &ngx_posted_events);
140 }
141
142
143 static void
144 ngx_mail_smtp_resolve_name(ngx_event_t *rev)
145 {
146 ngx_connection_t *c;
147 ngx_mail_session_t *s;
148 ngx_resolver_ctx_t *ctx;
149 ngx_mail_core_srv_conf_t *cscf;
150
151 c = rev->data;
152 s = c->data;
136 153
137 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); 154 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
138 155
139 ctx = ngx_resolve_start(cscf->resolver, NULL); 156 ctx = ngx_resolve_start(cscf->resolver, NULL);
140 if (ctx == NULL) { 157 if (ctx == NULL) {