goshuirc / bnc

a simple irc bouncer written in go
https://goshubnc.org/
MIT License
17 stars 3 forks source link

Replace listener socket.go #37

Open prawnsalad opened 7 years ago

prawnsalad commented 7 years ago

It's logic is very.. awkward, and the whole finaldata thing to close a socket is very weird to use.

DanielOaks commented 7 years ago

When we do this, remind me to do a bunch of stress-testing on it (and specifically to keep in mind the memory usage/leaking resulting from sockets not closing correctly). The old socket was much simpler but wrecked us because it'd never completely return and close properly.

The reason why finaldata exists is because when we close because of an error or because the sendq/receiveq is overrun, I want to always make sure the final error/etc is sent indicating that problem. if you just .Send() the error then close the socket, a lot of the time in testing it wouldn't correctly output that before the socket got closed (iirc when the socket was being used in the ircd).