Commit 4679e521 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0853555b
......@@ -152,6 +152,7 @@ type Msg struct {
type _chan struct {
t *T
msgq chan *Msg
down chan struct{} // becomes ready when closed
_name string
}
......@@ -166,16 +167,21 @@ func (ch *_chan) Send(event interface{}) {
fmt.Printf("%s <- %T %v\n", ch.name(), event, event)
}
ack := make(chan error)
ch.msgq <- &Msg{event, ack}
err := <-ack
if err != nil {
ch.t.fatalfInNonMain("%s: send: %s", ch.name(), err)
select {
case <-ch.down:
ch.t.fatalfInNonMain("%s: send: channel was closed", ch.name())
case ch.msgq <- &Msg{event, ack}:
err := <-ack
if err != nil {
ch.t.fatalfInNonMain("%s: send: %s", ch.name(), err)
}
}
}
// Close implements ChanTx.
func (ch *_chan) Close() {
close(ch.msgq)
close(ch.down) // note - not .msgq
}
// Recv implements ChanRx.
......@@ -732,9 +738,6 @@ func (t *T) FailNow() {
default:
}
// in any case close channel where future Sends may arrive so that will panic too.
ch.Close()
}
// order channels by name
......@@ -752,13 +755,17 @@ func (t *T) FailNow() {
}
}
// log the deadlock details and nak all senders.
// log the deadlock details and nak senders that we received from.
// nak them only after deadlock printout, so that the deadlock text
// comes first, and their "panics" don't get intermixed with it.
t.Log(bad)
for _, __ := range sendv {
__.msg.nak("XXX deadlock") // XXX reason can be custom / different
}
// in any case close channel where future Sends may arrive so that will "panic" too.
for _, ch := range streamTab {
ch.Close()
}
t.TB.FailNow()
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment