MCPcopy Create free account
hub / github.com/ceph/ceph / readpipe

Function readpipe

src/log/test.cc:173–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173static void readpipe(int fd, int verify)
174{
175 while (1) {
176 /* Use larger buffer on receiver as Linux will allow pipes buffers to
177 * exceed PIPE_BUF. We can't avoid tearing due to small read buffers from
178 * the Ceph side.
179 */
180
181 char buf[65536] = "";
182 int rc = read(fd, buf, (sizeof buf) - 1);
183 if (rc == 0) {
184 _exit(0);
185 } else if (rc == -1) {
186 _exit(1);
187 } else if (rc > 0) {
188 if (verify) {
189 char* p = strrchr(buf, '\n');
190 /* verify no torn writes */
191 if (p == NULL) {
192 _exit(2);
193 } else if (p[1] != '\0') {
194 std::ignore = write(2, buf, strlen(buf));
195 _exit(3);
196 }
197 }
198 } else _exit(100);
199 usleep(500);
200 }
201}
202
203TEST(Log, StderrPipeAtomic)
204{

Callers 1

TESTFunction · 0.85

Calls 2

readFunction · 0.50
writeFunction · 0.50

Tested by

no test coverage detected