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.
This commit is contained in:
+12
-12
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user