-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Here's a sample code:
idleChannel := make(chan int8)
for {
interrupted := false
log.Printf("before idle\n");
_, idleErr := c.Idle()
log.Printf("after idle %v\n", idling);
go func() {
log.Printf("receiving data\n");
c.Recv(-1)
log.Printf("received data xx\n");
if (!interrupted) {
idleChannel <- 1 // received
}
}()
log.Printf("select")
timeout := time.After(2 * time.Second)
select {
case value := <- idleChannel:
if (value == 1) {
log.Printf("received data %v\n", c.Data);
}
c.IdleTerm()
case timeValue := <- timeout:
log.Printf("interrupted %v\n", timeValue)
interrupted = true
c.IdleTerm()
log.Printf("interrupted done\n")
}
log.Printf("out of select")
}
When calling, c.IdleTerm() it will interrupt IDLE but the execution flow will be blocked at c.IdleTerm().
The log "interrupted done" won't show.
@iragsdale has a suggestion of fix here:
boxer@796926b
And it seems like it's the right thing to do:
- don't try to read and parse the response in c.IdleTerm()
- let c.Recv() do the receiving and parsing work
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels