2004-09-28 16:34:51 +08:00
|
|
|
|
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-05-12 23:52:24 +08:00
|
|
|
#ifndef _NGX_EVENT_CONNECT_H_INCLUDED_
|
|
|
|
#define _NGX_EVENT_CONNECT_H_INCLUDED_
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
2003-07-21 05:15:59 +08:00
|
|
|
#include <ngx_core.h>
|
2003-05-12 23:52:24 +08:00
|
|
|
#include <ngx_event.h>
|
|
|
|
|
|
|
|
|
2003-10-02 13:39:37 +08:00
|
|
|
#define NGX_CONNECT_ERROR -10
|
|
|
|
|
|
|
|
|
2003-05-12 23:52:24 +08:00
|
|
|
typedef struct {
|
2003-11-26 04:44:56 +08:00
|
|
|
in_addr_t addr;
|
2003-05-12 23:52:24 +08:00
|
|
|
ngx_str_t host;
|
2004-09-09 23:40:48 +08:00
|
|
|
in_port_t port;
|
2003-07-23 03:53:10 +08:00
|
|
|
ngx_str_t addr_port_text;
|
2003-05-12 23:52:24 +08:00
|
|
|
|
2004-09-09 23:40:48 +08:00
|
|
|
ngx_int_t fails;
|
2003-05-12 23:52:24 +08:00
|
|
|
time_t accessed;
|
|
|
|
} ngx_peer_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2004-09-09 23:40:48 +08:00
|
|
|
ngx_int_t current;
|
|
|
|
ngx_int_t number;
|
|
|
|
ngx_int_t max_fails;
|
2004-10-25 23:29:23 +08:00
|
|
|
time_t fail_timeout;
|
2004-09-09 23:40:48 +08:00
|
|
|
ngx_int_t last_cached;
|
2003-05-12 23:52:24 +08:00
|
|
|
|
2003-10-02 13:39:37 +08:00
|
|
|
/* ngx_mutex_t *mutex; */
|
|
|
|
ngx_connection_t **cached;
|
2003-05-12 23:52:24 +08:00
|
|
|
|
2003-10-02 13:39:37 +08:00
|
|
|
ngx_peer_t peers[1];
|
2003-05-12 23:52:24 +08:00
|
|
|
} ngx_peers_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_peers_t *peers;
|
2004-09-09 23:40:48 +08:00
|
|
|
ngx_int_t cur_peer;
|
|
|
|
ngx_int_t tries;
|
2003-07-21 05:15:59 +08:00
|
|
|
|
2003-07-22 00:24:25 +08:00
|
|
|
ngx_connection_t *connection;
|
2004-07-05 23:08:23 +08:00
|
|
|
#if (NGX_THREADS)
|
|
|
|
ngx_atomic_t *lock;
|
|
|
|
#endif
|
2003-07-22 00:24:25 +08:00
|
|
|
|
2003-07-23 03:53:10 +08:00
|
|
|
int rcvbuf;
|
|
|
|
|
2003-08-01 22:56:33 +08:00
|
|
|
ngx_log_t *log;
|
|
|
|
|
2003-07-21 05:15:59 +08:00
|
|
|
unsigned cached:1;
|
2004-03-15 04:46:25 +08:00
|
|
|
unsigned log_error:2; /* ngx_connection_log_error_e */
|
2003-07-22 00:24:25 +08:00
|
|
|
} ngx_peer_connection_t;
|
2003-05-12 23:52:24 +08:00
|
|
|
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
ngx_int_t ngx_event_connect_peer(ngx_peer_connection_t *pc);
|
2003-10-02 13:39:37 +08:00
|
|
|
void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc);
|
|
|
|
|
|
|
|
|
2003-05-12 23:52:24 +08:00
|
|
|
#endif /* _NGX_EVENT_CONNECT_H_INCLUDED_ */
|