This is an helper for moduleFireServerEvent() and other functions: * It populates the replication info structure with the appropriate * fields depending on the version provided. If the version is not valid * then REDISMODULE_ERR is returned. Otherwise the function returns * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */
| 1947 | * then REDISMODULE_ERR is returned. Otherwise the function returns |
| 1948 | * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */ |
| 1949 | int modulePopulateReplicationInfoStructure(void *ri, int structver) { |
| 1950 | if (structver != 1) return REDISMODULE_ERR; |
| 1951 | |
| 1952 | RedisModuleReplicationInfoV1 *ri1 = ri; |
| 1953 | memset(ri1,0,sizeof(*ri1)); |
| 1954 | ri1->version = structver; |
| 1955 | ri1->master = server.masterhost==NULL; |
| 1956 | ri1->masterhost = server.masterhost? server.masterhost: ""; |
| 1957 | ri1->masterport = server.masterport; |
| 1958 | ri1->replid1 = server.replid; |
| 1959 | ri1->replid2 = server.replid2; |
| 1960 | ri1->repl1_offset = server.master_repl_offset; |
| 1961 | ri1->repl2_offset = server.second_replid_offset; |
| 1962 | return REDISMODULE_OK; |
| 1963 | } |
| 1964 | |
| 1965 | /* Return information about the client with the specified ID (that was |
| 1966 | * previously obtained via the RedisModule_GetClientId() API). If the |
no test coverage detected