Commit 92d562688a1e02e5d6dd2e3de7fc1264288e378c

Authored by Hayk Martirosyan
1 parent bc16f4a1

Fix connection hang between remote machines

Add EVRUN_ONCE evloop call at the start of the event loop thread,
instead of just an EVRUN_NOWAIT call. We want to block until the
connection happens, or else we hang on the condition variable wait.
Showing 1 changed file with 2 additions and 0 deletions
src/client.cpp
@@ -120,6 +120,7 @@ void Redox::connectedCallback(const redisAsyncContext* ctx, int status) { @@ -120,6 +120,7 @@ void Redox::connectedCallback(const redisAsyncContext* ctx, int status) {
120 120
121 if (status != REDIS_OK) { 121 if (status != REDIS_OK) {
122 rdx->logger_.fatal() << "Could not connect to Redis: " << ctx->errstr; 122 rdx->logger_.fatal() << "Could not connect to Redis: " << ctx->errstr;
  123 + rdx->logger_.fatal() << "Status: " << status;
123 rdx->connect_state_ = CONNECT_ERROR; 124 rdx->connect_state_ = CONNECT_ERROR;
124 125
125 } else { 126 } else {
@@ -213,6 +214,7 @@ void breakEventLoop(struct ev_loop* loop, ev_async* async, int revents) { @@ -213,6 +214,7 @@ void breakEventLoop(struct ev_loop* loop, ev_async* async, int revents) {
213 void Redox::runEventLoop() { 214 void Redox::runEventLoop() {
214 215
215 // Events to connect to Redox 216 // Events to connect to Redox
  217 + ev_run(evloop_, EVRUN_ONCE);
216 ev_run(evloop_, EVRUN_NOWAIT); 218 ev_run(evloop_, EVRUN_NOWAIT);
217 219
218 // Block until connected to Redis, or error 220 // Block until connected to Redis, or error