Skip to content

Commit

Permalink
Rename redisx-io to redisx-client and no setting listener prio by def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
attipaci committed Sep 4, 2024
1 parent 7ae03a2 commit 4d2702b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
14 changes: 9 additions & 5 deletions include/redisx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------->
Expand Down
21 changes: 21 additions & 0 deletions src/redisx-io.c → src/redisx-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
24 changes: 2 additions & 22 deletions src/redisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4d2702b

Please sign in to comment.