… | |
… | |
56 | * client. |
56 | * client. |
57 | */ |
57 | */ |
58 | client::client (int fd, const char *peername) |
58 | client::client (int fd, const char *peername) |
59 | : fd (fd), host (strdup (peername)), |
59 | : fd (fd), host (strdup (peername)), |
60 | socket_ev (this, &client::socket_cb), |
60 | socket_ev (this, &client::socket_cb), |
61 | cmd_ev (this, &client::cmd_cb), |
61 | cmd_ev (this, &client::cmd_cb) |
62 | cc_inv (this), cc_other (this) |
|
|
63 | { |
62 | { |
64 | refcnt_inc (); // the socket is an external reference |
63 | refcnt_inc (); // the socket is an external reference |
65 | |
64 | |
66 | mss = 1500 - 52; // 1500 typical ethernet frame, 66 typical tcp header overhead |
65 | mss = 1500 - 52; // 1500 typical ethernet frame, 66 typical tcp header overhead |
67 | |
66 | |
68 | { |
67 | { |
69 | struct linger linger_opt; |
68 | struct linger linger_opt; |
70 | |
69 | |
71 | linger_opt.l_onoff = 0; |
70 | linger_opt.l_onoff = 0; |
72 | linger_opt.l_linger = 0; |
71 | linger_opt.l_linger = 0; |
73 | |
72 | |
74 | if (setsockopt (fd, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof (struct linger))) |
73 | if (setsockopt (fd, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof (struct linger))) |
75 | LOG (llevError, "SO_LINGER: %s\n", strerror (errno)); |
74 | LOG (llevError, "SO_LINGER: %s\n", strerror (errno)); |
76 | } |
75 | } |
… | |
… | |
90 | LOG (llevError, "TCP_NODELAY: %s\n", strerror (errno)); |
89 | LOG (llevError, "TCP_NODELAY: %s\n", strerror (errno)); |
91 | #endif |
90 | #endif |
92 | |
91 | |
93 | // set some very aggressive keepalive parameters |
92 | // set some very aggressive keepalive parameters |
94 | #ifdef TCP_KEEPIDLE |
93 | #ifdef TCP_KEEPIDLE |
95 | val = 10; |
94 | val = 1; |
96 | if (setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof (val))) |
95 | if (setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof (val))) |
97 | LOG (llevError, "TCP_KEEPIDLE: %s\n", strerror (errno)); |
96 | LOG (llevError, "TCP_KEEPIDLE: %s\n", strerror (errno)); |
98 | #endif |
97 | #endif |
99 | |
98 | |
100 | #ifdef TCP_KEEPCNT |
99 | #ifdef TCP_KEEPCNT |
101 | val = 5; |
100 | val = 3; |
102 | if (setsockopt (fd, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof (val))) |
101 | if (setsockopt (fd, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof (val))) |
103 | LOG (llevError, "TCP_KEEPCNT: %s\n", strerror (errno)); |
102 | LOG (llevError, "TCP_KEEPCNT: %s\n", strerror (errno)); |
104 | #endif |
103 | #endif |
105 | |
104 | |
106 | #ifdef TCP_KEEPINTVL |
105 | #ifdef TCP_KEEPINTVL |
… | |
… | |
221 | last_weight_limit = 0; |
220 | last_weight_limit = 0; |
222 | last_path_attuned = 0; |
221 | last_path_attuned = 0; |
223 | last_path_repelled = 0; |
222 | last_path_repelled = 0; |
224 | last_path_denied = 0; |
223 | last_path_denied = 0; |
225 | last_speed = 0; |
224 | last_speed = 0; |
226 | flags = 0; |
225 | last_flags = 0; |
227 | |
226 | |
228 | static living zero_living; |
227 | static living zero_living; |
229 | last_stats = zero_living; |
228 | last_stats = zero_living; |
230 | } |
229 | } |
231 | |
230 | |
… | |
… | |
236 | cst_tot.time_start = time (NULL); |
235 | cst_tot.time_start = time (NULL); |
237 | cst_lst.time_start = time (NULL); |
236 | cst_lst.time_start = time (NULL); |
238 | |
237 | |
239 | LOG (llevDebug, "Initialize new client/server data\n"); |
238 | LOG (llevDebug, "Initialize new client/server data\n"); |
240 | } |
239 | } |
241 | |
|
|
242 | |
240 | |
243 | /******************************************************************************* |
241 | /******************************************************************************* |
244 | * |
242 | * |
245 | * Start of functions dealing with freeing of the data. |
243 | * Start of functions dealing with freeing of the data. |
246 | * |
244 | * |