]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: do not call pty_forward_done() in do_shovel()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 19:44:41 +0000 (04:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Jul 2025 16:10:24 +0000 (01:10 +0900)
Previously, do_shovel() sometimes call pty_forward_done(), and
its caller shovel() also call pty_forward_done(). Let's move all
pty_forward_done() calls to shovel(), and do_shovel() not call it.

No functional change, just refactoring.

src/shared/ptyfwd.c

index 255a62d4b4d4296b07400d636d757aefbc99893e..eab81fca8065e2b4ea04ee5984b2a85a427778af 100644 (file)
@@ -786,6 +786,18 @@ static int do_shovel(PTYForward *f) {
                         break;
         }
 
+        return 0;
+}
+
+static int shovel(PTYForward *f) {
+        int r;
+
+        assert(f);
+
+        r = do_shovel(f);
+        if (r < 0)
+                return pty_forward_done(f, r);
+
         if (f->stdin_hangup || f->stdout_hangup || f->master_hangup) {
                 /* Exit the loop if any side hung up and if there's
                  * nothing more to write or nothing we could write. */
@@ -803,18 +815,6 @@ static int do_shovel(PTYForward *f) {
         return 0;
 }
 
-static int shovel(PTYForward *f) {
-        int r;
-
-        assert(f);
-
-        r = do_shovel(f);
-        if (r < 0)
-                return pty_forward_done(f, r);
-
-        return r;
-}
-
 static int on_master_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
         PTYForward *f = ASSERT_PTR(userdata);