]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: split-out shovel_force()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 19:51:33 +0000 (04:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Jul 2025 16:10:24 +0000 (01:10 +0900)
No functional change. Preparation for later change.

src/shared/ptyfwd.c

index eab81fca8065e2b4ea04ee5984b2a85a427778af..77bd624ec97d0af3e4539055cd2e5c78c4196d3f 100644 (file)
@@ -815,6 +815,19 @@ static int shovel(PTYForward *f) {
         return 0;
 }
 
+static int shovel_force(PTYForward *f) {
+        assert(f);
+
+        if (!f->master_hangup)
+                f->master_writable = f->master_readable = true;
+        if (!f->stdin_hangup)
+                f->stdin_readable = true;
+        if (!f->stdout_hangup)
+                f->stdout_writable = true;
+
+        return shovel(f);
+}
+
 static int on_master_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
         PTYForward *f = ASSERT_PTR(userdata);
 
@@ -883,15 +896,7 @@ static int on_exit_event(sd_event_source *e, void *userdata) {
 
         if (!pty_forward_drain(f)) {
                 /* If not drained, try to drain the buffer. */
-
-                if (!f->master_hangup)
-                        f->master_writable = f->master_readable = true;
-                if (!f->stdin_hangup)
-                        f->stdin_readable = true;
-                if (!f->stdout_hangup)
-                        f->stdout_writable = true;
-
-                r = shovel(f);
+                r = shovel_force(f);
                 if (r < 0)
                         return r;
         }