mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
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:
18
src/tlslib.c
18
src/tlslib.c
@@ -115,17 +115,25 @@ 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];
|
||||
ssize_t len, total = 0;
|
||||
int ret;
|
||||
int fd;
|
||||
char buf[1024];
|
||||
int counter = 100; /* allow 10 seconds for a full packet */
|
||||
ssize_t len, total = 0;
|
||||
int ret;
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd == -1)
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user