Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable call methods with a timeout greater than 2142 seconds #73

Open
dsander opened this issue Aug 16, 2021 · 0 comments
Open

Unable call methods with a timeout greater than 2142 seconds #73

dsander opened this issue Aug 16, 2021 · 0 comments

Comments

@dsander
Copy link

dsander commented Aug 16, 2021

Hi! 👋

We noticed that all call that take a timeout argument like brpoplpush do not accept a timeout greater than 2142 seconds.

$ r.brpoplpush('test', 'test2', timeout: 2143)

RangeError: integer 2148000000 too big to convert to `int'
from vendor/bundle/ruby/3.0.0/gems/redis-4.2.5/lib/redis/connection/hiredis.rb:41:in `timeout='

While this might not be a smart use case (a lot of things can happen to the connection within one hour), I believe it should be supported by hiredis-rb because it works with the plain ruby adapter.

I am pretty sure this line causes the exception:

if (NUM2INT(usecs) < 0) {

A bit later in the function the usecs are converted back to seconds.

if (NUM2INT(usecs) > 0) {
ptr = malloc(sizeof(*ptr));
ptr->tv_sec = NUM2INT(usecs) / 1000000;

This makes me think the NUM2INT cast could be done after the division. I didn't send a PR because I am not sure how regirous the validation of the resulting number should be. Is it safe to assume that t_time is always at least a 32bit integer, or are there smarter/safer ways to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant