InterNetNews / inn

INN (InterNetNews) Usenet server
https://www.isc.org/othersoftware/#INN
Other
68 stars 12 forks source link

nnrpd: avoid hang due to misplaced select() #270

Closed enrikb closed 1 year ago

enrikb commented 1 year ago

The select() call in nnrpd's input data processing is moved right before the related read() call to avoid blocking when it shouldn't.

Without this change, there could still remain data to be inflated, that has already been read, if compression had been activated. The select() can then time out because the client might already have sent all data before, and the yet to be inflated data will not be used until after the timeout.

Resolves: #269

Julien-Elie commented 1 year ago

Many thanks for your investigation and having provided a patch. I've tested it, and I confirm it fixes the issue (no timeout).

I just changed in line_doread() the return RTtimeout instruction to return -2 as the return values of line_doread() and line_read() are not the same: -2 is the one for RTtimeout in line_doread().

Apart from that, your proposed change seems right to me. I was just wondering whether looping in line_doread() without returning data when zstream_inflate_needed is true wouldn't also do the trick, but well your solution seems to solve the problem.

enrikb commented 1 year ago

Thanks for pointing out the return value issue. I revised the change accordingly.

Julien-Elie commented 1 year ago

Merged in 821b271b58be720e4e3d53d967e91e203d7aa370.