Skip to content

Potential deadlock with NetworkStreamSession with Websockets #884

Open
@mbrandenburger

Description

@mbrandenburger

The current implementation of the NetworkStreamSession acquires the sessionsMutex and calls close on each stream when closing a session.

With websockets, it may happen that the close call hangs when trying to write c.reads <- streamEOF within the multiplexedBaseConn implementation, see here. This may happen when the connection will closed before c.reads is consumed.

This causes the caller of close to block forever, thus, the sessionMutex in [NetworkStreamSession] is not released anymore.

One approach to overcome this issue is to perform a non-blocking write to c.reads and then complete the close() call.

select {
case c.reads <- streamEOF:
default:
	logger.Warnf("cannot send EOF to close connection")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions