mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-02-21 07:25:21 -05:00
avoid message copy deadlock in message writers and stop copy when alert was sent
This commit is contained in:
committed by
Xiaokang Wang (Shelikhoo)
parent
71f1be1b9c
commit
548331dc2b
@@ -165,8 +165,14 @@ func (c *conn) c2sWorker() {
|
||||
}
|
||||
go func() {
|
||||
for c.ctx.Err() == nil {
|
||||
// implicit memory consistency synchronization capture read for c.tls12ExplicitNonce
|
||||
record := <-c.c2sInsert
|
||||
var record *tlsmirror.TLSRecord
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
return
|
||||
case record = <-c.c2sInsert:
|
||||
// implicit memory consistency synchronization capture read for c.tls12ExplicitNonce
|
||||
}
|
||||
|
||||
// memory consistency synchronization for value c.tls12ExplicitNonce is required!!!
|
||||
if *c.tls12ExplicitNonce {
|
||||
if record.RecordType == mirrorcommon.TLSRecord_RecordType_application_data ||
|
||||
@@ -183,6 +189,11 @@ func (c *conn) c2sWorker() {
|
||||
newError("failed to write C2S message").Base(err).AtWarning().WriteToLog()
|
||||
return
|
||||
}
|
||||
if record.RecordType == mirrorcommon.TLSRecord_RecordType_alert {
|
||||
c.done()
|
||||
newError("alert sent, ending copy").AtWarning().WriteToLog()
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
explicitNonceSessionAndChangeCipherSpecWasLastMessage := false
|
||||
@@ -289,8 +300,13 @@ func (c *conn) s2cWorker() {
|
||||
}
|
||||
go func() {
|
||||
for c.ctx.Err() == nil {
|
||||
// implicit memory consistency synchronization capture read for c.tls12ExplicitNonce
|
||||
record := <-c.s2cInsert
|
||||
var record *tlsmirror.TLSRecord
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
return
|
||||
case record = <-c.s2cInsert:
|
||||
// implicit memory consistency synchronization capture read for c.tls12ExplicitNonce
|
||||
}
|
||||
// memory consistency synchronization for value c.tls12ExplicitNonce is required!!!
|
||||
if *c.tls12ExplicitNonce {
|
||||
if record.RecordType == mirrorcommon.TLSRecord_RecordType_application_data ||
|
||||
@@ -307,6 +323,11 @@ func (c *conn) s2cWorker() {
|
||||
newError("failed to write S2C message").Base(err).AtWarning().WriteToLog()
|
||||
return
|
||||
}
|
||||
if record.RecordType == mirrorcommon.TLSRecord_RecordType_alert {
|
||||
c.done()
|
||||
newError("alert sent, ending copy").AtWarning().WriteToLog()
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
explicitNonceSessionAndChangeCipherSpecWasLastMessage := false
|
||||
|
||||
Reference in New Issue
Block a user