mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
fix double release on buffers
This commit is contained in:
parent
12181f527f
commit
fa63beceb6
@ -150,11 +150,6 @@ func fetchInput(ctx context.Context, s *Session, output buf.Writer) {
|
||||
defer s.Close()
|
||||
|
||||
newError("dispatching request to ", dest).WithContext(ctx).WriteToLog()
|
||||
data, _ := s.input.ReadTimeout(time.Millisecond * 500)
|
||||
if err := writer.WriteMultiBuffer(data); err != nil {
|
||||
newError("failed to write first payload").Base(err).WithContext(ctx).WriteToLog()
|
||||
return
|
||||
}
|
||||
if err := buf.Copy(s.input, writer); err != nil {
|
||||
newError("failed to fetch all input").Base(err).WithContext(ctx).WriteToLog()
|
||||
}
|
||||
|
@ -178,14 +178,15 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
|
||||
return newError("failed to write response").Base(err)
|
||||
}
|
||||
|
||||
payload, err := ray.InboundOutput().ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
{
|
||||
payload, err := ray.InboundOutput().ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := responseWriter.WriteMultiBuffer(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := responseWriter.WriteMultiBuffer(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
payload.Release()
|
||||
|
||||
if err := bufferedWriter.SetBuffered(false); err != nil {
|
||||
return err
|
||||
|
@ -182,16 +182,17 @@ func transferResponse(timer signal.ActivityUpdater, session *encoding.ServerSess
|
||||
|
||||
bodyWriter := session.EncodeResponseBody(request, output)
|
||||
|
||||
// Optimize for small response packet
|
||||
data, err := input.ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
{
|
||||
// Optimize for small response packet
|
||||
data, err := input.ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := bodyWriter.WriteMultiBuffer(data); err != nil {
|
||||
return err
|
||||
if err := bodyWriter.WriteMultiBuffer(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
data.Release()
|
||||
|
||||
if bufferedWriter, ok := output.(*buf.BufferedWriter); ok {
|
||||
if err := bufferedWriter.SetBuffered(false); err != nil {
|
||||
|
@ -113,15 +113,16 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
||||
}
|
||||
|
||||
bodyWriter := session.EncodeRequestBody(request, writer)
|
||||
firstPayload, err := input.ReadTimeout(time.Millisecond * 500)
|
||||
if err != nil && err != buf.ErrReadTimeout {
|
||||
return newError("failed to get first payload").Base(err)
|
||||
}
|
||||
if !firstPayload.IsEmpty() {
|
||||
if err := bodyWriter.WriteMultiBuffer(firstPayload); err != nil {
|
||||
return newError("failed to write first payload").Base(err)
|
||||
{
|
||||
firstPayload, err := input.ReadTimeout(time.Millisecond * 500)
|
||||
if err != nil && err != buf.ErrReadTimeout {
|
||||
return newError("failed to get first payload").Base(err)
|
||||
}
|
||||
if !firstPayload.IsEmpty() {
|
||||
if err := bodyWriter.WriteMultiBuffer(firstPayload); err != nil {
|
||||
return newError("failed to write first payload").Base(err)
|
||||
}
|
||||
}
|
||||
firstPayload.Release()
|
||||
}
|
||||
|
||||
if err := writer.SetBuffered(false); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user