mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-08 02:00:43 +08:00
core: process refused TCP data immediately once the connection is ready
If the first TCP data chunk was refused, perhaps due to the connection was under connecting state (it's almost always the case), waiting for timers to process the refused data would introduce a ~250ms (TCP_FAST_INTERVAL) delay for the connection. (from eycorsican/go-tun2socks)
This commit is contained in:
10
core/tcp_conn.go
Normal file → Executable file
10
core/tcp_conn.go
Normal file → Executable file
@@ -64,7 +64,7 @@ type tcpConn struct {
|
||||
localAddr *net.TCPAddr
|
||||
connKeyArg unsafe.Pointer
|
||||
connKey uint32
|
||||
canWrite *sync.Cond // Condition variable to implement TCP back pressure.
|
||||
canWrite *sync.Cond // Condition variable to implement TCP backpressure.
|
||||
state tcpConnState
|
||||
sndPipeReader *io.PipeReader
|
||||
sndPipeWriter *io.PipeWriter
|
||||
@@ -116,6 +116,12 @@ func newTCPConn(pcb *C.struct_tcp_pcb, handler TCPConnHandler) (TCPConn, error)
|
||||
conn.Lock()
|
||||
conn.state = tcpConnected
|
||||
conn.Unlock()
|
||||
|
||||
lwipMutex.Lock()
|
||||
if pcb.refused_data != nil {
|
||||
C.tcp_process_refused_data(pcb)
|
||||
}
|
||||
lwipMutex.Unlock()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -133,11 +139,9 @@ func (conn *tcpConn) LocalAddr() net.Addr {
|
||||
func (conn *tcpConn) SetDeadline(t time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (conn *tcpConn) SetReadDeadline(t time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (conn *tcpConn) SetWriteDeadline(t time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user