MCPcopy Index your code
hub / github.com/git/git / pump_io_round

Function pump_io_round

run-command.c:1328–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1326};
1327
1328static int pump_io_round(struct io_pump *slots, int nr, struct pollfd *pfd)
1329{
1330 int pollsize = 0;
1331 int i;
1332
1333 for (i = 0; i < nr; i++) {
1334 struct io_pump *io = &slots[i];
1335 if (io->fd < 0)
1336 continue;
1337 pfd[pollsize].fd = io->fd;
1338 pfd[pollsize].events = io->type;
1339 io->pfd = &pfd[pollsize++];
1340 }
1341
1342 if (!pollsize)
1343 return 0;
1344
1345 if (poll(pfd, pollsize, -1) < 0) {
1346 if (errno == EINTR)
1347 return 1;
1348 die_errno("poll failed");
1349 }
1350
1351 for (i = 0; i < nr; i++) {
1352 struct io_pump *io = &slots[i];
1353
1354 if (io->fd < 0)
1355 continue;
1356
1357 if (!(io->pfd->revents & (POLLOUT|POLLIN|POLLHUP|POLLERR|POLLNVAL)))
1358 continue;
1359
1360 if (io->type == POLLOUT) {
1361 ssize_t len;
1362
1363 /*
1364 * Don't use xwrite() here. It loops forever on EAGAIN,
1365 * and we're in our own poll() loop here.
1366 *
1367 * Note that we lose xwrite()'s handling of MAX_IO_SIZE
1368 * and EINTR, so we have to implement those ourselves.
1369 */
1370 len = write(io->fd, io->u.out.buf,
1371 io->u.out.len <= MAX_IO_SIZE ?
1372 io->u.out.len : MAX_IO_SIZE);
1373 if (len < 0) {
1374 if (errno != EINTR && errno != EAGAIN &&
1375 errno != ENOSPC) {
1376 io->error = errno;
1377 close(io->fd);
1378 io->fd = -1;
1379 }
1380 } else {
1381 io->u.out.buf += len;
1382 io->u.out.len -= len;
1383 if (!io->u.out.len) {
1384 close(io->fd);
1385 io->fd = -1;

Callers 1

pump_ioFunction · 0.85

Calls 3

pollFunction · 0.85
die_errnoFunction · 0.85
strbuf_read_onceFunction · 0.85

Tested by

no test coverage detected