OpenPHDGuiding / phd2

PHD2 Guiding
https://openphdguiding.org
BSD 3-Clause "New" or "Revised" License
255 stars 115 forks source link

event server: fix possible problems when client sends multiple requests #1228

Closed agalasso closed 4 months ago

agalasso commented 4 months ago

event server: fix possible problems when client sends multiple requests

The connect command can cause the event loop to run and for the event server to process additional buffered client commands. As the JSON parser instance is reused for all client commands, the parser's state will reflect the most recent client command and may lose the state of the unfinished connect command.

The fix is to not reuse the JsonParser instance -- instantiate a dedicated parser for each client command.

Testing:

agalasso commented 4 months ago

Why would an app spray a stream of messages at the event server?

Agreed, that's probably why we do not hear about this problem. But in theory, an app should be allowed to send a multiple (overlapping) requests and then correlate the responses using the request ids -- we made this work with #780 and #781.

Another way to look at this pr is that it is completing the change started by #780.