Skip to content

Conversation

@Fu-XDU
Copy link

@Fu-XDU Fu-XDU commented Dec 2, 2021

Because of unpredictable network connections during consensus, a deadlock can be caused as below.

At simple_pbft/pbft/network/proxy_server.go

func send(url string, msg []byte) {
	buff := bytes.NewBuffer(msg)
	http.Post("http://"+url, "application/json", buff)
}

http.Post will always wait until its response arrives. While http.Post is waiting, node.MsgDelivery is blocked so that resolveMsg() at simple_pbft/pbft/network/node.go can't deliver other msg. But the premise of the http.Post response’s arrival is that our node has processed the request msg of other nodes, so a deadlock is produced.

To resolve the deadlock, we can use go routine to make node processes other msg while waiting the post response.

func send(url string, msg []byte) {
	buff := bytes.NewBuffer(msg)
	go http.Post("http://"+url, "application/json", buff)
}

@Fu-XDU Fu-XDU marked this pull request as ready for review December 2, 2021 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant