MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelPingReplyCallback

Function sentinelPingReplyCallback

src/sentinel.cpp:2797–2835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

redisAsyncCommandFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected