mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
修复在连接读写优化模式下fastcgi无法正常工作的Bug
This commit is contained in:
@@ -105,7 +105,7 @@ func (this *ClientConn) Read(b []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置读超时时间
|
// 设置读超时时间
|
||||||
if this.isHTTP && !this.isWebsocket && !this.isShortReading && this.autoReadTimeout {
|
if this.isHTTP && !this.isPersistent && !this.isShortReading && this.autoReadTimeout {
|
||||||
this.setHTTPReadTimeout()
|
this.setHTTPReadTimeout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ func (this *ClientConn) Write(b []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 延长读超时时间
|
// 延长读超时时间
|
||||||
if this.isHTTP && !this.isWebsocket && this.autoReadTimeout {
|
if this.isHTTP && !this.isPersistent && this.autoReadTimeout {
|
||||||
this.setHTTPReadTimeout()
|
this.setHTTPReadTimeout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ func (this *ClientConn) SetDeadline(t time.Time) error {
|
|||||||
|
|
||||||
func (this *ClientConn) SetReadDeadline(t time.Time) error {
|
func (this *ClientConn) SetReadDeadline(t time.Time) error {
|
||||||
// 如果开启了HTTP自动读超时选项,则自动控制超时时间
|
// 如果开启了HTTP自动读超时选项,则自动控制超时时间
|
||||||
if this.isHTTP && !this.isWebsocket && this.autoReadTimeout {
|
if this.isHTTP && !this.isPersistent && this.autoReadTimeout {
|
||||||
this.isShortReading = false
|
this.isShortReading = false
|
||||||
|
|
||||||
var unixTime = t.Unix()
|
var unixTime = t.Unix()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type BaseClientConn struct {
|
|||||||
remoteAddr string
|
remoteAddr string
|
||||||
hasLimit bool
|
hasLimit bool
|
||||||
|
|
||||||
isWebsocket bool
|
isPersistent bool // 是否为持久化连接
|
||||||
|
|
||||||
isClosed bool
|
isClosed bool
|
||||||
|
|
||||||
@@ -125,6 +125,6 @@ func (this *BaseClientConn) SetLinger(seconds int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *BaseClientConn) SetIsWebsocket(isWebsocket bool) {
|
func (this *BaseClientConn) SetIsPersistent(isPersistent bool) {
|
||||||
this.isWebsocket = isWebsocket
|
this.isPersistent = isPersistent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ type ClientConnInterface interface {
|
|||||||
// UserId 获取当前连接所属服务的用户ID
|
// UserId 获取当前连接所属服务的用户ID
|
||||||
UserId() int64
|
UserId() int64
|
||||||
|
|
||||||
// SetIsWebsocket 设置是否为Websocket
|
// SetIsPersistent 设置是否为持久化
|
||||||
SetIsWebsocket(isWebsocket bool)
|
SetIsPersistent(isPersistent bool)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ func (this *ClientTLSConn) SetWriteDeadline(t time.Time) error {
|
|||||||
return this.rawConn.SetWriteDeadline(t)
|
return this.rawConn.SetWriteDeadline(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ClientTLSConn) SetIsWebsocket(isWebsocket bool) {
|
func (this *ClientTLSConn) SetIsPersistent(isPersistent bool) {
|
||||||
tlsConn, ok := this.rawConn.(*tls.Conn)
|
tlsConn, ok := this.rawConn.(*tls.Conn)
|
||||||
if ok {
|
if ok {
|
||||||
var rawConn = tlsConn.NetConn()
|
var rawConn = tlsConn.NetConn()
|
||||||
if rawConn != nil {
|
if rawConn != nil {
|
||||||
clientConn, ok := rawConn.(*ClientConn)
|
clientConn, ok := rawConn.(*ClientConn)
|
||||||
if ok {
|
if ok {
|
||||||
clientConn.SetIsWebsocket(isWebsocket)
|
clientConn.SetIsPersistent(isPersistent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,16 @@ func (this *HTTPRequest) doFastcgi() (shouldStop bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置为持久化连接
|
||||||
|
var requestConn = this.RawReq.Context().Value(HTTPConnContextKey)
|
||||||
|
if requestConn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requestClientConn, ok := requestConn.(ClientConnInterface)
|
||||||
|
if ok {
|
||||||
|
requestClientConn.SetIsPersistent(true)
|
||||||
|
}
|
||||||
|
|
||||||
// 连接池配置
|
// 连接池配置
|
||||||
poolSize := fastcgi.PoolSize
|
poolSize := fastcgi.PoolSize
|
||||||
if poolSize <= 0 {
|
if poolSize <= 0 {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func (this *HTTPRequest) doWebsocket(requestHost string, isLastRetry bool) (shou
|
|||||||
|
|
||||||
requestClientConn, ok := requestConn.(ClientConnInterface)
|
requestClientConn, ok := requestConn.(ClientConnInterface)
|
||||||
if ok {
|
if ok {
|
||||||
requestClientConn.SetIsWebsocket(true)
|
requestClientConn.SetIsPersistent(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConn, _, err := this.writer.Hijack()
|
clientConn, _, err := this.writer.Hijack()
|
||||||
|
|||||||
Reference in New Issue
Block a user