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

Function rdbPipeWriteHandler

src/replication.cpp:1949–1978  ·  view source on GitHub ↗

Called in diskless master during transfer of data from the rdb pipe, when * the replica becomes writable again. */

Source from the content-addressed store, hash-verified

1947/* Called in diskless master during transfer of data from the rdb pipe, when
1948 * the replica becomes writable again. */
1949void rdbPipeWriteHandler(struct connection *conn) {
1950 serverAssert(g_pserver->rdb_pipe_bufflen>0);
1951 client *slave = (client*)connGetPrivateData(conn);
1952 AssertCorrectThread(slave);
1953 int nwritten;
1954
1955 if (slave->flags & CLIENT_CLOSE_ASAP) {
1956 rdbPipeWriteHandlerConnRemoved(conn);
1957 return;
1958 }
1959
1960 if ((nwritten = connWrite(conn, g_pserver->rdb_pipe_buff + slave->repldboff,
1961 g_pserver->rdb_pipe_bufflen - slave->repldboff)) == -1)
1962 {
1963 if (connGetState(conn) == CONN_STATE_CONNECTED)
1964 return; /* equivalent to EAGAIN */
1965 serverLog(LL_WARNING,"Write error sending DB to replica: %s",
1966 connGetLastError(conn));
1967 freeClientAsync(slave);
1968 return;
1969 } else {
1970 slave->repldboff += nwritten;
1971 g_pserver->stat_net_output_bytes += nwritten;
1972 if (slave->repldboff < g_pserver->rdb_pipe_bufflen) {
1973 slave->repl_last_partial_write = g_pserver->unixtime;
1974 return; /* more data to write.. */
1975 }
1976 }
1977 rdbPipeWriteHandlerConnRemoved(conn);
1978}
1979
1980/* Called in diskless master, when there's data to read from the child's rdb pipe */
1981void rdbPipeReadHandler(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask) {

Callers

nothing calls this directly

Calls 7

connGetPrivateDataFunction · 0.85
connWriteFunction · 0.85
connGetStateFunction · 0.85
serverLogFunction · 0.85
connGetLastErrorFunction · 0.85
freeClientAsyncFunction · 0.85

Tested by

no test coverage detected