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

Function aofCreatePipes

app/redis-6.2.6/src/aof.c:1708–1734  ·  view source on GitHub ↗

Create the pipes used for parent - child process IPC during rewrite. * We have a data pipe used to send AOF incremental diffs to the child, * and two other pipes used by the children to signal it finished with * the rewrite so no more data should be written, and another for the * parent to acknowledge it understood this new condition. */

Source from the content-addressed store, hash-verified

1706 * the rewrite so no more data should be written, and another for the
1707 * parent to acknowledge it understood this new condition. */
1708int aofCreatePipes(void) {
1709 int fds[6] = {-1, -1, -1, -1, -1, -1};
1710 int j;
1711
1712 if (pipe(fds) == -1) goto error; /* parent -> children data. */
1713 if (pipe(fds+2) == -1) goto error; /* children -> parent ack. */
1714 if (pipe(fds+4) == -1) goto error; /* parent -> children ack. */
1715 /* Parent -> children data is non blocking. */
1716 if (anetNonBlock(NULL,fds[0]) != ANET_OK) goto error;
1717 if (anetNonBlock(NULL,fds[1]) != ANET_OK) goto error;
1718 if (aeCreateFileEvent(server.el, fds[2], AE_READABLE, aofChildPipeReadable, NULL) == AE_ERR) goto error;
1719
1720 server.aof_pipe_write_data_to_child = fds[1];
1721 server.aof_pipe_read_data_from_parent = fds[0];
1722 server.aof_pipe_write_ack_to_parent = fds[3];
1723 server.aof_pipe_read_ack_from_child = fds[2];
1724 server.aof_pipe_write_ack_to_child = fds[5];
1725 server.aof_pipe_read_ack_from_parent = fds[4];
1726 server.aof_stop_sending_diff = 0;
1727 return C_OK;
1728
1729error:
1730 serverLog(LL_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s",
1731 strerror(errno));
1732 for (j = 0; j < 6; j++) if(fds[j] != -1) close(fds[j]);
1733 return C_ERR;
1734}
1735
1736void aofClosePipes(void) {
1737 aeDeleteFileEvent(server.el,server.aof_pipe_read_ack_from_child,AE_READABLE);

Callers 1

Calls 4

anetNonBlockFunction · 0.85
aeCreateFileEventFunction · 0.85
closeFunction · 0.70
pipeClass · 0.50

Tested by

no test coverage detected