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. */
| 1817 | * the rewrite so no more data should be written, and another for the |
| 1818 | * parent to acknowledge it understood this new condition. */ |
| 1819 | int aofCreatePipes(void) { |
| 1820 | int fds[6] = {-1, -1, -1, -1, -1, -1}; |
| 1821 | int j; |
| 1822 | |
| 1823 | if (pipe(fds) == -1) goto error; /* parent -> children data. */ |
| 1824 | if (pipe(fds+2) == -1) goto error; /* children -> parent ack. */ |
| 1825 | if (pipe(fds+4) == -1) goto error; /* parent -> children ack. */ |
| 1826 | /* Parent -> children data is non blocking. */ |
| 1827 | if (anetNonBlock(NULL,fds[0]) != ANET_OK) goto error; |
| 1828 | if (anetNonBlock(NULL,fds[1]) != ANET_OK) goto error; |
| 1829 | if (aeCreateFileEvent(serverTL->el, fds[2], AE_READABLE, aofChildPipeReadable, NULL) == AE_ERR) goto error; |
| 1830 | |
| 1831 | g_pserver->aof_pipe_write_data_to_child = fds[1]; |
| 1832 | g_pserver->aof_pipe_read_data_from_parent = fds[0]; |
| 1833 | g_pserver->aof_pipe_write_ack_to_parent = fds[3]; |
| 1834 | g_pserver->aof_pipe_read_ack_from_child = fds[2]; |
| 1835 | g_pserver->el_alf_pip_read_ack_from_child = serverTL->el; |
| 1836 | g_pserver->aof_pipe_write_ack_to_child = fds[5]; |
| 1837 | g_pserver->aof_pipe_read_ack_from_parent = fds[4]; |
| 1838 | g_pserver->aof_stop_sending_diff = 0; |
| 1839 | return C_OK; |
| 1840 | |
| 1841 | error: |
| 1842 | serverLog(LL_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s", |
| 1843 | strerror(errno)); |
| 1844 | for (j = 0; j < 6; j++) if(fds[j] != -1) close(fds[j]); |
| 1845 | return C_ERR; |
| 1846 | } |
| 1847 | |
| 1848 | void aofClosePipes(void) { |
| 1849 | int fdAofAckPipe = g_pserver->aof_pipe_read_ack_from_child; |
no test coverage detected