mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Redis: return proper error if connection fails
This commit is contained in:
parent
d929392a76
commit
0fb4548ff0
4 changed files with 38 additions and 3 deletions
|
@ -634,7 +634,7 @@ void Redis::HandleInfoResult(redisReply* reply) {
|
|||
}
|
||||
|
||||
void Redis::OnConnect(int status) {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection event");
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection event, status=%d", status);
|
||||
--active_ops;
|
||||
|
||||
connected = false;
|
||||
|
@ -644,7 +644,7 @@ void Redis::OnConnect(int status) {
|
|||
|
||||
if ( status == REDIS_ERR ) {
|
||||
// TODO: do something with the error?
|
||||
DBG_LOG(DBG_STORAGE, "INFO command failed: %s", async_ctx->errstr);
|
||||
DBG_LOG(DBG_STORAGE, "INFO command failed: %s err=%d", async_ctx->errstr, async_ctx->err);
|
||||
CompleteCallback(open_cb,
|
||||
{ReturnCode::OPERATION_FAILED,
|
||||
util::fmt("INFO command failed to retrieve server info: %s", async_ctx->errstr)});
|
||||
|
@ -653,12 +653,17 @@ void Redis::OnConnect(int status) {
|
|||
|
||||
++active_ops;
|
||||
}
|
||||
else {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: connection failed: %s err=%d", async_ctx->errstr, async_ctx->err);
|
||||
CompleteCallback(open_cb,
|
||||
{ReturnCode::CONNECTION_FAILED, util::fmt("Connection failed: %s", async_ctx->errstr)});
|
||||
}
|
||||
|
||||
// TODO: we could attempt to reconnect here
|
||||
}
|
||||
|
||||
void Redis::OnDisconnect(int status) {
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: disconnection event");
|
||||
DBG_LOG(DBG_STORAGE, "Redis backend: disconnection event, status=%d", status);
|
||||
|
||||
connected = false;
|
||||
if ( status == REDIS_ERR ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue