mirror of
https://github.com/systemd/systemd.git
synced 2025-03-13 00:58:27 +03:00
varlink: add new helper that reports whether connection is idle
This is useful to allow event loops to run exactly as long as there's something to do but not longer.
This commit is contained in:
parent
5e71f86dff
commit
8240fa920d
@ -1282,6 +1282,15 @@ int varlink_wait(Varlink *v, usec_t timeout) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int varlink_is_idle(Varlink *v) {
|
||||
assert_return(v, -EINVAL);
|
||||
|
||||
/* Returns true if there's nothing pending on the connection anymore, i.e. we processed all incoming
|
||||
* or outgoing messages fully, or finished disconnection */
|
||||
|
||||
return IN_SET(v->state, VARLINK_DISCONNECTED, VARLINK_IDLE_CLIENT, VARLINK_IDLE_SERVER);
|
||||
}
|
||||
|
||||
int varlink_get_fd(Varlink *v) {
|
||||
|
||||
assert_return(v, -EINVAL);
|
||||
|
@ -71,6 +71,8 @@ sd_event *varlink_get_event(Varlink *v);
|
||||
int varlink_process(Varlink *v);
|
||||
int varlink_wait(Varlink *v, usec_t timeout);
|
||||
|
||||
int varlink_is_idle(Varlink *v);
|
||||
|
||||
int varlink_flush(Varlink *v);
|
||||
int varlink_close(Varlink *v);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user