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

Function clusterWriteHandler

src/cluster.cpp:2303–2318  ·  view source on GitHub ↗

Send data. This is handled using a trivial send buffer that gets * consumed by write(). We don't try to optimize this for speed too much * as this is a very low traffic channel. */

Source from the content-addressed store, hash-verified

2301 * consumed by write(). We don't try to optimize this for speed too much
2302 * as this is a very low traffic channel. */
2303void clusterWriteHandler(connection *conn) {
2304 serverAssert(ielFromEventLoop(serverTL->el) == IDX_EVENT_LOOP_MAIN);
2305 clusterLink *link = (clusterLink*)connGetPrivateData(conn);
2306 ssize_t nwritten;
2307
2308 nwritten = connWrite(conn, link->sndbuf, sdslen(link->sndbuf));
2309 if (nwritten <= 0) {
2310 serverLog(LL_DEBUG,"I/O error writing to node link: %s",
2311 (nwritten == -1) ? connGetLastError(conn) : "short write");
2312 handleLinkIOError(link);
2313 return;
2314 }
2315 sdsrange(link->sndbuf,nwritten,-1);
2316 if (sdslen(link->sndbuf) == 0)
2317 connSetWriteHandler(link->conn, NULL);
2318}
2319
2320/* A connect handler that gets called when a connection to another node
2321 * gets established.

Callers

nothing calls this directly

Calls 9

ielFromEventLoopFunction · 0.85
connGetPrivateDataFunction · 0.85
connWriteFunction · 0.85
sdslenFunction · 0.85
serverLogFunction · 0.85
connGetLastErrorFunction · 0.85
handleLinkIOErrorFunction · 0.85
sdsrangeFunction · 0.85
connSetWriteHandlerFunction · 0.85

Tested by

no test coverage detected