comparison src/core/ngx_resolver.c @ 384:09b703ae3ba5 NGINX_0_6_36

nginx 0.6.36 *) Change: now the "Invalid argument" error returned by setsockopt(TCP_NODELAY) on Solaris, is ignored. *) Change: now POSTs without "Content-Length" header line are allowed. *) Feature: the "try_files" directive. *) Feature: the --with-pcre option in the configure. *) Feature: the "if_modified_since" directive. *) Feature: the "$cookie_..." variables. *) Feature: the "$arg_..." variables. *) Bugfix: compatibility with Tru64 UNIX. Thanks to Dustin Marquess. *) Bugfix: a "ssl_engine" directive did not use a SSL-accelerator for asymmetric ciphers. Thanks to Marcin Gozdalik. *) Bugfix: in a redirect rewrite directive original arguments were concatenated with new arguments by a "?" rather than an "&"; the bug had appeared in 0.1.18. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on AIX. *) Bugfix: a double response might be returned if the epoll or rtsig methods are used and a redirect was returned to a request with body. Thanks to Eden Li. *) Bugfix: a segmentation fault might occur in worker process if "resolver" directive was used in SMTP proxy. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: nginx did not process a FastCGI server response, if the server send too many messages to stderr before response.
author Igor Sysoev <http://sysoev.ru>
date Thu, 02 Apr 2009 00:00:00 +0400
parents fc497c1dfb7c
children
comparison
equal deleted inserted replaced
383:3d40b0260a84 384:09b703ae3ba5
576 576
577 577
578 ngx_int_t 578 ngx_int_t
579 ngx_resolve_addr(ngx_resolver_ctx_t *ctx) 579 ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
580 { 580 {
581 u_char *name;
581 ngx_resolver_t *r; 582 ngx_resolver_t *r;
582 ngx_resolver_node_t *rn; 583 ngx_resolver_node_t *rn;
583 584
584 r = ctx->resolver; 585 r = ctx->resolver;
585 586
599 600
600 rn->expire = ngx_time() + r->expire; 601 rn->expire = ngx_time() + r->expire;
601 602
602 ngx_queue_insert_head(&r->addr_expire_queue, &rn->queue); 603 ngx_queue_insert_head(&r->addr_expire_queue, &rn->queue);
603 604
604 ctx->name.len = rn->nlen; 605 name = ngx_resolver_dup(r, rn->name, rn->nlen);
605 ctx->name.data = ngx_resolver_dup(r, rn->name, rn->nlen); 606 if (name == NULL) {
606 if (ctx->name.data == NULL) {
607 goto failed; 607 goto failed;
608 } 608 }
609 609
610 ctx->name.len = rn->nlen;
611 ctx->name.data = name;
612
610 /* unlock addr mutex */ 613 /* unlock addr mutex */
611 614
612 ctx->state = NGX_OK; 615 ctx->state = NGX_OK;
613 616
614 ctx->handler(ctx); 617 ctx->handler(ctx);
615 618
616 ngx_resolver_free(r, ctx->name.data); 619 ngx_resolver_free(r, name);
617 620
618 return NGX_OK; 621 return NGX_OK;
619 } 622 }
620 623
621 if (rn->waiting) { 624 if (rn->waiting) {
622 625
623 ctx->next = rn->waiting; 626 ctx->next = rn->waiting;
624 rn->waiting = ctx; 627 rn->waiting = ctx;
625 628
626 return NGX_AGAIN; 629 /* unlock addr mutex */
630
631 return NGX_OK;
627 } 632 }
628 633
629 ngx_queue_remove(&rn->queue); 634 ngx_queue_remove(&rn->queue);
630 635
631 ngx_resolver_free(r, rn->query); 636 ngx_resolver_free(r, rn->query);
1304 next = ctx->next; 1309 next = ctx->next;
1305 1310
1306 ctx->handler(ctx); 1311 ctx->handler(ctx);
1307 } 1312 }
1308 1313
1309 if (naddrs) { 1314 if (naddrs > 1) {
1310 ngx_resolver_free(r, addrs); 1315 ngx_resolver_free(r, addrs);
1311 } 1316 }
1312 1317
1313 return; 1318 return;
1314 1319
1481 1486
1482 if (i + len > (ngx_uint_t) n) { 1487 if (i + len > (ngx_uint_t) n) {
1483 goto short_response; 1488 goto short_response;
1484 } 1489 }
1485 1490
1486 len -= 2;
1487
1488 if (ngx_resolver_copy(r, &name, buf, &buf[i], &buf[n]) != NGX_OK) { 1491 if (ngx_resolver_copy(r, &name, buf, &buf[i], &buf[n]) != NGX_OK) {
1489 return; 1492 return;
1490 } 1493 }
1491 1494
1492 ngx_log_debug1(NGX_LOG_DEBUG_CORE, r->log, 0, "resolver an:%V", &name); 1495 ngx_log_debug1(NGX_LOG_DEBUG_CORE, r->log, 0, "resolver an:%V", &name);
1493 1496
1494 if (len != (size_t) rn->nlen || ngx_strncmp(name.data, rn->name, len) != 0) 1497 if (name.len != (size_t) rn->nlen
1498 || ngx_strncmp(name.data, rn->name, name.len) != 0)
1495 { 1499 {
1496 ngx_resolver_free(r, rn->name); 1500 if (rn->nlen) {
1501 ngx_resolver_free(r, rn->name);
1502 }
1503
1504 rn->nlen = (u_short) name.len;
1497 rn->name = name.data; 1505 rn->name = name.data;
1498 1506
1499 name.data = ngx_resolver_dup(r, rn->name, len); 1507 name.data = ngx_resolver_dup(r, rn->name, name.len);
1500 if (name.data == NULL) { 1508 if (name.data == NULL) {
1501 goto failed; 1509 goto failed;
1502 } 1510 }
1503 } 1511 }
1504 1512