diff options
| author | jEzEk <[email protected]> | 2018-10-27 19:46:38 +0200 |
|---|---|---|
| committer | jEzEk <[email protected]> | 2018-10-27 19:46:38 +0200 |
| commit | 75c4af6d19421197c0ed0486f41b9c4cf302ce9b (patch) | |
| tree | 17339561621c2095c83ed9c535c2990e3a71f897 /cookie.go | |
| parent | 63b50f5e3e8ca11d17c75378b5ddf2fc5b4e0a60 (diff) | |
| parent | 67a5ab1e1a19c2cfc42fd9f539194dd17aafeacb (diff) | |
Merge branch 'connection_close_fix'
Diffstat (limited to 'cookie.go')
| -rw-r--r-- | cookie.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -2,6 +2,7 @@ package xgb import ( "errors" + "io" ) // Cookie is the internal representation of a cookie, where one is generated @@ -80,6 +81,7 @@ func (c Cookie) Reply() ([]byte, error) { // channels. If the former arrives, the bytes are returned with a nil error. // If the latter arrives, no bytes are returned (nil) and the error received // is returned. +// Returns (nil, io.EOF) when the connection is closed. // // Unless you're building requests from bytes by hand, this method should // not be used. @@ -98,6 +100,9 @@ func (c Cookie) replyChecked() ([]byte, error) { return reply, nil case err := <-c.errorChan: return nil, err + case <-c.conn.doneRead: + // c.conn.readResponses is no more, there will be no replys or errors + return nil, io.EOF } } @@ -106,6 +111,7 @@ func (c Cookie) replyChecked() ([]byte, error) { // If the latter arrives, no bytes are returned (nil) and a nil error // is returned. (In the latter case, the corresponding error can be retrieved // from (Wait|Poll)ForEvent asynchronously.) +// Returns (nil, io.EOF) when the connection is closed. // In all honesty, you *probably* don't want to use this method. // // Unless you're building requests from bytes by hand, this method should @@ -121,6 +127,9 @@ func (c Cookie) replyUnchecked() ([]byte, error) { return reply, nil case <-c.pingChan: return nil, nil + case <-c.conn.doneRead: + // c.conn.readResponses is no more, there will be no replys or pings + return nil, io.EOF } } @@ -132,6 +141,7 @@ func (c Cookie) replyUnchecked() ([]byte, error) { // Thus, pingChan is sent a value when the *next* reply is read. // If no more replies are being processed, we force a round trip request with // GetInputFocus. +// Returns io.EOF error when the connection is closed. // // Unless you're building requests from bytes by hand, this method should // not be used. @@ -161,5 +171,8 @@ func (c Cookie) Check() error { return err case <-c.pingChan: return nil + case <-c.conn.doneRead: + // c.conn.readResponses is no more, there will be no errors or pings + return io.EOF } } |
