File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -194,9 +194,6 @@ func (c *Channel) init() {
194
194
//
195
195
// This will block until the underlying DataChannel has been opened.
196
196
func (c * Channel ) Read (bytes []byte ) (int , error ) {
197
- if c .isClosed () {
198
- return 0 , c .closeError
199
- }
200
197
err := c .waitOpened ()
201
198
if err != nil {
202
199
return 0 , err
@@ -233,9 +230,6 @@ func (c *Channel) Write(bytes []byte) (n int, err error) {
233
230
c .writeMutex .Lock ()
234
231
defer c .writeMutex .Unlock ()
235
232
236
- if c .isClosed () {
237
- return 0 , c .closeWithError (nil )
238
- }
239
233
err = c .waitOpened ()
240
234
if err != nil {
241
235
return 0 , err
@@ -313,7 +307,13 @@ func (c *Channel) isClosed() bool {
313
307
func (c * Channel ) waitOpened () error {
314
308
select {
315
309
case <- c .opened :
316
- return nil
310
+ // Re-check to prioritize the closed channel.
311
+ select {
312
+ case <- c .closed :
313
+ return c .closeError
314
+ default :
315
+ return nil
316
+ }
317
317
case <- c .closed :
318
318
return c .closeError
319
319
}
You can’t perform that action at this time.
0 commit comments