Commit 650df0f9 authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

Don't do a write(2) after QUIT

This causes non-deterministic error messages because sometimes the
socket will already be closed and sometimes it is yet to be closed.
parent 74254a3b
...@@ -178,24 +178,20 @@ static void test_blocking_connection() { ...@@ -178,24 +178,20 @@ static void test_blocking_connection() {
if (major >= 2 && minor > 0) { if (major >= 2 && minor > 0) {
/* > 2.0 returns OK on QUIT and read() should be issued once more /* > 2.0 returns OK on QUIT and read() should be issued once more
* to know the descriptor is at EOF. */ * to know the descriptor is at EOF. */
test_cond(strcasecmp(reply->str,"OK") == 0 && redisCommand(c,"PING") == NULL); test_cond(strcasecmp(reply->str,"OK") == 0 &&
redisGetReply(c,(void**)&reply) == REDIS_ERR);
freeReplyObject(reply); freeReplyObject(reply);
} else { } else {
test_cond(reply == NULL); test_cond(reply == NULL);
} }
/* Two conditions may happen, depending on the type of connection. /* On 2.0, QUIT will cause the connection to be closed immediately and
* When connected via TCP, the socket will not yet be aware of the closed * the read(2) for the reply on QUIT will set the error to EOF.
* connection and the write(2) call will succeed, but the read(2) will * On >2.0, QUIT will return with OK and another read(2) needed to be
* result in an EOF. When connected via Unix sockets, the socket will be * issued to find out the socket was closed by the server. In both
* immediately aware that it was closed and fail on the write(2) call. */ * conditions, the error will be set to EOF. */
if (use_unix) {
assert(c->err == REDIS_ERR_IO &&
strcmp(c->errstr,"Broken pipe") == 0);
} else {
assert(c->err == REDIS_ERR_EOF && assert(c->err == REDIS_ERR_EOF &&
strcmp(c->errstr,"Server closed the connection") == 0); strcmp(c->errstr,"Server closed the connection") == 0);
}
/* Clean up context and reconnect again */ /* Clean up context and reconnect again */
redisFree(c); redisFree(c);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment