]> git.ipfire.org Git - pakfire.git/commitdiff
log stream: Avoid infinite loop
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 16:39:11 +0000 (16:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 16:39:11 +0000 (16:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/log_stream.c

index 760dcc1670326f267f8895b7415f7ac0cb9ca1b3..d212d6f8023a4dfb4a0078caee80f8f22c0dbc91 100644 (file)
@@ -162,24 +162,15 @@ static int __pakfire_log_stream(sd_event_source* s, int fd, uint32_t events, voi
        int r = -EINVAL;
 
        if (events & EPOLLIN) {
-               for (;;) {
-                       // Fill the buffer
-                       r = pakfire_log_stream_fill_buffer(stream, fd);
-                       if (r < 0) {
-                               switch (-r) {
-                                       case EAGAIN:
-                                               return 0;
-
-                                       default:
-                                               return r;
-                               }
-                       }
-
-                       // Drain the buffer
-                       r = pakfire_log_stream_drain_buffer(stream);
-                       if (r < 0)
-                               return r;
-               }
+               // Fill the buffer
+               r = pakfire_log_stream_fill_buffer(stream, fd);
+               if (r < 0)
+                       return r;
+
+               // Drain the buffer
+               r = pakfire_log_stream_drain_buffer(stream);
+               if (r < 0)
+                       return r;
        }
 
        // Handle if the child process has closed the file descriptor