optimizations

This commit is contained in:
Igor Sysoev 2007-09-14 14:04:24 +00:00
parent 711c36b825
commit 2422950571
5 changed files with 17 additions and 18 deletions

View File

@ -338,8 +338,8 @@ ngx_int_t ngx_mail_auth_cram_md5_salt(ngx_mail_session_t *s,
ngx_int_t ngx_mail_auth_cram_md5(ngx_mail_session_t *s, ngx_connection_t *c);
void ngx_mail_send(ngx_event_t *wev);
ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s);
void ngx_mail_auth(ngx_mail_session_t *s);
ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c);
void ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c);
void ngx_mail_close_connection(ngx_connection_t *c);
void ngx_mail_session_internal_server_error(ngx_mail_session_t *s);
u_char *ngx_mail_log_error(ngx_log_t *log, u_char *buf, size_t len);

View File

@ -565,17 +565,16 @@ ngx_mail_send(ngx_event_t *wev)
ngx_int_t
ngx_mail_read_command(ngx_mail_session_t *s)
ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c)
{
ssize_t n;
ngx_int_t rc;
ngx_str_t l;
n = s->connection->recv(s->connection, s->buffer->last,
s->buffer->end - s->buffer->last);
n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
if (n == NGX_ERROR || n == 0) {
ngx_mail_close_connection(s->connection);
ngx_mail_close_connection(c);
return NGX_ERROR;
}
@ -584,7 +583,7 @@ ngx_mail_read_command(ngx_mail_session_t *s)
}
if (n == NGX_AGAIN) {
if (ngx_handle_read_event(s->connection->read, 0) == NGX_ERROR) {
if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
ngx_mail_session_internal_server_error(s);
return NGX_ERROR;
}
@ -603,7 +602,7 @@ ngx_mail_read_command(ngx_mail_session_t *s)
l.len = s->buffer->last - s->buffer->start;
l.data = s->buffer->start;
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent too long command \"%V\"", &l);
s->quit = 1;
@ -616,7 +615,7 @@ ngx_mail_read_command(ngx_mail_session_t *s)
}
if (rc == NGX_ERROR) {
ngx_mail_close_connection(s->connection);
ngx_mail_close_connection(c);
return NGX_ERROR;
}
@ -625,15 +624,15 @@ ngx_mail_read_command(ngx_mail_session_t *s)
void
ngx_mail_auth(ngx_mail_session_t *s)
ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c)
{
s->args.nelts = 0;
s->buffer->pos = s->buffer->start;
s->buffer->last = s->buffer->start;
s->state = 0;
if (s->connection->read->timer_set) {
ngx_del_timer(s->connection->read);
if (c->read->timer_set) {
ngx_del_timer(c->read);
}
s->login_attempt++;

View File

@ -134,7 +134,7 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
s->blocked = 0;
rc = ngx_mail_read_command(s);
rc = ngx_mail_read_command(s, c);
if (rc == NGX_AGAIN || rc == NGX_ERROR) {
return;
@ -242,7 +242,7 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
switch (rc) {
case NGX_DONE:
ngx_mail_auth(s);
ngx_mail_auth(s, c);
return;
case NGX_ERROR:

View File

@ -140,7 +140,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *rev)
s->blocked = 0;
rc = ngx_mail_read_command(s);
rc = ngx_mail_read_command(s, c);
if (rc == NGX_AGAIN || rc == NGX_ERROR) {
return;
@ -247,7 +247,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *rev)
switch (rc) {
case NGX_DONE:
ngx_mail_auth(s);
ngx_mail_auth(s, c);
return;
case NGX_ERROR:

View File

@ -188,7 +188,7 @@ ngx_mail_smtp_auth_state(ngx_event_t *rev)
s->blocked = 0;
rc = ngx_mail_read_command(s);
rc = ngx_mail_read_command(s, c);
if (rc == NGX_AGAIN || rc == NGX_ERROR) {
return;
@ -263,7 +263,7 @@ ngx_mail_smtp_auth_state(ngx_event_t *rev)
switch (rc) {
case NGX_DONE:
ngx_mail_auth(s);
ngx_mail_auth(s, c);
return;
case NGX_ERROR: