mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add operation_timeout and command_timeout storage backend options
This commit is contained in:
parent
507974a1d8
commit
824b91216f
5 changed files with 22 additions and 6 deletions
|
@ -262,7 +262,8 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
opt.options |= REDIS_OPT_PREFER_IPV4;
|
||||
opt.options |= REDIS_OPT_NOAUTOFREEREPLIES;
|
||||
|
||||
struct timeval timeout = {5, 0};
|
||||
auto connect_timeout_opt = options->GetField<IntervalVal>("connect_timeout")->Get();
|
||||
struct timeval timeout = util::double_to_timeval(connect_timeout_opt);
|
||||
opt.connect_timeout = &timeout;
|
||||
|
||||
// The connection request below should be operation #1.
|
||||
|
@ -300,6 +301,10 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
redisAsyncSetConnectCallback(async_ctx, redisOnConnect);
|
||||
redisAsyncSetDisconnectCallback(async_ctx, redisOnDisconnect);
|
||||
|
||||
auto op_timeout_opt = options->GetField<IntervalVal>("operation_timeout")->Get();
|
||||
struct timeval op_timeout = util::double_to_timeval(op_timeout_opt);
|
||||
redisAsyncSetTimeout(async_ctx, op_timeout);
|
||||
|
||||
// redisAsyncSetConnectCallback sets the flag in the redisPollEvent for writing
|
||||
// so we can add this to our loop as well.
|
||||
zeek::iosource_mgr->RegisterFd(async_ctx->c.fd, this, zeek::iosource::IOSource::WRITE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue