Mercurial > hg > nginx
comparison src/mail/ngx_mail_auth_http_module.c @ 2049:2a92804f4109
*) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 17 Jun 2008 15:00:30 +0000 |
parents | 02a22cd5282a |
children | b0a1c84725cf |
comparison
equal
deleted
inserted
replaced
2048:824615f3b4ec | 2049:2a92804f4109 |
---|---|
591 sizeof("Auth-User") - 1) | 591 sizeof("Auth-User") - 1) |
592 == 0) | 592 == 0) |
593 { | 593 { |
594 s->login.len = ctx->header_end - ctx->header_start; | 594 s->login.len = ctx->header_end - ctx->header_start; |
595 | 595 |
596 s->login.data = ngx_palloc(s->connection->pool, s->login.len); | 596 s->login.data = ngx_pnalloc(s->connection->pool, s->login.len); |
597 if (s->login.data == NULL) { | 597 if (s->login.data == NULL) { |
598 ngx_close_connection(ctx->peer.connection); | 598 ngx_close_connection(ctx->peer.connection); |
599 ngx_destroy_pool(ctx->pool); | 599 ngx_destroy_pool(ctx->pool); |
600 ngx_mail_session_internal_server_error(s); | 600 ngx_mail_session_internal_server_error(s); |
601 return; | 601 return; |
612 sizeof("Auth-Pass") - 1) | 612 sizeof("Auth-Pass") - 1) |
613 == 0) | 613 == 0) |
614 { | 614 { |
615 s->passwd.len = ctx->header_end - ctx->header_start; | 615 s->passwd.len = ctx->header_end - ctx->header_start; |
616 | 616 |
617 s->passwd.data = ngx_palloc(s->connection->pool, s->passwd.len); | 617 s->passwd.data = ngx_pnalloc(s->connection->pool, |
618 s->passwd.len); | |
618 if (s->passwd.data == NULL) { | 619 if (s->passwd.data == NULL) { |
619 ngx_close_connection(ctx->peer.connection); | 620 ngx_close_connection(ctx->peer.connection); |
620 ngx_destroy_pool(ctx->pool); | 621 ngx_destroy_pool(ctx->pool); |
621 ngx_mail_session_internal_server_error(s); | 622 ngx_mail_session_internal_server_error(s); |
622 return; | 623 return; |
649 sizeof("Auth-Error-Code") - 1) | 650 sizeof("Auth-Error-Code") - 1) |
650 == 0) | 651 == 0) |
651 { | 652 { |
652 ctx->errcode.len = ctx->header_end - ctx->header_start; | 653 ctx->errcode.len = ctx->header_end - ctx->header_start; |
653 | 654 |
654 ctx->errcode.data = ngx_palloc(s->connection->pool, | 655 ctx->errcode.data = ngx_pnalloc(s->connection->pool, |
655 ctx->errcode.len); | 656 ctx->errcode.len); |
656 if (ctx->errcode.data == NULL) { | 657 if (ctx->errcode.data == NULL) { |
657 ngx_close_connection(ctx->peer.connection); | 658 ngx_close_connection(ctx->peer.connection); |
658 ngx_destroy_pool(ctx->pool); | 659 ngx_destroy_pool(ctx->pool); |
659 ngx_mail_session_internal_server_error(s); | 660 ngx_mail_session_internal_server_error(s); |
660 return; | 661 return; |
689 } | 690 } |
690 | 691 |
691 ctx->err.len = ctx->errcode.len + ctx->errmsg.len | 692 ctx->err.len = ctx->errcode.len + ctx->errmsg.len |
692 + sizeof(" " CRLF) - 1; | 693 + sizeof(" " CRLF) - 1; |
693 | 694 |
694 p = ngx_palloc(s->connection->pool, ctx->err.len); | 695 p = ngx_pnalloc(s->connection->pool, ctx->err.len); |
695 if (p == NULL) { | 696 if (p == NULL) { |
696 ngx_close_connection(ctx->peer.connection); | 697 ngx_close_connection(ctx->peer.connection); |
697 ngx_destroy_pool(ctx->pool); | 698 ngx_destroy_pool(ctx->pool); |
698 ngx_mail_session_internal_server_error(s); | 699 ngx_mail_session_internal_server_error(s); |
699 return; | 700 return; |
808 | 809 |
809 len = ctx->addr.len + 1 + ctx->port.len; | 810 len = ctx->addr.len + 1 + ctx->port.len; |
810 | 811 |
811 peer->name.len = len; | 812 peer->name.len = len; |
812 | 813 |
813 peer->name.data = ngx_palloc(s->connection->pool, len); | 814 peer->name.data = ngx_pnalloc(s->connection->pool, len); |
814 if (peer->name.data == NULL) { | 815 if (peer->name.data == NULL) { |
815 ngx_destroy_pool(ctx->pool); | 816 ngx_destroy_pool(ctx->pool); |
816 ngx_mail_session_internal_server_error(s); | 817 ngx_mail_session_internal_server_error(s); |
817 return; | 818 return; |
818 } | 819 } |
1253 return NGX_OK; | 1254 return NGX_OK; |
1254 } | 1255 } |
1255 | 1256 |
1256 escaped->len = text->len + n * 2; | 1257 escaped->len = text->len + n * 2; |
1257 | 1258 |
1258 p = ngx_palloc(pool, escaped->len); | 1259 p = ngx_pnalloc(pool, escaped->len); |
1259 if (p == NULL) { | 1260 if (p == NULL) { |
1260 return NGX_ERROR; | 1261 return NGX_ERROR; |
1261 } | 1262 } |
1262 | 1263 |
1263 (void) ngx_escape_uri(p, text->data, text->len, NGX_ESCAPE_MAIL_AUTH); | 1264 (void) ngx_escape_uri(p, text->data, text->len, NGX_ESCAPE_MAIL_AUTH); |
1324 header = conf->headers->elts; | 1325 header = conf->headers->elts; |
1325 for (i = 0; i < conf->headers->nelts; i++) { | 1326 for (i = 0; i < conf->headers->nelts; i++) { |
1326 len += header[i].key.len + 2 + header[i].value.len + 2; | 1327 len += header[i].key.len + 2 + header[i].value.len + 2; |
1327 } | 1328 } |
1328 | 1329 |
1329 p = ngx_palloc(cf->pool, len); | 1330 p = ngx_pnalloc(cf->pool, len); |
1330 if (p == NULL) { | 1331 if (p == NULL) { |
1331 return NGX_CONF_ERROR; | 1332 return NGX_CONF_ERROR; |
1332 } | 1333 } |
1333 | 1334 |
1334 conf->header.len = len; | 1335 conf->header.len = len; |