summaryrefslogtreecommitdiff
path: root/src/blocked.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-07-27 09:41:48 +0200
committerantirez <antirez@gmail.com>2015-07-27 14:37:58 +0200
commit32f80e2f1bf42d0508f1114a9dddd91c4719eb8e (patch)
tree66763c2803eb8a91c6b57e5e54e61d454888365c /src/blocked.c
parent40eb548a80797b93cc733876654ff0978d7381cf (diff)
downloadredis-32f80e2f1bf42d0508f1114a9dddd91c4719eb8e.tar.gz
RDMF: More consistent define names.
Diffstat (limited to 'src/blocked.c')
-rw-r--r--src/blocked.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/blocked.c b/src/blocked.c
index c6194a0e7..d22872548 100644
--- a/src/blocked.c
+++ b/src/blocked.c
@@ -34,17 +34,17 @@
* getTimeoutFromObjectOrReply() is just an utility function to parse a
* timeout argument since blocking operations usually require a timeout.
*
- * blockClient() set the REDIS_BLOCKED flag in the client, and set the
- * specified block type 'btype' filed to one of REDIS_BLOCKED_* macros.
+ * blockClient() set the CLIENT_BLOCKED flag in the client, and set the
+ * specified block type 'btype' filed to one of BLOCKED_* macros.
*
* unblockClient() unblocks the client doing the following:
* 1) It calls the btype-specific function to cleanup the state.
- * 2) It unblocks the client by unsetting the REDIS_BLOCKED flag.
+ * 2) It unblocks the client by unsetting the CLIENT_BLOCKED flag.
* 3) It puts the client into a list of just unblocked clients that are
* processed ASAP in the beforeSleep() event loop callback, so that
* if there is some query buffer to process, we do it. This is also
* required because otherwise there is no 'readable' event fired, we
- * already read the pending commands. We also set the REDIS_UNBLOCKED
+ * already read the pending commands. We also set the CLIENT_UNBLOCKED
* flag to remember the client is in the unblocked_clients list.
*
* processUnblockedClients() is called inside the beforeSleep() function
@@ -94,11 +94,11 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int
return C_OK;
}
-/* Block a client for the specific operation type. Once the REDIS_BLOCKED
+/* Block a client for the specific operation type. Once the CLIENT_BLOCKED
* flag is set client query buffer is not longer processed, but accumulated,
* and will be processed when the client is unblocked. */
void blockClient(client *c, int btype) {
- c->flags |= REDIS_BLOCKED;
+ c->flags |= CLIENT_BLOCKED;
c->btype = btype;
server.bpop_blocked_clients++;
}
@@ -115,13 +115,13 @@ void processUnblockedClients(void) {
serverAssert(ln != NULL);
c = ln->value;
listDelNode(server.unblocked_clients,ln);
- c->flags &= ~REDIS_UNBLOCKED;
+ c->flags &= ~CLIENT_UNBLOCKED;
/* Process remaining data in the input buffer, unless the client
* is blocked again. Actually processInputBuffer() checks that the
* client is not blocked before to proceed, but things may change and
* the code is conceptually more correct this way. */
- if (!(c->flags & REDIS_BLOCKED)) {
+ if (!(c->flags & CLIENT_BLOCKED)) {
if (c->querybuf && sdslen(c->querybuf) > 0) {
processInputBuffer(c);
}
@@ -132,22 +132,22 @@ void processUnblockedClients(void) {
/* Unblock a client calling the right function depending on the kind
* of operation the client is blocking for. */
void unblockClient(client *c) {
- if (c->btype == REDIS_BLOCKED_LIST) {
+ if (c->btype == BLOCKED_LIST) {
unblockClientWaitingData(c);
- } else if (c->btype == REDIS_BLOCKED_WAIT) {
+ } else if (c->btype == BLOCKED_WAIT) {
unblockClientWaitingReplicas(c);
} else {
- redisPanic("Unknown btype in unblockClient().");
+ serverPanic("Unknown btype in unblockClient().");
}
/* Clear the flags, and put the client in the unblocked list so that
* we'll process new commands in its query buffer ASAP. */
- c->flags &= ~REDIS_BLOCKED;
- c->btype = REDIS_BLOCKED_NONE;
+ c->flags &= ~CLIENT_BLOCKED;
+ c->btype = BLOCKED_NONE;
server.bpop_blocked_clients--;
/* The client may already be into the unblocked list because of a previous
* blocking operation, don't add back it into the list multiple times. */
- if (!(c->flags & REDIS_UNBLOCKED)) {
- c->flags |= REDIS_UNBLOCKED;
+ if (!(c->flags & CLIENT_UNBLOCKED)) {
+ c->flags |= CLIENT_UNBLOCKED;
listAddNodeTail(server.unblocked_clients,c);
}
}
@@ -155,12 +155,12 @@ void unblockClient(client *c) {
/* This function gets called when a blocked client timed out in order to
* send it a reply of some kind. */
void replyToBlockedClientTimedOut(client *c) {
- if (c->btype == REDIS_BLOCKED_LIST) {
+ if (c->btype == BLOCKED_LIST) {
addReply(c,shared.nullmultibulk);
- } else if (c->btype == REDIS_BLOCKED_WAIT) {
+ } else if (c->btype == BLOCKED_WAIT) {
addReplyLongLong(c,replicationCountAcksByOffset(c->bpop.reploffset));
} else {
- redisPanic("Unknown btype in replyToBlockedClientTimedOut().");
+ serverPanic("Unknown btype in replyToBlockedClientTimedOut().");
}
}
@@ -179,12 +179,12 @@ void disconnectAllBlockedClients(void) {
while((ln = listNext(&li))) {
client *c = listNodeValue(ln);
- if (c->flags & REDIS_BLOCKED) {
+ if (c->flags & CLIENT_BLOCKED) {
addReplySds(c,sdsnew(
"-UNBLOCKED force unblock from blocking operation, "
"instance state changed (master -> slave?)\r\n"));
unblockClient(c);
- c->flags |= REDIS_CLOSE_AFTER_REPLY;
+ c->flags |= CLIENT_CLOSE_AFTER_REPLY;
}
}
}