connection.go | 3 ++- diff --git a/connection.go b/connection.go index 148f362430ccb079f9bd4787eae7f9e10f21bc5c..4c2a1d2556cf2c0976971fd99970545dbfc1ebbb 100644 --- a/connection.go +++ b/connection.go @@ -334,10 +334,11 @@ // Writes buffers to the socket from the write channel. func (conn *connection) writer() { // Reduce write syscalls. buf := bufio.NewWriterSize(conn.Socket, 0x8000) // 32 KiB - // Returns immediately if the buffer contains data. + // Receives when buf is not empty. notEmpty := make(chan struct{}, 1) for { if buf.Buffered() != 0 { + // Make sure it's receivable. select { case notEmpty <- struct{}{}: default: