diff --git a/Makefile b/Makefile index 766f956..e72445b 100644 --- a/Makefile +++ b/Makefile @@ -58,13 +58,13 @@ clean: .PHONY: distclean distclean: clean rm -f Doxyfile.local $(LIB)/libredisx.so* $(LIB)/libredisx.a - + # ---------------------------------------------------------------------------- # The nitty-gritty stuff below # ---------------------------------------------------------------------------- -SOURCES = $(SRC)/redisx.c $(SRC)/redisx-net.c $(SRC)/redisx-hooks.c $(SRC)/redisx-io.c $(SRC)/redisx-tab.c $(SRC)/redisx-sub.c +SOURCES = $(SRC)/redisx.c $(SRC)/redisx-net.c $(SRC)/redisx-hooks.c $(SRC)/redisx-client.c $(SRC)/redisx-tab.c $(SRC)/redisx-sub.c # Generate a list of object (obj/*.o) files from the input sources OBJECTS := $(subst $(SRC),$(OBJ),$(SOURCES)) diff --git a/include/redisx.h b/include/redisx.h index 6fa48d9..af3eee7 100644 --- a/include/redisx.h +++ b/include/redisx.h @@ -17,27 +17,31 @@ // Configuration constants -------------------------------------------------------> #ifndef REDIS_TCP_PORT -# define REDIS_TCP_PORT 6379 ///< TCP/IP port on which Redis server listens to clients. +# define REDIS_TCP_PORT 6379 ///< TCP/IP port on which Redis server listens to clients. #endif #ifndef REDIS_TCP_BUF -# define REDIS_TCP_BUF 0 ///< (bytes), <= 0 to use system default. +# define REDIS_TCP_BUF 0 ///< (bytes), <= 0 to use system default. #endif #ifndef REDIS_CMDBUF_SIZE /// (bytes) Size of many internal arrays, and the max. send size. At least ~16 bytes... -# define REDIS_CMDBUF_SIZE 8192 +# define REDIS_CMDBUF_SIZE 8192 #endif #ifndef REDIS_RCV_CHUNK_SIZE /// (bytes) Redis receive buffer size. -# define REDIS_RCV_CHUNK_SIZE 8192 +# define REDIS_RCV_CHUNK_SIZE 8192 +#endif + +#ifndef REDISX_SET_LISTENER_PRIORITY +# define REDISX_SET_LISTENER_PRIORITY FALSE ///< Whether to explicitly set listener thread priorities #endif #ifndef REDISX_LISTENER_REL_PRIORITY /// [0.0:1.0] Listener priority as fraction of available range /// You may want to set it quite high to ensure that the receive buffer is promptly cleared. -# define REDISX_LISTENER_REL_PRIORITY (0.5) +# define REDISX_LISTENER_REL_PRIORITY (0.5) #endif // Various exposed constants -----------------------------------------------------> diff --git a/src/redisx-io.c b/src/redisx-client.c similarity index 97% rename from src/redisx-io.c rename to src/redisx-client.c index 17b40c7..788167c 100644 --- a/src/redisx-io.c +++ b/src/redisx-client.c @@ -616,6 +616,27 @@ RESP *redisxRequest(Redis *redis, const char *command, const char *arg1, const c return redisxArrayRequest(redis, (char **) args, NULL, n, status); } +/** + * Silently consumes a reply from the specified Redis channel. + * + * \param cl Pointer to a Redis channel. + * + * \return X_SUCCESS if a response was successfully consumed, or + * REDIS_NULL if a valid response could not be obtained. + * + */ +int redisxIgnoreReplyAsync(RedisClient *cl) { + static const char *funcName = "redisxIgnoreReplyAsync()"; + RESP *resp; + + if(cl == NULL) return redisxError(funcName, X_NULL); + + resp = redisxReadReplyAsync(cl); + if(resp == NULL) return redisxError(funcName, REDIS_NULL); + else redisxDestroyRESP(resp); + return X_SUCCESS; +} + /** * Reads a response from Redis and returns it. * diff --git a/src/redisx.c b/src/redisx.c index 97c0adf..5ec855a 100644 --- a/src/redisx.c +++ b/src/redisx.c @@ -24,7 +24,7 @@ #if DEBUG #define SET_PRIORITIES FALSE ///< Disable if you want to use gdb to debug... #else -#define SET_PRIORITIES TRUE ///< Disable if you want to use gdb to debug... +#define SET_PRIORITIES REDIS_SET_LISTENER_PRIORITIES ///< Whether to actually set listener priorities #endif #define XPRIO_MIN (sched_get_priority_min(SCHED_RR)) @@ -466,7 +466,7 @@ int redisxPing(Redis *redis, const char *message) { * @sa redisxSelectDB() * @sa redisxLockEnabled() */ -int redisxSelectClientDBAsync(RedisClient *cl, int idx, boolean confirm) { +static int redisxSelectClientDBAsync(RedisClient *cl, int idx, boolean confirm) { static const char *funcName = "redisxSelectClientDBAsync()"; char sval[20]; @@ -648,26 +648,6 @@ int redisxCheckDestroyRESP(RESP *resp, char expectedType, int expectedSize) { return status; } -/** - * Silently consumes a reply from the specified Redis channel. - * - * \param cl Pointer to a Redis channel. - * - * \return X_SUCCESS if a response was successfully consumed, or - * REDIS_NULL if a valid response could not be obtained. - * - */ -int redisxIgnoreReplyAsync(RedisClient *cl) { - static const char *funcName = "redisxIgnoreReplyAsync()"; - RESP *resp; - - if(cl == NULL) return redisxError(funcName, X_NULL); - - resp = redisxReadReplyAsync(cl); - if(resp == NULL) return redisxError(funcName, REDIS_NULL); - else redisxDestroyRESP(resp); - return X_SUCCESS; -} /** * Prints a descriptive error message to stderr, and returns the error code.