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)
}
func (w *BufferedWriter) Interrupt() {
common.Interrupt(w.writer)
}
// SequentialWriter is a Writer that writes MultiBuffer sequentially into the underlying io.Writer.
type SequentialWriter struct {
io.Writer
+3 -1
View File
@@ -188,7 +188,9 @@ var (
// NewClientWorker creates a new mux.Client.
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{
sessionManager: NewSessionManager(),
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) {
writer := buf.NewBufferedWriter(link.Writer)
writer.SetBuffered(false)
worker := &ServerWorker{
dispatcher: d,
link: &transport.Link{Reader: link.Reader, Writer: &MutexWriter{Writer: link.Writer}},
link: &transport.Link{Reader: link.Reader, Writer: writer},
sessionManager: NewSessionManager(),
done: done.New(),
timer: time.NewTicker(60 * time.Second),
-13
View File
@@ -1,8 +1,6 @@
package mux
import (
"sync"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net"
@@ -11,17 +9,6 @@ import (
"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 {
dest net.Destination
writer buf.Writer