diff mbox series

BUGFIX: Handle `EINTR` during network read in `_fill_buffer`.

Message ID YT2PR01MB59834E6D68BC917595D120ABB025A@YT2PR01MB5983.CANPRD01.PROD.OUTLOOK.COM
State Accepted
Headers show
Series BUGFIX: Handle `EINTR` during network read in `_fill_buffer`. | expand

Commit Message

Patrick Bergeron July 29, 2025, 5:03 p.m. UTC
Issue:
When reading from the IPC socket, it is possible the read gets interupted, when this happends it would cause the update process to fail since interupt error isn't handled.

Fix:
When an interupt error is received, retry to read from the file descriptor.

Signed-off-by: Patrick Bergeron <pbergeron@biointelligence.com>
---
 core/cpio_utils.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefano Babic July 29, 2025, 6 p.m. UTC | #1
On 29.07.25 19:03, Patrick Bergeron wrote:
> Issue:
> When reading from the IPC socket, it is possible the read gets interupted, when this happends it would cause the update process to fail since interupt error isn't handled.
> 
> Fix:
> When an interupt error is received, retry to read from the file descriptor.
> 
> Signed-off-by: Patrick Bergeron <pbergeron@biointelligence.com>
> ---
>   core/cpio_utils.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/core/cpio_utils.c b/core/cpio_utils.c
> index f4c61b0f..562943c8 100644
> --- a/core/cpio_utils.c
> +++ b/core/cpio_utils.c
> @@ -72,6 +72,10 @@ static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigne
>   	while (nbytes > 0) {
>   		len = read(fd, buf, nbytes);
>   		if (len < 0) {
> +			if (errno == EINTR) {
> +				continue;
> +			}
> +
>   			ERROR("Failure in stream %d: %s", fd, strerror(errno));
>   			return -EFAULT;
>   		}

Reviewed-by: Stefano Babic <stefano.babic@swupdate.org>
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index f4c61b0f..562943c8 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -72,6 +72,10 @@  static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigne
 	while (nbytes > 0) {
 		len = read(fd, buf, nbytes);
 		if (len < 0) {
+			if (errno == EINTR) {
+				continue;
+			}
+
 			ERROR("Failure in stream %d: %s", fd, strerror(errno));
 			return -EFAULT;
 		}