diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-09-07 15:29:22 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-09-07 15:29:22 +0000 |
commit | 59cf56c5d975725be9e2adc84170ffe0c638fa48 (patch) | |
tree | d355ce8975bbcacc29cdf54ffac45c84b55649a0 /src/imap/ngx_imap_handler.c | |
parent | aab4d8c0c4aa068cc7ddcb1c5daee330d9dec47a (diff) | |
download | nginx-59cf56c5d975725be9e2adc84170ffe0c638fa48.tar.gz nginx-59cf56c5d975725be9e2adc84170ffe0c638fa48.zip |
nginx-0.0.10-2004-09-07-19:29:22 import
Diffstat (limited to 'src/imap/ngx_imap_handler.c')
-rw-r--r-- | src/imap/ngx_imap_handler.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/imap/ngx_imap_handler.c b/src/imap/ngx_imap_handler.c index 635ae020c..bbedc9c56 100644 --- a/src/imap/ngx_imap_handler.c +++ b/src/imap/ngx_imap_handler.c @@ -2,18 +2,56 @@ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> +#include <ngx_imap.h> +#include <nginx.h> + + +static void ngx_imap_auth_state(ngx_event_t *rev); + + +static char pop3_greeting[] = "+OK " NGINX_VER " ready" CRLF; +static char imap_greeting[] = "* OK " NGINX_VER " ready" CRLF; void ngx_imap_init_connection(ngx_connection_t *c) { + ngx_int_t rc; + ngx_log_debug0(NGX_LOG_DEBUG_IMAP, c->log, 0, "imap init connection"); - if (ngx_close_socket(c->fd) == -1) { + c->log_error = NGX_ERROR_INFO; - /* we use ngx_cycle->log because c->log was in c->pool */ + rc = ngx_send(c, pop3_greeting, sizeof(pop3_greeting) - 1); - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno, - ngx_close_socket_n " failed"); + if (rc == NGX_ERROR) { + ngx_imap_close_connection(c); + return; } + + c->read->event_handler = ngx_imap_auth_state; + + 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) +{ + ngx_connection_t *c; + + c = rev->data; + + ngx_imap_close_connection(c); +} + + +void ngx_imap_close_connection(ngx_connection_t *c) +{ + ngx_log_debug1(NGX_LOG_DEBUG_IMAP, c->log, 0, + "close imap connection: %d", c->fd); + + ngx_close_connection(c); } |