-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
redisCommand not blocking when expected #507
Comments
Did you try with enabling keepalive? It might very well that the server closes the connection. |
It's the default |
That sounds weird indeed. I don't have time this week to look into it, but I put it on my list for the following week |
Alright, thanks! I'm going to do some investigation too - I'm going to implement an auto-reconnect into my application anyway so with some more logging and pushing it onto my test server I should have some more information on why this is happening. Strangely I can't reproduce it consistently either, which is annoying... |
Hi, I haven't done any real C++ work in years, but this is almost certainly a memory corruption bug due to threading. I wrote a very simple C program to run BLPOP in a worker thread and hiredis is just fine with it: If you place a The fact that it works sometimes, and other times fails makes me almost certain that this is a threading issue. Cheers! |
While I am always the first one pointing out issues in multi-threaded programs, I don't see a problem with the current usage. It might still be possible for further memory corruption, but a closed socket would probably cause similar problems. |
Just in case you were still thinking about this issue, I've solved it now. You'll be pleased to know that Hiredis is fine! It was some memory corruption on the host app caused by some dodgy SQLite library (the main reason for my implementing Hiredis was to get the SQL code out of the host and into a Go app to do it concurrently via a message queue anyway). Thanks for the replies on the topic anyway, apologies for wasting an issue :) |
:) Thanks for reporting back. |
I have a thread (thread owns its own
redisContext*
, can't use event libs because reasons) and that thread is in awhile
loop with aredisCommand
callingBLPOP
.Now I expected this thread to just wait there for a
LPUSH
, grab the data, do my thing and go back to waiting. It pops one value thencontext->errstr
complains about a "bad file descriptor".So I'm guessing somehow the context has lost the fd at some point while blocking but I can't figure out if this is a bug with hiredis or something I'm missing. I've looked at pretty much every example available. Does the context need a keepalive mechanism or something along those lines? I had a quick look at #168 but my
connected_clients
doesn't appear to be going down so it seems my threaded context is still connected...Here's the wait loop code https://github.com/Southclaws/samp-redis/blob/master/src/impl.cpp#L432-L451
The text was updated successfully, but these errors were encountered: