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.
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. */
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);