This project is read-only.

Concurrent read / writes - Possible Solution to Problem 2

Aug 18, 2011 at 11:41 AM

Problem 2: Response send too early

It even comes worse: The data are send in chunks. As in Example 1 we assume the server sends "Cursor Line 4/Col1" and "Enter:" as one chunk. Your program waits for "Enter:" and immediately sends a response after finding it. The server side is still busy by sending other data and it might be that the response "gets lost" on the server. Users told me about this phenomenon which seems to happen when you run not a shell but an arbitrary program on server side.

Solution: Try to wait before sending the response, use Wait(int seconds)

A possible technical solution to the problem would be to use a variable and mutex to limit the write thread so that it can only write when not reading.

Any thoughts on this idea?

Aug 18, 2011 at 12:40 PM
Edited Aug 18, 2011 at 3:50 PM

Yes a mutex could(!) solve the problem. Some users have reported back concurrent read / writes and trouble with it. Unfortunately we do not have a precise test scenario showing us, when this happens exactly. Surely we could just implement a mutex (lock) and see, weather this improves such problems. Most of the feedbacks on this issue go like this: "I have moved this part in a lock block and the problem was gone". But I have no idea in which scenario the problem occurred, what telnet server was used, etc. On the other hand, to many locks bear the risk of timeouts, deadlocks etc.

So I would like to encourage every user sharing his/her experience on this issue, so we could come up with a solution for this. Also, everybody can just go ahead, create a fork and implement it.