Klaus Demo nginx / 2422950
optimizations Igor Sysoev 14 years ago
5 changed file(s) with 17 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
337337 ngx_int_t ngx_mail_auth_cram_md5(ngx_mail_session_t *s, ngx_connection_t *c);
338338
339339 void ngx_mail_send(ngx_event_t *wev);
340 ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s);
341 void ngx_mail_auth(ngx_mail_session_t *s);
340 ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c);
341 void ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c);
342342 void ngx_mail_close_connection(ngx_connection_t *c);
343343 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s);
344344 u_char *ngx_mail_log_error(ngx_log_t *log, u_char *buf, size_t len);
564564
565565
566566 ngx_int_t
567 ngx_mail_read_command(ngx_mail_session_t *s)
567 ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c)
568568 {
569569 ssize_t n;
570570 ngx_int_t rc;
571571 ngx_str_t l;
572572
573 n = s->connection->recv(s->connection, s->buffer->last,
574 s->buffer->end - s->buffer->last);
573 n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
575574
576575 if (n == NGX_ERROR || n == 0) {
577 ngx_mail_close_connection(s->connection);
576 ngx_mail_close_connection(c);
578577 return NGX_ERROR;
579578 }
580579
583582 }
584583
585584 if (n == NGX_AGAIN) {
586 if (ngx_handle_read_event(s->connection->read, 0) == NGX_ERROR) {
585 if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
587586 ngx_mail_session_internal_server_error(s);
588587 return NGX_ERROR;
589588 }
602601 l.len = s->buffer->last - s->buffer->start;
603602 l.data = s->buffer->start;
604603
605 ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
604 ngx_log_error(NGX_LOG_INFO, c->log, 0,
606605 "client sent too long command \"%V\"", &l);
607606
608607 s->quit = 1;
615614 }
616615
617616 if (rc == NGX_ERROR) {
618 ngx_mail_close_connection(s->connection);
617 ngx_mail_close_connection(c);
619618 return NGX_ERROR;
620619 }
621620
624623
625624
626625 void
627 ngx_mail_auth(ngx_mail_session_t *s)
626 ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c)
628627 {
629628 s->args.nelts = 0;
630629 s->buffer->pos = s->buffer->start;
631630 s->buffer->last = s->buffer->start;
632631 s->state = 0;
633632
634 if (s->connection->read->timer_set) {
635 ngx_del_timer(s->connection->read);
633 if (c->read->timer_set) {
634 ngx_del_timer(c->read);
636635 }
637636
638637 s->login_attempt++;
133133
134134 s->blocked = 0;
135135
136 rc = ngx_mail_read_command(s);
136 rc = ngx_mail_read_command(s, c);
137137
138138 if (rc == NGX_AGAIN || rc == NGX_ERROR) {
139139 return;
241241 switch (rc) {
242242
243243 case NGX_DONE:
244 ngx_mail_auth(s);
244 ngx_mail_auth(s, c);
245245 return;
246246
247247 case NGX_ERROR:
139139
140140 s->blocked = 0;
141141
142 rc = ngx_mail_read_command(s);
142 rc = ngx_mail_read_command(s, c);
143143
144144 if (rc == NGX_AGAIN || rc == NGX_ERROR) {
145145 return;
246246 switch (rc) {
247247
248248 case NGX_DONE:
249 ngx_mail_auth(s);
249 ngx_mail_auth(s, c);
250250 return;
251251
252252 case NGX_ERROR:
187187
188188 s->blocked = 0;
189189
190 rc = ngx_mail_read_command(s);
190 rc = ngx_mail_read_command(s, c);
191191
192192 if (rc == NGX_AGAIN || rc == NGX_ERROR) {
193193 return;
262262 switch (rc) {
263263
264264 case NGX_DONE:
265 ngx_mail_auth(s);
265 ngx_mail_auth(s, c);
266266 return;
267267
268268 case NGX_ERROR: