logind: use the new FDSTOREREMOVE=1 sd_notify() message
Let's explicitly tell PID 1 that we don't need an fd anymore, instead of relying exclusively on POLLERR/POLLHUP for it to be removed. Fixes: #6908
This commit is contained in:
parent
e78ee06de1
commit
4050e47976
|
@ -410,6 +410,17 @@ error:
|
||||||
void session_device_free(SessionDevice *sd) {
|
void session_device_free(SessionDevice *sd) {
|
||||||
assert(sd);
|
assert(sd);
|
||||||
|
|
||||||
|
if (sd->pushed_fd) {
|
||||||
|
const char *m;
|
||||||
|
|
||||||
|
/* Remove the pushed fd again, just in case. */
|
||||||
|
|
||||||
|
m = strjoina("FDSTOREREMOVE=1\n"
|
||||||
|
"FDNAME=session-", sd->session->id);
|
||||||
|
|
||||||
|
(void) sd_notify(false, m);
|
||||||
|
}
|
||||||
|
|
||||||
session_device_stop(sd);
|
session_device_stop(sd);
|
||||||
session_device_notify(sd, SESSION_DEVICE_RELEASE);
|
session_device_notify(sd, SESSION_DEVICE_RELEASE);
|
||||||
close_nointr(sd->fd);
|
close_nointr(sd->fd);
|
||||||
|
@ -489,26 +500,30 @@ unsigned int session_device_try_pause_all(Session *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_device_save(SessionDevice *sd) {
|
int session_device_save(SessionDevice *sd) {
|
||||||
_cleanup_free_ char *state = NULL;
|
const char *m;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(sd);
|
assert(sd);
|
||||||
|
|
||||||
/* Store device fd in PID1. It will send it back to us on
|
/* Store device fd in PID1. It will send it back to us on restart so revocation will continue to work. To make
|
||||||
* restart so revocation will continue to work. To make things
|
* things simple, send fds for all type of devices even if they don't support the revocation mechanism so we
|
||||||
* simple, send fds for all type of devices even if they don't
|
* don't have to handle them differently later.
|
||||||
* support the revocation mechanism so we don't have to handle
|
|
||||||
* them differently later.
|
|
||||||
*
|
*
|
||||||
* Note: for device supporting revocation, PID1 will drop a
|
* Note: for device supporting revocation, PID1 will drop a stored fd automatically if the corresponding device
|
||||||
* stored fd automatically if the corresponding device is
|
* is revoked. */
|
||||||
* revoked. */
|
|
||||||
r = asprintf(&state, "FDSTORE=1\n"
|
|
||||||
"FDNAME=session-%s", sd->session->id);
|
|
||||||
if (r < 0)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
return sd_pid_notify_with_fds(0, false, state, &sd->fd, 1);
|
if (sd->pushed_fd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
m = strjoina("FDSTORE=1\n"
|
||||||
|
"FDNAME=session", sd->session->id);
|
||||||
|
|
||||||
|
r = sd_pid_notify_with_fds(0, false, m, &sd->fd, 1);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
sd->pushed_fd = true;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_device_attach_fd(SessionDevice *sd, int fd, bool active) {
|
void session_device_attach_fd(SessionDevice *sd, int fd, bool active) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct SessionDevice {
|
||||||
int fd;
|
int fd;
|
||||||
bool active;
|
bool active;
|
||||||
DeviceType type;
|
DeviceType type;
|
||||||
|
bool pushed_fd;
|
||||||
|
|
||||||
LIST_FIELDS(struct SessionDevice, sd_by_device);
|
LIST_FIELDS(struct SessionDevice, sd_by_device);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue