diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-09-09 15:40:48 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-09-09 15:40:48 +0000 |
commit | 2e6ba93fa79cadf9ed2256992d7c8c4d512f2b1f (patch) | |
tree | 50dd328ad6dbd0d9a22a561f2f335ebfe098f1d0 /src/imap/ngx_imap_handler.c | |
parent | 0d9da9b6c3c4842eade3034e6e1f3ea140d08d6d (diff) | |
download | nginx-2e6ba93fa79cadf9ed2256992d7c8c4d512f2b1f.tar.gz nginx-2e6ba93fa79cadf9ed2256992d7c8c4d512f2b1f.zip |
nginx-0.0.10-2004-09-09-19:40:48 import
Diffstat (limited to 'src/imap/ngx_imap_handler.c')
-rw-r--r-- | src/imap/ngx_imap_handler.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/imap/ngx_imap_handler.c b/src/imap/ngx_imap_handler.c index 61c59c98d..55808fac4 100644 --- a/src/imap/ngx_imap_handler.c +++ b/src/imap/ngx_imap_handler.c @@ -6,7 +6,7 @@ #include <nginx.h> -static void ngx_imap_auth_state(ngx_event_t *rev); +static void ngx_imap_init_session(ngx_event_t *rev); static char pop3_greeting[] = "+OK " NGINX_VER " ready" CRLF; @@ -15,36 +15,66 @@ static char imap_greeting[] = "* OK " NGINX_VER " ready" CRLF; void ngx_imap_init_connection(ngx_connection_t *c) { - ngx_int_t n; + char *greeting; + ssize_t size; + ngx_int_t n; ngx_log_debug0(NGX_LOG_DEBUG_IMAP, c->log, 0, "imap init connection"); c->log_error = NGX_ERROR_INFO; - n = ngx_send(c, pop3_greeting, sizeof(pop3_greeting) - 1); + greeting = pop3_greeting; + size = sizeof(pop3_greeting) - 1; - if (n == NGX_ERROR) { + n = ngx_send(c, greeting, size); + + if (n < size) { + /* + * we treat the incomplete sending as NGX_ERROR + * because it is very strange here + */ ngx_imap_close_connection(c); return; } - c->read->event_handler = ngx_imap_auth_state; + c->read->event_handler = ngx_imap_init_session; + + ngx_add_timer(c->read, /* STUB */ 60000); if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) { ngx_imap_close_connection(c); - return; } } -static void ngx_imap_auth_state(ngx_event_t *rev) +static void ngx_imap_init_session(ngx_event_t *rev) { - ngx_connection_t *c; + ngx_connection_t *c; + ngx_imap_session_t *s; c = rev->data; - ngx_imap_close_connection(c); + if (!(s = ngx_pcalloc(c->pool, sizeof(ngx_imap_session_t)))) { + ngx_imap_close_connection(c); + return; + } + + c->data = s; + s->connection = c; + + if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) == NGX_ERROR) { + ngx_imap_close_connection(s->connection); + return; + } + + s->buffer = ngx_create_temp_buf(s->connection->pool, /* STUB */ 4096); + if (s->buffer == NULL) { + ngx_imap_close_connection(s->connection); + return; + } + + ngx_imap_proxy_init(s); } |