DanielT / NitroHack

A fork of NetHack 3.4.3
nitrohack.org
21 stars 2 forks source link

Client freezes when connection to server is lost #9

Closed tung closed 12 years ago

tung commented 12 years ago

A network issue on my end interrupted a game I was playing on nitrohack.org. The game is fine, but my client froze (commit 0f8563a4e3a602957d8ec9137c6b88b91457ab56 i.e. the current head), not even responding to Ctrl+C; I had to kill -9 the client.

The client should handle this case more gracefully, maybe dropping back to the title or server screen.

DanielT commented 12 years ago

What was the network issue? I would like to reproduce this.

NitroHack has lots of error handling built in already; I can disconnect and reconnect my internet connection while playing without ever noticing that the IP address changed because the client will automatically reconnect when errors happen. So the error is likely to be something more complicated, eg a failure in one of the error handling code paths.

tung commented 12 years ago

My router gave out for about an hour or two, so I gave up on the session and wanted to close the client.

If it matters, I was trying to loot from a large box at the time.

DanielT commented 12 years ago

I think I've figured it out.

Commit 29ad5fb25c4fef9f80057252354c410a336a1480 fixes the issue if I guessed the cause correctly.

Basically, if all packets on the connection are going into the bitbucket somewhere rather than generating RST responses or ICMP packets, the kernel cannot figure out that the connection is dead and never returns from read(). So now select() is called first with a timout of 10 seconds. That makes error handling possible.

Also: Ctrl+C never has any effect on NItroHack because it sets raw input mode on the terminal where Ctrl+C is just a key combination like any other.