0
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #ifndef _NGX_EVENT_CONNECT_H_INCLUDED_
|
|
8 #define _NGX_EVENT_CONNECT_H_INCLUDED_
|
|
9
|
|
10
|
|
11 #include <ngx_config.h>
|
|
12 #include <ngx_core.h>
|
|
13 #include <ngx_event.h>
|
|
14
|
|
15
|
|
16 #define NGX_CONNECT_ERROR -10
|
|
17
|
|
18
|
|
19 typedef struct {
|
|
20 in_addr_t addr;
|
|
21 ngx_str_t host;
|
|
22 in_port_t port;
|
|
23 ngx_str_t addr_port_text;
|
|
24
|
|
25 ngx_int_t fails;
|
|
26 time_t accessed;
|
|
27 } ngx_peer_t;
|
|
28
|
|
29
|
|
30 typedef struct {
|
|
31 ngx_int_t current;
|
|
32 ngx_int_t number;
|
|
33 ngx_int_t max_fails;
|
|
34 ngx_int_t fail_timeout;
|
|
35 ngx_int_t last_cached;
|
|
36
|
|
37 /* ngx_mutex_t *mutex; */
|
|
38 ngx_connection_t **cached;
|
|
39
|
|
40 ngx_peer_t peers[1];
|
|
41 } ngx_peers_t;
|
|
42
|
|
43
|
|
44 typedef struct {
|
|
45 ngx_peers_t *peers;
|
|
46 ngx_int_t cur_peer;
|
|
47 ngx_int_t tries;
|
|
48
|
|
49 ngx_connection_t *connection;
|
|
50 #if (NGX_THREADS)
|
|
51 ngx_atomic_t *lock;
|
|
52 #endif
|
|
53
|
|
54 int rcvbuf;
|
|
55
|
|
56 ngx_log_t *log;
|
|
57
|
|
58 unsigned cached:1;
|
|
59 unsigned log_error:2; /* ngx_connection_log_error_e */
|
|
60 } ngx_peer_connection_t;
|
|
61
|
|
62
|
|
63 int ngx_event_connect_peer(ngx_peer_connection_t *pc);
|
|
64 void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc);
|
|
65
|
|
66
|
|
67 #endif /* _NGX_EVENT_CONNECT_H_INCLUDED_ */
|