Hi
Just wondering if anyone has found the same problem. Quick outlay:
Create a thread. Inside the thread create a TServerSocket. In TServerSocket's OnRead event, at tbe beginning of the OnRead function, I put in a criticalsection->acquire, (the criticalsection is globally defined) to ensure only one socket read at a time is handled. Works lovely, but if 2 requests (reads) come in VERY close to each other, the acquire happens twice, before a release has been called.
I even put it all in a try .. finally, but before the lock is released, it is acquired. How I found out was to put a line of code writing to my logging area right after the acquire part. Quite strange to see "lock acquired", and right after that again "lock acquired".
Regards.
Just wondering if anyone has found the same problem. Quick outlay:
Create a thread. Inside the thread create a TServerSocket. In TServerSocket's OnRead event, at tbe beginning of the OnRead function, I put in a criticalsection->acquire, (the criticalsection is globally defined) to ensure only one socket read at a time is handled. Works lovely, but if 2 requests (reads) come in VERY close to each other, the acquire happens twice, before a release has been called.
I even put it all in a try .. finally, but before the lock is released, it is acquired. How I found out was to put a line of code writing to my logging area right after the acquire part. Quite strange to see "lock acquired", and right after that again "lock acquired".
Regards.