ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn_tcp.C
(Generate patch)

Comparing gvpe/src/vpn_tcp.C (file contents):
Revision 1.18 by pcg, Sat Nov 10 19:43:37 2007 UTC vs.
Revision 1.19 by pcg, Tue Nov 13 02:12:08 2007 UTC

21 21
22#include "config.h" 22#include "config.h"
23 23
24#if ENABLE_TCP 24#if ENABLE_TCP
25 25
26// tcp processing is extremely ugly, since the vpe protocol is simply 26// tcp processing is extremely ugly, since the gvpe protocol is simply
27// designed for unreliable datagram networks. tcp is implemented by 27// designed for unreliable datagram networks. tcp is implemented by
28// multiplexing packets over tcp. errors are completely ignored, as we 28// multiplexing packets over tcp. errors are completely ignored, as we
29// rely on the higher level protocol to time out and reconnect. 29// rely on the higher level layers to time out and reconnect.
30 30
31#include <cstring> 31#include <cstring>
32 32
33#include <sys/types.h> 33#include <sys/types.h>
34#include <sys/socket.h> 34#include <sys/socket.h>
63 void cleaner_cb (ev::timer &w, int revents); ev::timer cleaner; 63 void cleaner_cb (ev::timer &w, int revents); ev::timer 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 { 67 {
68 cleaner.start (300, 300); 68 cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2);
69 } 69 }
70 70
71} tcp_si; 71} tcp_si;
72 72
73struct tcp_connection : ev::io { 73struct tcp_connection : ev::io {
111 for (iterator i = begin (); i != end(); ) 111 for (iterator i = begin (); i != end(); )
112 if (i->second->last_activity >= to) 112 if (i->second->last_activity >= to)
113 ++i; 113 ++i;
114 else 114 else
115 { 115 {
116 delete i->second;
116 erase (i); 117 erase (i);
117 i = begin (); 118 i = begin ();
118 } 119 }
119} 120}
120 121
452} 453}
453 454
454tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) 455tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_)
455: v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) 456: v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev)
456{ 457{
457 if (!tcp_si.cleaner.active)
458 tcp_si.cleaner.start (0);
459
460 last_activity = ev::ev_now (); 458 last_activity = ev::ev_now ();
461 r_pkt = 0; 459 r_pkt = 0;
462 w_pkt = 0; 460 w_pkt = 0;
463 fd = fd_; 461 fd = fd_;
464#if ENABLE_HTTP_PROXY 462#if ENABLE_HTTP_PROXY

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines