Compare commits

..
3 Commits
Author SHA1 Message Date
Fangliding ead185fb84 Interrupt 2026-11-09 22:49:40 +08:00
Fangliding 669c01a5d4 wrap writter 2026-11-09 20:50:10 +08:00
Fangliding bedf31970c Revert "VLESS Multiplex (mux.cool): Apply MutexWriter to avoid concurrent writes to the underlayer"
This reverts commit 5745dea2b4.
2026-11-09 20:19:53 +08:00
4 changed files with 10 additions and 15 deletions
+4
View File
@@ -236,6 +236,10 @@ func (w *BufferedWriter) Close() error {
return common.Close(w.writer) return common.Close(w.writer)
} }
func (w *BufferedWriter) Interrupt() {
common.Interrupt(w.writer)
}
// SequentialWriter is a Writer that writes MultiBuffer sequentially into the underlying io.Writer. // SequentialWriter is a Writer that writes MultiBuffer sequentially into the underlying io.Writer.
type SequentialWriter struct { type SequentialWriter struct {
io.Writer io.Writer
+3 -1
View File
@@ -188,7 +188,9 @@ var (
// NewClientWorker creates a new mux.Client. // NewClientWorker creates a new mux.Client.
func NewClientWorker(stream transport.Link, s ClientStrategy) (*ClientWorker, error) { func NewClientWorker(stream transport.Link, s ClientStrategy) (*ClientWorker, error) {
stream.Writer = &MutexWriter{Writer: stream.Writer} writer := buf.NewBufferedWriter(stream.Writer)
writer.SetBuffered(false)
stream.Writer = writer
c := &ClientWorker{ c := &ClientWorker{
sessionManager: NewSessionManager(), sessionManager: NewSessionManager(),
link: stream, link: stream,
+3 -1
View File
@@ -93,9 +93,11 @@ type ServerWorker struct {
} }
func NewServerWorker(ctx context.Context, d routing.Dispatcher, link *transport.Link) (*ServerWorker, error) { func NewServerWorker(ctx context.Context, d routing.Dispatcher, link *transport.Link) (*ServerWorker, error) {
writer := buf.NewBufferedWriter(link.Writer)
writer.SetBuffered(false)
worker := &ServerWorker{ worker := &ServerWorker{
dispatcher: d, dispatcher: d,
link: &transport.Link{Reader: link.Reader, Writer: &MutexWriter{Writer: link.Writer}}, link: &transport.Link{Reader: link.Reader, Writer: writer},
sessionManager: NewSessionManager(), sessionManager: NewSessionManager(),
done: done.New(), done: done.New(),
timer: time.NewTicker(60 * time.Second), timer: time.NewTicker(60 * time.Second),
-13
View File
@@ -1,8 +1,6 @@
package mux package mux
import ( import (
"sync"
"github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net"
@@ -11,17 +9,6 @@ import (
"github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/session"
) )
type MutexWriter struct {
sync.Mutex
buf.Writer
}
func (w *MutexWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
w.Lock()
defer w.Unlock()
return w.Writer.WriteMultiBuffer(mb)
}
type Writer struct { type Writer struct {
dest net.Destination dest net.Destination
writer buf.Writer writer buf.Writer