diff options
author | Anita Zhang <the.anitazha@gmail.com> | 2020-09-08 18:35:27 -0700 |
---|---|---|
committer | Anita Zhang <the.anitazha@gmail.com> | 2020-10-07 16:17:23 -0700 |
commit | e8e9227f5c3f8d47bec1d57a2801b22d53d0b341 (patch) | |
tree | 054fa056683f4ed6e0e774ac127645fe4cf0a2d4 /src/shared/varlink.c | |
parent | 4d824a4e0b008a359adda0e960706316f207047e (diff) | |
download | systemd-e8e9227f5c3f8d47bec1d57a2801b22d53d0b341.tar.gz |
varlink: add server write states to disconnect check
While a server is in the VARLINK_PENDING_METHOD or VARLINK_PENDING_METHOD_MORE
states and its write end is disconnected and it gets a POLLHUP, we
should disconnect since it can't write anymore.
In the case of systemd-oomd disconnecting while pid1 was pending-more, this
condition left pid1 in a state where it started throttling from
continually getting POLLHUP.
Diffstat (limited to 'src/shared/varlink.c')
-rw-r--r-- | src/shared/varlink.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/shared/varlink.c b/src/shared/varlink.c index 86b5f08ae7..fabfe78280 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -418,6 +418,11 @@ static int varlink_test_disconnect(Varlink *v) { if (IN_SET(v->state, VARLINK_IDLE_CLIENT) && (v->write_disconnected || v->got_pollhup)) goto disconnect; + /* The server is still expecting to write more, but its write end is disconnected and it got a POLLHUP + * (i.e. from a disconnected client), so disconnect. */ + if (IN_SET(v->state, VARLINK_PENDING_METHOD, VARLINK_PENDING_METHOD_MORE) && v->write_disconnected && v->got_pollhup) + goto disconnect; + return 0; disconnect: |