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

Function clusterBeforeSleep

app/redis-6.2.6/src/cluster.c:3765–3795  ·  view source on GitHub ↗

This function is called before the event handler returns to sleep for * events. It is useful to perform operations that must be done ASAP in * reaction to events fired but that are not safe to perform inside event * handlers, or to perform potentially expansive tasks that we need to do * a single time before replying to clients. */

Source from the content-addressed store, hash-verified

3763 * handlers, or to perform potentially expansive tasks that we need to do
3764 * a single time before replying to clients. */
3765void clusterBeforeSleep(void) {
3766 int flags = server.cluster->todo_before_sleep;
3767
3768 /* Reset our flags (not strictly needed since every single function
3769 * called for flags set should be able to clear its flag). */
3770 server.cluster->todo_before_sleep = 0;
3771
3772 if (flags & CLUSTER_TODO_HANDLE_MANUALFAILOVER) {
3773 /* Handle manual failover as soon as possible so that won't have a 100ms
3774 * as it was handled only in clusterCron */
3775 if(nodeIsSlave(myself)) {
3776 clusterHandleManualFailover();
3777 if (!(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER))
3778 clusterHandleSlaveFailover();
3779 }
3780 } else if (flags & CLUSTER_TODO_HANDLE_FAILOVER) {
3781 /* Handle failover, this is needed when it is likely that there is already
3782 * the quorum from masters in order to react fast. */
3783 clusterHandleSlaveFailover();
3784 }
3785
3786 /* Update the cluster state. */
3787 if (flags & CLUSTER_TODO_UPDATE_STATE)
3788 clusterUpdateState();
3789
3790 /* Save the config, possibly using fsync. */
3791 if (flags & CLUSTER_TODO_SAVE_CONFIG) {
3792 int fsync = flags & CLUSTER_TODO_FSYNC_CONFIG;
3793 clusterSaveConfigOrDie(fsync);
3794 }
3795}
3796
3797void clusterDoBeforeSleep(int flags) {
3798 server.cluster->todo_before_sleep |= flags;

Callers 1

beforeSleepFunction · 0.85

Calls 4

clusterUpdateStateFunction · 0.85
clusterSaveConfigOrDieFunction · 0.85

Tested by

no test coverage detected