]> git.ipfire.org Git - pakfire.git/commitdiff
PTY: Remove the rest of the line buffering code
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 16:11:44 +0000 (16:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 16:11:44 +0000 (16:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/pty.c

index 9f665b3280d8ec1895b5653dc4b98f3d154dfa74..9f87efc43575bb254902d683ca76c7558c2b18ff 100644 (file)
@@ -400,25 +400,11 @@ static int pakfire_pty_fill_buffer(struct pakfire_pty* pty, int fd, struct pakfi
        return bytes_read;
 }
 
-static ssize_t pakfire_pty_send_line(struct pakfire_pty* self,
-               struct pakfire_pty_stdio* stdio, const char* buffer, ssize_t length) {
-       int r;
-
-       // Call the callback
-       r = stdio->callbacks.stdout_callback(self->ctx, stdio->callbacks.data, buffer, length);
-       if (r < 0)
-               return r;
-
-       // We have consumed the entire line
-       return length;
-}
-
 /*
        Writes as much data as possible from the buffer
 */
 static int pakfire_pty_drain_buffer(struct pakfire_pty* pty, int fd, struct pakfire_pty_stdio* stdio) {
        ssize_t bytes_written = 0;
-       char* eol = NULL;
 
        // Map any CRNL to just NL
        if (stdio->io & PAKFIRE_PTY_MAP_CRNL)
@@ -426,20 +412,9 @@ static int pakfire_pty_drain_buffer(struct pakfire_pty* pty, int fd, struct pakf
 
        // Call the callback if possible
        if (stdio->callbacks.stdout_callback) {
-               // Try finding the end of a line
-               eol = memchr(stdio->buffer, '\n', stdio->buffered);
-
-               // No newline found
-               if (!eol) {
-                       if (!pakfire_pty_buffer_is_full(pty, stdio))
-                               return -ENOMSG;
-
-                       DEBUG(pty->ctx, "Buffer is full. Sending all content\n");
-                       eol = stdio->buffer + stdio->buffered - 1;
-               }
-
                // Send the line
-               bytes_written = pakfire_pty_send_line(pty, stdio, stdio->buffer, eol - stdio->buffer + 1);
+               bytes_written = stdio->callbacks.stdout_callback(pty->ctx,
+                               stdio->callbacks.data, stdio->buffer, stdio->buffered);
 
                // Abort on error
                if (bytes_written < 0)
@@ -694,15 +669,6 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) {
                                                }
                                                break;
 
-                                       // This is a special hack for when we have data in the buffer
-                                       // but cannot send it to the callback, yet, because we have not
-                                       // read to the end of the line.
-                                       // To avoid getting stuck in this loop for forever, we simply
-                                       // exit and let the loop call us again.
-                                       case ENOMSG:
-                                               break;
-                                               // return 0;
-
                                        default:
                                                ERROR(pty->ctx, "Failed writing to standard output: %s\n", strerror(-r));
                                                goto ERROR;