mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-04 21:47:16 +03:00
util: Remove virPipeReadUntilEOF
Unused since 3c269b51a6f03a1a678e8d Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6864d8f740
commit
1bb063f69c
@ -3226,7 +3226,6 @@ virMemoryMaxValue;
|
||||
virParseNumber;
|
||||
virParseOwnershipIds;
|
||||
virParseVersionString;
|
||||
virPipeReadUntilEOF;
|
||||
virScaleInteger;
|
||||
virSetBlocking;
|
||||
virSetCloseExec;
|
||||
|
@ -191,88 +191,6 @@ int virSetSockReuseAddr(int fd, bool fatal)
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
virPipeReadUntilEOF(int outfd, int errfd,
|
||||
char **outbuf, char **errbuf) {
|
||||
|
||||
struct pollfd fds[2];
|
||||
size_t i;
|
||||
bool finished[2];
|
||||
|
||||
fds[0].fd = outfd;
|
||||
fds[0].events = POLLIN;
|
||||
fds[0].revents = 0;
|
||||
finished[0] = false;
|
||||
fds[1].fd = errfd;
|
||||
fds[1].events = POLLIN;
|
||||
fds[1].revents = 0;
|
||||
finished[1] = false;
|
||||
|
||||
while (!(finished[0] && finished[1])) {
|
||||
|
||||
if (poll(fds, ARRAY_CARDINALITY(fds), -1) < 0) {
|
||||
if ((errno == EAGAIN) || (errno == EINTR))
|
||||
continue;
|
||||
goto pollerr;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(fds); ++i) {
|
||||
char data[1024], **buf;
|
||||
int got, size;
|
||||
|
||||
if (!(fds[i].revents))
|
||||
continue;
|
||||
else if (fds[i].revents & POLLHUP)
|
||||
finished[i] = true;
|
||||
|
||||
if (!(fds[i].revents & POLLIN)) {
|
||||
if (fds[i].revents & POLLHUP)
|
||||
continue;
|
||||
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Unknown poll response."));
|
||||
goto error;
|
||||
}
|
||||
|
||||
got = read(fds[i].fd, data, sizeof(data));
|
||||
|
||||
if (got == sizeof(data))
|
||||
finished[i] = false;
|
||||
|
||||
if (got == 0) {
|
||||
finished[i] = true;
|
||||
continue;
|
||||
}
|
||||
if (got < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN)
|
||||
break;
|
||||
goto pollerr;
|
||||
}
|
||||
|
||||
buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
|
||||
size = (*buf ? strlen(*buf) : 0);
|
||||
if (VIR_REALLOC_N(*buf, size+got+1) < 0)
|
||||
goto error;
|
||||
memmove(*buf+size, data, got);
|
||||
(*buf)[size+got] = '\0';
|
||||
}
|
||||
continue;
|
||||
|
||||
pollerr:
|
||||
virReportSystemError(errno,
|
||||
"%s", _("poll error"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
VIR_FREE(*outbuf);
|
||||
VIR_FREE(*errbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Convert C from hexadecimal character to integer. */
|
||||
int
|
||||
|
@ -41,9 +41,6 @@ int virSetInherit(int fd, bool inherit) ATTRIBUTE_RETURN_CHECK;
|
||||
int virSetCloseExec(int fd) ATTRIBUTE_RETURN_CHECK;
|
||||
int virSetSockReuseAddr(int fd, bool fatal) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
int virPipeReadUntilEOF(int outfd, int errfd,
|
||||
char **outbuf, char **errbuf);
|
||||
|
||||
int virSetUIDGID(uid_t uid, gid_t gid, gid_t *groups, int ngroups);
|
||||
int virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
||||
unsigned long long capBits,
|
||||
|
Loading…
x
Reference in New Issue
Block a user