Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Operations hang forever if attempted after client connection is closed #125

Description

@jhump

Client operations, for example conn.GetW(...), simply enqueue a request on the conn.sendChan and then block for the reply. However, if the client has been shutdown via conn.Close(), subsequent operations should probably fail. Instead, they happily enqueue a request and then block forever since nothing is processing conn.sendChan after the connection is closed.

One possible fix is to simply close sendChan when the connection is closed. This will cause any subsequent operations to panic.

A nicer solution, however, would be to return an error to operations if they are attempted after close. This would require some changes to conn.loop() (or in the go routine that runs it, in Connect(...)) to store a flag indicating that the connection is dead. In conn.queueRequest(...), the code would need to do a select over conn.shouldQuit when trying to store to conn.sendChan in order to skip the request if conn.Close() has been called. To avoid a race, it would also need to check the flag to see if the connection has concurrently become dead after storing the request in sendChan and clean up if so (like by putting an error result into the request's receive channel).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions