From 5ce1c39f2dc990fe6ecef3e5ef52b59d49227bca Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Jul 2025 04:44:41 +0900 Subject: [PATCH] ptyfwd: do not call pty_forward_done() in do_shovel() 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index 255a62d4b4d..eab81fca806 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -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); -- 2.47.3