cstp_send_file: fixed handling of syscall interrupts

This also increases the buffer size.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
This commit is contained in:
Nikos Mavrogiannopoulos
2020-04-02 15:04:29 +02:00
parent 275ab571b3
commit d551b8badc

View File

@@ -116,7 +116,8 @@ ssize_t cstp_send(worker_st *ws, const void *data,
ssize_t cstp_send_file(worker_st *ws, const char *file)
{
int fd;
char buf[512];
char buf[1024];
int counter = 100; /* allow 10 seconds for a full packet */
ssize_t len, total = 0;
int ret;
@@ -125,7 +126,14 @@ int ret;
return GNUTLS_E_FILE_ERROR;
while ( (len = read( fd, buf, sizeof(buf))) > 0 ||
(len == -1 && (errno == EINTR || errno == EAGAIN))) {
(len == -1 && counter > 0 && (errno == EINTR || errno == EAGAIN))) {
if (len == -1) {
counter--;
ms_sleep(100);
continue;
}
ret = cstp_send(ws, buf, len);
CSTP_FATAL_ERR(ws, ret);