… | |
… | |
77 | { |
77 | { |
78 | ev_default_loop (0); |
78 | ev_default_loop (0); |
79 | cleaner.set<tcp_si_map, &tcp_si_map::cleaner_cb> (this); |
79 | cleaner.set<tcp_si_map, &tcp_si_map::cleaner_cb> (this); |
80 | cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2); |
80 | cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2); |
81 | } |
81 | } |
|
|
82 | }; |
82 | |
83 | |
83 | } tcp_si; |
84 | static tcp_si_map tcp_si; |
84 | |
85 | |
85 | struct tcp_connection : ev::io |
86 | struct tcp_connection : ev::io |
86 | { |
87 | { |
87 | int tos; |
88 | int tos; |
88 | tstamp last_activity; |
89 | tstamp last_activity; |
… | |
… | |
116 | |
117 | |
117 | tcp_connection (int fd_, const sockinfo &si_, vpn &v_); |
118 | tcp_connection (int fd_, const sockinfo &si_, vpn &v_); |
118 | ~tcp_connection (); |
119 | ~tcp_connection (); |
119 | }; |
120 | }; |
120 | |
121 | |
|
|
122 | void |
121 | void tcp_si_map::cleaner_cb (ev::timer &w, int revents) |
123 | tcp_si_map::cleaner_cb (ev::timer &w, int revents) |
122 | { |
124 | { |
123 | tstamp to = ev_now () - ::conf.keepalive - 30 - 60; |
125 | tstamp to = ev_now () - ::conf.keepalive - 30 - 60; |
124 | |
126 | |
125 | for (iterator i = begin (); i != end(); ) |
127 | for (iterator i = begin (); i != end(); ) |
126 | if (i->second->last_activity >= to) |
128 | if (i->second->last_activity >= to) |
… | |
… | |
449 | } |
451 | } |
450 | |
452 | |
451 | return state != ERROR; |
453 | return state != ERROR; |
452 | } |
454 | } |
453 | |
455 | |
|
|
456 | void |
454 | void tcp_connection::error () |
457 | tcp_connection::error () |
455 | { |
458 | { |
456 | stop (); |
459 | stop (); |
457 | |
460 | |
458 | if (fd >= 0) |
461 | if (fd >= 0) |
459 | { |
462 | { |