• 源码 502 回溯


    https://github.com/nginx/nginx/blob/cb4dd56771c1af082bf3e810436712b4f48f2cf2/src/http/ngx_http_upstream.c

    if (ctx == NGX_NO_RESOLVER) {
      ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
      "no resolver defined to resolve %V", host);
       
      ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
      return;
      }

    https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_resolver.h

    #define NGX_NO_RESOLVER (void *) -1

     

    if (r->connections.nelts == 0) {
      return NGX_NO_RESOLVER;
      }

    https://github.com/nginx/nginx/blob/8e2949e56a13405a157e05b21aa4c4a5fa468335/src/core/ngx_resolver.c

    https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_resolver.h

    typedef struct ngx_resolver_ctx_s ngx_resolver_ctx_t;
     

    https://github.com/nginx/nginx/blob/8e2949e56a13405a157e05b21aa4c4a5fa468335/src/core/ngx_resolver.c

    ngx_resolve_start(ngx_resolver_t *r, ngx_resolver_ctx_t *temp)
    {
    in_addr_t addr;
    ngx_resolver_ctx_t *ctx;
    if (temp) {
    addr = ngx_inet_addr(temp->name.data, temp->name.len);
    if (addr != INADDR_NONE) {
    temp->resolver = r;
    temp->state = NGX_OK;
    temp->naddrs = 1;
    temp->addrs = &temp->addr;
    temp->addr.sockaddr = (struct sockaddr *) &temp->sin;
    temp->addr.socklen = sizeof(struct sockaddr_in);
    ngx_memzero(&temp->sin, sizeof(struct sockaddr_in));
    temp->sin.sin_family = AF_INET;
    temp->sin.sin_addr.s_addr = addr;
    temp->quick = 1;
    return temp;
    }
    }
    if (r->connections.nelts == 0) {
    return NGX_NO_RESOLVER;
    }

    https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_resolver.h

    typedef struct ngx_resolver_ctx_s ngx_resolver_ctx_t;

    struct ngx_resolver_ctx_s {
    ngx_resolver_ctx_t *next;
    ngx_resolver_t *resolver;
    ngx_resolver_node_t *node;

    /* event ident must be after 3 pointers as in ngx_connection_t */
    ngx_int_t ident;

    ngx_int_t state;
    ngx_str_t name;
    ngx_str_t service;

    time_t valid;
    ngx_uint_t naddrs;
    ngx_resolver_addr_t *addrs;
    ngx_resolver_addr_t addr;
    struct sockaddr_in sin;

    ngx_uint_t count;
    ngx_uint_t nsrvs;
    ngx_resolver_srv_name_t *srvs;

    ngx_resolver_handler_pt handler;
    void *data;
    ngx_msec_t timeout;

    unsigned quick:1;
    unsigned async:1;
    unsigned cancelable:1;
    ngx_uint_t recursion;
    ngx_event_t *event;
    };

    https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_resolver.h

    typedef struct ngx_resolver_s ngx_resolver_t;

    struct ngx_resolver_s {
    /* has to be pointer because of "incomplete type" */
    ngx_event_t *event;
    void *dummy;
    ngx_log_t *log;

    /* event ident must be after 3 pointers as in ngx_connection_t */
    ngx_int_t ident;

    /* simple round robin DNS peers balancer */
    ngx_array_t connections;
    ngx_uint_t last_connection;

    ngx_rbtree_t name_rbtree;
    ngx_rbtree_node_t name_sentinel;

    ngx_rbtree_t srv_rbtree;
    ngx_rbtree_node_t srv_sentinel;

    ngx_rbtree_t addr_rbtree;
    ngx_rbtree_node_t addr_sentinel;

    ngx_queue_t name_resend_queue;
    ngx_queue_t srv_resend_queue;
    ngx_queue_t addr_resend_queue;

    ngx_queue_t name_expire_queue;
    ngx_queue_t srv_expire_queue;
    ngx_queue_t addr_expire_queue;

    #if (NGX_HAVE_INET6)
    ngx_uint_t ipv6; /* unsigned ipv6:1; */
    ngx_rbtree_t addr6_rbtree;
    ngx_rbtree_node_t addr6_sentinel;
    ngx_queue_t addr6_resend_queue;
    ngx_queue_t addr6_expire_queue;
    #endif

    time_t resend_timeout;
    time_t tcp_timeout;
    time_t expire;
    time_t valid;

    ngx_uint_t log_level;
    };

    https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_array.h

    typedef struct {
    void *elts;
    ngx_uint_t nelts;
    size_t size;
    ngx_uint_t nalloc;
    ngx_pool_t *pool;
    } ngx_array_t;

  • 相关阅读:
    Python面向对象(类的成员之属性)
    Python面向对象(类的成员之方法)
    Python面向对象(类的成员之字段)
    Python面向对象(多态)
    Python面向对象(继承)
    Python面向对象(构造方法)
    Python面向对象(self参数、封装)
    Python面向对象(定义类和创建对象)
    Pangolin库的使用
    Combinations
  • 原文地址:https://www.cnblogs.com/rsapaper/p/10193138.html
Copyright © 2020-2023  润新知