stchang / redis

A redis client for Racket.
17 stars 4 forks source link

Fixed up some race conditions. #5

Closed m4burns closed 9 years ago

m4burns commented 9 years ago

2265ce5: My changes introduced a race between connection release due to calling disconnect and connection release due to thread termination. This is fixed.

ec98067: I modified (P)(UN)SUBSCRIBE to not read a response. Using SUBSCRIBE/UNSUBSCRIBE when at least one channel has been subscribed to could read an incoming message instead of the command response. I added proper handling of this in the connection pool return code: channels are unsubscribed and any remaining messages are drained before the connection is returned to the pool. Finally, I added a synchronizable event for getting the next reply, the synchronization result of which is the reply.

stchang commented 9 years ago

Thanks again for your work on this.

Question: would you mind if I added a current-redis-pool parameter? It should be thread safe since your pools only allocates one connection per thread right?

m4burns commented 9 years ago

That would be great. I chose to make the connection and pool polymorphic for maximum backward compatibility, but it's kinda awkward. Yeah, it should be thread safe.