-
-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Hi @PatrickRitchie,
I am investigating a bug when ShdrClient constantly disconnects and reconnects to our machine. I found a few suspicious places in the ShdrClient implementation and I would like to discuss and confirm if they are bugs with you before actually proceed with further actions.
The first potential issue is with ShdrClient.ProcessResponse method. It assumes that incoming char buffer always contains full data strings delimited with \n. But what if read from stream happens in the middle of receiving and you get in the buffer partial data string? The "end" of the string come only with next buffer and next char array. I do not see that this case is handled and from what I see partial chunk is non processed in current chunk and the "end" is not processed in next chunk. So one line is dropped and we have data loss.
In case of complete unluckness with timings and small amount of data you can potentially have a lot or even all data items corrupted
So the question is: why are you sure that the situation cannot happen?
The second potential issue is on line 276 of ShdrClient:
In case when DataAvailable and data is read from the stream you still delay further processing by 1 millisecond. I assume that if a machine sends too much data or too often it can lead to the stream buffer overflow as code will not be able to process data fast enough.
I would expect to have Thread.Sleep(1) under line 273 inside of else statement to have "Process data as fast as possible, wait one millisecond otherwise".
The probability of the issue is very low as thread block is only 1 millisecond, machines usually do not send so much data and read buffer is big enough.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
