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

Function readChildInfo

src/childinfo.cpp:135–159  ·  view source on GitHub ↗

Read child info data from the pipe. * if complete data read into the buffer, * data is stored into *buffer, and returns 1. * otherwise, the partial data is left in the buffer, waiting for the next read, and returns 0. */

Source from the content-addressed store, hash-verified

133 * data is stored into *buffer, and returns 1.
134 * otherwise, the partial data is left in the buffer, waiting for the next read, and returns 0. */
135int readChildInfo(childInfoType *information_type, size_t *cow, monotime *cow_updated, size_t *keys, double* progress) {
136 /* We are using here a static buffer in combination with the server.child_info_nread to handle short reads */
137 static child_info_data buffer;
138 ssize_t wlen = sizeof(buffer);
139
140 /* Do not overlap */
141 if (g_pserver->child_info_nread == wlen) g_pserver->child_info_nread = 0;
142
143 int nread = read(g_pserver->child_info_pipe[0], (char *)&buffer + g_pserver->child_info_nread, wlen - g_pserver->child_info_nread);
144 if (nread > 0) {
145 g_pserver->child_info_nread += nread;
146 }
147
148 /* We have complete child info */
149 if (g_pserver->child_info_nread == wlen) {
150 *information_type = buffer.information_type;
151 *cow = buffer.cow;
152 *cow_updated = buffer.cow_updated;
153 *keys = buffer.keys;
154 *progress = buffer.progress;
155 return 1;
156 } else {
157 return 0;
158 }
159}
160
161/* Receive info data from child. */
162void receiveChildInfo(void) {

Callers 1

receiveChildInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected