-
Similar to the fixes for subscriber, without holding the waiter_lock_, updating the waiting_done_ flag may cause deadlock. In the deadlock example below, Thread1 is waiting for the response, thread 2 is processing the response and updating the waiter_lock_ variable: ---------------------------------------------------- | Thread 1 | Thread 2 | ---------------------------------------------------- | locks 'waiter_lock_' | | | check 'waiting_done_' | | | | Update 'waiting done' | | | Send notification | | begin waiting for signal | | | *deadlocked* | | ----------------------------------------------------
-
Instructions in README, some minor changes to comments.
-
This enables full support for binary data, with no tokenization needed and all the assumptions that come with that. All of the core methods are changed to accept vector<string>& instead of string&. Ported all examples and tutorial as well.
-
Call Redox::disconnectCallback from processReply
-
Configure CMake to generate libredox.so and libredox_static.a, and have all examples use the dynamic library. This is how Redox should be used in practice, and greatly reduces the compilation time of the examples. Also renamed redox.[ch]pp to client.[ch]pp and created one master header redox.hpp for users to include. This header right now just includes client.hpp, command.hpp, and subscriber.hpp.
-
Make .free() on commands send a message over an async watcher to the event loop, just like adding commands. This gets rid of some very tough to find memory bugs. Combined .cancel() with .free(), so there is only one method to call, whether for synchronous commands or for looped commands. Also debug some horrible segfaults related to Subscriber. Something is odd with hiredis and subscriptions, need to ask them. It seems when we flood with commands it doesn't disconnect cleanly. Look for a way to wait until all commands are processed.
-
Conform (mostly) to Google C++ guidelines. Apache license notice and link above each core file.
-
Using free_guard_ as the same mutex in .reply() causes deadlock when a callback accesses .reply(). Make a separate mutex.
-
Also make cmd.reply() copy the value and use a mutex to make it thread safe. No noticable speed hits, probably thanks to RVO.
-
Split up command into command, command_blocking, and command_looping. The original command no longer returns anything, which clarifies how it should be used in most cases. command_looping and command_blocking both return a command object. Also added a waiting CV to the Command object, though it is not used in command_blocking yet.
-
Now, there is only one callback for command(), and it returns a const reference to the Command object. The user is responsible for error checking using c.ok(), c.status(), and getting the reply with c.reply(). This significantly cleans up the library code and the user code. Greatly refactored the data type specialization code in command.cpp.
-
* Member variables with trailing underscore * Methods camelCase * Explicit template instantiation, move definitions to .cpp * Reorder methods to make more sense * Limit public API, comment well
-
utils/logger.[ch]pp gives a logger implementation based on ostringstream that is pretty nice. I took this from Stack Overflow and added some things to make syntax nicer. Changed all cout and cerr statements in Redox to be of the form logger.{debug/info/warning/error/fatal}() << stuff. Arguments for non-printed statements are still evaluated. Gives a performance hit if we actually add statements on every callback and run speed tests. For most use cases, doesn't matter. For now, not including such low level output anyway. Would be nice to have a macro to leave out/include the low-level logs at compile-time. -
Implemented limited but useful binary data support without breaking the API. If the last character of the command is a ", look for the first ", and everything in between the quotes treat as binary data. Takes care of setting a key with a binary value. Not useful if there need to be multiple binary entries in one command, or for binary keys. Also need to be careful if the last character of the value actually needs to be a quote, in which case we need to quote the value.
-
Useful based on what kind of data you need.
-
Also plan to add in set<string> and unordered_set<string>. Maybe queue<string>. Looking at likely removing char* as an option, if it shows to be about the same speed as string.
-
Fixed a couple of bugs found with a test case of 100 parallel asynchronous clients. As of now, there are no known memory leaks, segfaults, or deadlocks in Redox.
-
Take that, hours of debugging memory leaks! Did lots of structural tweaks to more smartly keep track of commands and make sure everything is evenutally freed from the heap.
-
Added Command<nullptr_t> which successfully returns NIL replies from Redis, with REDOX_OK. Also renamed constants from REDISX_ -> REDOX_. Moved a bunch of code from redox.cpp into command.cpp, where it logically makes more sense.