You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by "bbennett-ks (via GitHub)" <gi...@apache.org> on 2026/03/06 22:23:40 UTC
[PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
bbennett-ks opened a new pull request, #643:
URL: https://github.com/apache/guacamole-server/pull/643
## Summary
This PR hardens blocking I/O and wait paths against signal interruption (EINTR).
When a signal is delivered (e.g. when a child process exits), some blocking syscalls can return early with -1 with **errno = EINTR** . This is not a hard failure: the syscall should be retried.
This PR adds EINTR retry loops around blocking calls in various guacamole-server. Equivalent handling for the Windows equivalent was also added.
Without retry, signal (async) delivery can cause a variety of errors: network connections errors, read/write failures, premature timeouts...
# select Handling
` int select(int nfds, fd_set *_Nullable restrict readfds,
fd_set *_Nullable restrict writefds,
fd_set *_Nullable restrict exceptfds,
struct timeval *_Nullable restrict timeout);
`
Special care has been taken with the **select** system call, as it has parameters which are modified by the system: how these parameters are handled on retry must be considered. Based on the Linux man page:
`On error, -1 is returned, and is set to indicate the error;
the file descriptor sets are unmodified, and timeout becomes
undefined.`
**select** retry is based on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2966702246
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
Review Comment:
Fixed, by adding documenting.
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
Review Comment:
Fixed, by adding documenting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2966715618
##########
src/protocols/ssh/ssh.c:
##########
@@ -22,6 +22,7 @@
#include "argv.h"
#include "common-ssh/sftp.h"
#include "common-ssh/ssh.h"
+#include "eintr.h"
Review Comment:
Fixed, moved to `src/libguac/guacamole/error.h`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2994612062
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
Fixed & verified by fresh clone.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2900063735
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
> There's a _lot_ of this pattern repeated. If possible, I think we should pull anything like:
>
> ```c
> do {
> retval = do_thing(params);
> } while (retval < 0 && errno == EINTR);
> ```
>
> into libguac functions/macros that can be reused instead of duplicated.
Does this approach look good?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2899379932
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
There's a _lot_ of this pattern repeated. If possible, I think we should pull this into libguac functions/macros that can be reused instead of duplicated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2994544318
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
Odd, it looks good to me:
<img width="703" height="188" alt="image" src="https://github.com/user-attachments/assets/bb5dfefb-6186-45b2-a80d-19533a4a3dfd" />
But if I do a fresh clone, I do see tabs, I wonder if there's an issue with whitespace only changes in git; I'll reformat so there's non-white space comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2916820131
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
+ *
+ * @param expression
+ * Expression (function) to run.
+ */
+#define GUAC_EINTR_RETRY(retval, expression) \
Review Comment:
This might live better in the established `guacamole/file.h` (or at least something more specific to retrying and less specific to a single error code).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2921503450
##########
src/protocols/ssh/ssh.c:
##########
@@ -22,6 +22,7 @@
#include "argv.h"
#include "common-ssh/sftp.h"
#include "common-ssh/ssh.h"
+#include "eintr.h"
Review Comment:
Also: for these macros to be usable outside libguac, they'll need to be in a public header instead of an internal header.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2981357501
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
+ /* Structure that stores our timeout setting. On Linux, select() updates
+ timeout with the remaining time on EINTR, so no need to reinitialize on
+ retry. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ GUAC_RETRY_EINTR(retval, select(fd + 1, NULL, &fdset, NULL, &tv));
Review Comment:
I updated comments to clarify in the 2 places we call `select()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2936330480
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
+ *
+ * @param expression
+ * Expression (function) to run.
+ */
+#define GUAC_EINTR_RETRY(retval, expression) \
Review Comment:
Sure - makes sense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#issuecomment-4015054410
- I didn't check for **send/recvmsg()**: updated.
- Also, mention of **1998** made me think of another **select()** issue: **fd_set** overflow: updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2922021794
##########
src/libguac/socket-wsa.c:
##########
@@ -93,7 +93,10 @@ ssize_t guac_socket_wsa_write(guac_socket* socket,
/* Write until completely written */
while (count > 0) {
- int retval = send(data->sock, buffer, count, 0);
+ int retval;
+ do {
+ retval = send(data->sock, buffer, count, 0);
+ } while (retval < 0 && WSAGetLastError() == WSAEINTR);
Review Comment:
Sounds good, add `GUAC_RETRY_UNTIL()` (and use it here) and modify `GUAC_EINTR_RETRY()` to use it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2993467357
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
I'm still seeing the wonky spacing:

Am I seeing stale/cached content?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2980049119
##########
src/libguac/socket-wsa.c:
##########
@@ -134,7 +136,10 @@ static ssize_t guac_socket_wsa_read_handler(guac_socket* socket,
guac_socket_wsa_data* data = (guac_socket_wsa_data*) socket->data;
/* Read from socket */
- int retval = recv(data->sock, buf, count, 0);
+ int retval;
+ do {
+ retval = recv(data->sock, buf, count, 0);
+ } while (retval < 0 && WSAGetLastError() == WSAEINTR);
Review Comment:
This should be a `GUAC_RETRY_UNTIL()`.
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
+ /* Structure that stores our timeout setting. On Linux, select() updates
+ timeout with the remaining time on EINTR, so no need to reinitialize on
+ retry. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ GUAC_RETRY_EINTR(retval, select(fd + 1, NULL, &fdset, NULL, &tv));
Review Comment:
Does the `fd_set` need to be reinitialized here before each retry? (Possibly same with the `struct timeval`?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2900049464
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2899379932
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
There's a _lot_ of this pattern repeated. If possible, I think we should pull this anything like:
```c
do {
retval = dothing(params);
} while (retval < 0 && errno == EINTR);
```
into libguac functions/macros that can be reused instead of duplicated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2916737745
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
Review Comment:
Failing doesn't necessarily always mean returning a negative value - we should either document that here or provide a means to define the failure condition.
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
+ *
+ * @param expression
+ * Expression (function) to run.
+ */
+#define GUAC_EINTR_RETRY(retval, expression) \
Review Comment:
This might live better in the established `guacamole/file.h`.
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
Review Comment:
We should elaborate here such that it's clear how this function should be called. From the perspective of someone needing to provide a value for the `retval` parameter, it's unclear what "return value" means without reading through and understanding the implementation of this macro.
##########
src/libguac/socket-wsa.c:
##########
@@ -93,7 +93,10 @@ ssize_t guac_socket_wsa_write(guac_socket* socket,
/* Write until completely written */
while (count > 0) {
- int retval = send(data->sock, buffer, count, 0);
+ int retval;
+ do {
+ retval = send(data->sock, buffer, count, 0);
+ } while (retval < 0 && WSAGetLastError() == WSAEINTR);
Review Comment:
If we allow the macro to include the failure test, this could also be turned into an invocation of that macro.
We could even continue to provide `GUAC_EINTR_RETRY()` as a convenience macro leveraging the broader macro... something like `GUAC_RETRY_UNTIL()` and `GUAC_RETRY_IGNORE_EINTR()`, maybe.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2899379932
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
There's a _lot_ of this pattern repeated. If possible, I think we should pull anything like:
```c
do {
retval = do_thing(params);
} while (retval < 0 && errno == EINTR);
```
into libguac functions/macros that can be reused instead of duplicated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#issuecomment-4014783024
Looks pretty good to me, @bbennett-ks. Just going to see if @mike-jumper has any comments or concerns before merging this. I'm wondering if this will help resolve some of the other bugs we have lingering, like 1998, which deals with hung processes and the like.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2993467357
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
I'm still seeing the wonky spacing:

Am I seeing stale/cached content?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2985039825
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
This line appears to have a couple of tabs instead of spaces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2966705321
##########
src/libguac/socket-wsa.c:
##########
@@ -93,7 +93,10 @@ ssize_t guac_socket_wsa_write(guac_socket* socket,
/* Write until completely written */
while (count > 0) {
- int retval = send(data->sock, buffer, count, 0);
+ int retval;
+ do {
+ retval = send(data->sock, buffer, count, 0);
+ } while (retval < 0 && WSAGetLastError() == WSAEINTR);
Review Comment:
Fixed, GUAC_RETRY_UNTIL() (and use it here) and modify GUAC_EINTR_RETRY().
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2981223657
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
+ /* Structure that stores our timeout setting. On Linux, select() updates
+ timeout with the remaining time on EINTR, so no need to reinitialize on
+ retry. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ GUAC_RETRY_EINTR(retval, select(fd + 1, NULL, &fdset, NULL, &tv));
Review Comment:
I'd seen many opinions on these 2 issues so I did a deep dive into the Linux kernel and glibc source code to be sure:
- `fd_set` is not modified if `select` returns -1.
- `struct timeval` is modified if `select()` returns -1 and `errno = EINTR` to reflect the elapsed time. Leaving `tv` unmodified on retry means the original timeout value is observed, even on retry.
#2 is Linux specific behavior, not behavior as defined by POSIX.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2985258101
##########
src/libguac/tcp.c:
##########
@@ -97,20 +97,33 @@ int guac_tcp_connect(const char* hostname, const char* port, const int timeout)
continue;
}
- /* Structure that stores our timeout setting. */
struct timeval tv;
tv.tv_sec = timeout;
tv.tv_usec = 0;
/* Connect and wait for timeout */
if ((retval = connect(fd, current_address->ai_addr, current_address->ai_addrlen)) < 0) {
- if (errno == EINPROGRESS) {
- /* Set up timeout. */
+ /* If connect() is in progress (EINPROGRESS) or interrupted by a signal
+ * (EINTR), wait for the socket to become writable and check SO_ERROR. */
+ if (errno == EINPROGRESS || errno == EINTR) {
+
+ /* Prevent overflowing fd_set. */
+ if (fd >= FD_SETSIZE) {
+ guac_error = GUAC_STATUS_INVALID_ARGUMENT;
+ guac_error_message = "File descriptor exceeds FD_SETSIZE.";
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
-
- retval = select(fd + 1, NULL, &fdset, NULL, &tv);
+
+ /* Linux (kernel/glibc verified): select() does not modify fd_set on -1,
+ and updates struct timeval to reflect elapsed time on EINTR, so
+ neither needs reinitialization on retry. */
Review Comment:
Fixed. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#issuecomment-4024267579
After looking at kernel & glib source, I have a few more changes I'd like to make. I've changed the PR back to a draft.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2899379932
##########
src/common/io.c:
##########
@@ -29,7 +30,10 @@ int guac_common_write(int fd, void* buffer, int length) {
while (length > 0) {
/* Attempt write */
- int bytes_written = write(fd, bytes, length);
+ int bytes_written;
+ do {
+ bytes_written = write(fd, bytes, length);
+ } while (bytes_written < 0 && errno == EINTR);
Review Comment:
There's a _lot_ of this pattern repeated. If possible, I think we should pull anything like:
```c
do {
retval = dothing(params);
} while (retval < 0 && errno == EINTR);
```
into libguac functions/macros that can be reused instead of duplicated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2921871287
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
+ *
+ * @param expression
+ * Expression (function) to run.
+ */
+#define GUAC_EINTR_RETRY(retval, expression) \
Review Comment:
I was thinking **src/libguac/guacamole/error.h** (**#include <guacamole/error.h>**) would be an optimal choice, and would make it available for downstream projects.
```/**
* Provides functions and structures required for handling return values and
* errors.
*
* @file error.h
*/```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2921879337
##########
src/protocols/ssh/ssh.c:
##########
@@ -22,6 +22,7 @@
#include "argv.h"
#include "common-ssh/sftp.h"
#include "common-ssh/ssh.h"
+#include "eintr.h"
Review Comment:
I wasn't sure how making this part of a public header would be received, but I think overall this is the best solution. Better than having logic replicated by downstream projects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2966714185
##########
src/libguac/eintr.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_EINTR_H
+#define GUAC_EINTR_H
+
+#include <errno.h>
+
+/**
+ * Execute the expression and retry if it fails with errno =
+ * EINTR.
+ *
+ * @param retval
+ * Return value.
+ *
+ * @param expression
+ * Expression (function) to run.
+ */
+#define GUAC_EINTR_RETRY(retval, expression) \
Review Comment:
Fixed, moved to `src/libguac/guacamole/error.h`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#issuecomment-4015063291
> Looks pretty good to me, @bbennett-ks. Just going to see if @mike-jumper has any comments or concerns before merging this. I'm wondering if this will help resolve some of the other bugs we have lingering, like 1998, which deals with hung processes and the like.
An instance of this issue (GUACAMOLE-2239) was identified as the core cause of one intermittent issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper merged PR #643:
URL: https://github.com/apache/guacamole-server/pull/643
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GUACAMOLE-2238: Multiple guacamole-server code paths do not correctly… [guacamole-server]
Posted by "bbennett-ks (via GitHub)" <gi...@apache.org>.
bbennett-ks commented on code in PR #643:
URL: https://github.com/apache/guacamole-server/pull/643#discussion_r2981254689
##########
src/libguac/socket-wsa.c:
##########
@@ -134,7 +136,10 @@ static ssize_t guac_socket_wsa_read_handler(guac_socket* socket,
guac_socket_wsa_data* data = (guac_socket_wsa_data*) socket->data;
/* Read from socket */
- int retval = recv(data->sock, buf, count, 0);
+ int retval;
+ do {
+ retval = recv(data->sock, buf, count, 0);
+ } while (retval < 0 && WSAGetLastError() == WSAEINTR);
Review Comment:
Update to use `GUAC_RETRY_UNTIL()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org