mranney/node_redis — pull request #190 by bnoguchi (2012-03-13 06:07:16+00:00)
Title: Pub sub mode fix

Failure will occur in the following scenario:

A single-subscription client (i.e., a client that called subscribe just once before) calls unsubscribe immediately followed by a subscribe (the 2nd call to subscribe). It will fail when it tries to receive the next pmessage/message because the client will be in false pub_sub_mode.

Here is why it will have false pub_sub_mode:

First, the 2nd subscribe sets pub_sub_mode to true during send_command. Next, the unsubscribe's return_reply sets pub_sub_mode to false. The 2nd subscribe's return_reply does not re-set pub_sub_mode back to true. So the result is a client with false pub_sub_mode that fails upon receipt of the next message or pmessage.

This pull request adds both a test to demonstrate the failing scenario and a fix for it that sets pub_sub_mode to true upon receipt of a subscribe reply.