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

Function loadSentinelConfigFromQueue

src/sentinel.cpp:1847–1904  ·  view source on GitHub ↗

This function is used for loading the sentinel configuration from * pre_monitor_cfg, monitor_cfg and post_monitor_cfg list */

Source from the content-addressed store, hash-verified

1845/* This function is used for loading the sentinel configuration from
1846 * pre_monitor_cfg, monitor_cfg and post_monitor_cfg list */
1847void loadSentinelConfigFromQueue(void) {
1848 const char *err = NULL;
1849 listIter li;
1850 listNode *ln;
1851 int linenum = 0;
1852 sds line = NULL;
1853
1854 /* if there is no sentinel_config entry, we can return immediately */
1855 if (g_pserver->sentinel_config == NULL) return;
1856
1857 /* loading from pre monitor config queue first to avoid dependency issues */
1858 listRewind(g_pserver->sentinel_config->pre_monitor_cfg,&li);
1859 while((ln = listNext(&li))) {
1860 struct sentinelLoadQueueEntry *entry = (sentinelLoadQueueEntry*)ln->value;
1861 err = sentinelHandleConfiguration(entry->argv,entry->argc);
1862 if (err) {
1863 linenum = entry->linenum;
1864 line = entry->line;
1865 goto loaderr;
1866 }
1867 }
1868
1869 /* loading from monitor config queue */
1870 listRewind(g_pserver->sentinel_config->monitor_cfg,&li);
1871 while((ln = listNext(&li))) {
1872 struct sentinelLoadQueueEntry *entry = (sentinelLoadQueueEntry*)ln->value;
1873 err = sentinelHandleConfiguration(entry->argv,entry->argc);
1874 if (err) {
1875 linenum = entry->linenum;
1876 line = entry->line;
1877 goto loaderr;
1878 }
1879 }
1880
1881 /* loading from the post monitor config queue */
1882 listRewind(g_pserver->sentinel_config->post_monitor_cfg,&li);
1883 while((ln = listNext(&li))) {
1884 struct sentinelLoadQueueEntry *entry = (sentinelLoadQueueEntry*)ln->value;
1885 err = sentinelHandleConfiguration(entry->argv,entry->argc);
1886 if (err) {
1887 linenum = entry->linenum;
1888 line = entry->line;
1889 goto loaderr;
1890 }
1891 }
1892
1893 /* free sentinel_config when config loading is finished */
1894 freeSentinelConfig();
1895 return;
1896
1897loaderr:
1898 fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n",
1899 KEYDB_REAL_VERSION);
1900 fprintf(stderr, "Reading the configuration file, at line %d\n", linenum);
1901 fprintf(stderr, ">>> '%s'\n", line);
1902 fprintf(stderr, "%s\n", err);
1903 exit(1);
1904}

Callers 1

mainFunction · 0.85

Calls 4

listRewindFunction · 0.85
listNextFunction · 0.85
freeSentinelConfigFunction · 0.85

Tested by

no test coverage detected