waitsocket(int socket_fd, LIBSSH2_SESSION * session)
{
struct timeval timeout;
- int rc;
fd_set fd;
fd_set *writefd = NULL;
fd_set *readfd = NULL;
if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
writefd = &fd;
- rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
-
- return rc;
+ return select(socket_fd + 1, readfd, writefd, NULL, &timeout);
}
/* this function is the layer that manipulates the ssh channel itself
while ((channel = libssh2_channel_open_session(session)) == NULL &&
libssh2_session_last_error(session, NULL, NULL, 0) ==
LIBSSH2_ERROR_EAGAIN) {
- waitsocket(sock, session);
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
}
if (channel == NULL) {
while ((rc = libssh2_channel_exec(channel, cmd)) ==
LIBSSH2_ERROR_EAGAIN) {
- waitsocket(sock, session);
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
}
if (rc != 0) {
/* this is due to blocking that would occur otherwise so we loop on
* this condition */
if (rc == LIBSSH2_ERROR_EAGAIN) {
- waitsocket(sock, session);
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
} else {
break;
}
exitcode = 127;
while ((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN) {
- waitsocket(sock, session);
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
}
if (rc == 0) {
LIBSSH2_ERROR_EAGAIN) {
goto err;
} else {
- waitsocket(sock, session);
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
}
}
} while (!channel);
/* this is due to blocking that would occur otherwise
* so we loop on this condition */
- waitsocket(sock, session); /* now we wait */
+ /* now we wait */
+ if (waitsocket(sock, session) < 0 && errno != EINTR) {
+ virReportSystemError(errno, "%s",
+ _("unable to wait on libssh2 socket"));
+ goto err;
+ }
continue;
}
break;