… | |
… | |
61 | |
61 | |
62 | struct tcp_si_map : public map<const sockinfo *, tcp_connection *, lt_sockinfo> { |
62 | struct tcp_si_map : public map<const sockinfo *, tcp_connection *, lt_sockinfo> { |
63 | void cleaner_cb (time_watcher &w); time_watcher cleaner; |
63 | void cleaner_cb (time_watcher &w); time_watcher cleaner; |
64 | |
64 | |
65 | tcp_si_map () |
65 | tcp_si_map () |
66 | : cleaner(this, &tcp_si_map::cleaner_cb) |
66 | : cleaner(this, &tcp_si_map::cleaner_cb) |
67 | { |
|
|
68 | cleaner.start (0); |
|
|
69 | } |
67 | { } |
|
|
68 | |
70 | } tcp_si; |
69 | } tcp_si; |
71 | |
70 | |
72 | struct tcp_connection : io_watcher { |
71 | struct tcp_connection : io_watcher { |
73 | tstamp last_activity; |
72 | tstamp last_activity; |
74 | const sockinfo si; |
73 | const sockinfo si; |
… | |
… | |
93 | bool write_packet (); |
92 | bool write_packet (); |
94 | |
93 | |
95 | void error (); // abort conenction && cleanup |
94 | void error (); // abort conenction && cleanup |
96 | |
95 | |
97 | operator tcp_si_map::value_type() |
96 | operator tcp_si_map::value_type() |
98 | { |
97 | { |
99 | return tcp_si_map::value_type (&si, this); |
98 | return tcp_si_map::value_type (&si, this); |
100 | } |
99 | } |
101 | |
100 | |
102 | tcp_connection (int fd_, const sockinfo &si_, vpn &v_); |
101 | tcp_connection (int fd_, const sockinfo &si_, vpn &v_); |
103 | ~tcp_connection (); |
102 | ~tcp_connection (); |
104 | }; |
103 | }; |
105 | |
104 | |
… | |
… | |
448 | } |
447 | } |
449 | |
448 | |
450 | tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) |
449 | tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) |
451 | : v(v_), si(si_), io_watcher(this, &tcp_connection::tcpv4_ev) |
450 | : v(v_), si(si_), io_watcher(this, &tcp_connection::tcpv4_ev) |
452 | { |
451 | { |
|
|
452 | if (!tcp_si.cleaner.active) |
|
|
453 | tcp_si.cleaner.start (0); |
|
|
454 | |
453 | last_activity = NOW; |
455 | last_activity = NOW; |
454 | r_pkt = 0; |
456 | r_pkt = 0; |
455 | w_pkt = 0; |
457 | w_pkt = 0; |
456 | fd = fd_; |
458 | fd = fd_; |
457 | #if ENABLE_HTTP_PROXY |
459 | #if ENABLE_HTTP_PROXY |