MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sentinelPingReplyCallback

Function sentinelPingReplyCallback

app/redis-6.2.6/src/sentinel.c:2785–2823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2783}
2784
2785void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
2786 sentinelRedisInstance *ri = privdata;
2787 instanceLink *link = c->data;
2788 redisReply *r;
2789
2790 if (!reply || !link) return;
2791 link->pending_commands--;
2792 r = reply;
2793
2794 if (r->type == REDIS_REPLY_STATUS ||
2795 r->type == REDIS_REPLY_ERROR) {
2796 /* Update the "instance available" field only if this is an
2797 * acceptable reply. */
2798 if (strncmp(r->str,"PONG",4) == 0 ||
2799 strncmp(r->str,"LOADING",7) == 0 ||
2800 strncmp(r->str,"MASTERDOWN",10) == 0)
2801 {
2802 link->last_avail_time = mstime();
2803 link->act_ping_time = 0; /* Flag the pong as received. */
2804 } else {
2805 /* Send a SCRIPT KILL command if the instance appears to be
2806 * down because of a busy script. */
2807 if (strncmp(r->str,"BUSY",4) == 0 &&
2808 (ri->flags & SRI_S_DOWN) &&
2809 !(ri->flags & SRI_SCRIPT_KILL_SENT))
2810 {
2811 if (redisAsyncCommand(ri->link->cc,
2812 sentinelDiscardReplyCallback, ri,
2813 "%s KILL",
2814 sentinelInstanceMapCommand(ri,"SCRIPT")) == C_OK)
2815 {
2816 ri->link->pending_commands++;
2817 }
2818 ri->flags |= SRI_SCRIPT_KILL_SENT;
2819 }
2820 }
2821 }
2822 link->last_pong_time = mstime();
2823}
2824
2825/* This is called when we get the reply about the PUBLISH command we send
2826 * to the master to advertise this sentinel. */

Callers

nothing calls this directly

Calls 4

strncmpFunction · 0.85
redisAsyncCommandFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected