sd-bus: update peeking into receieved messages, with recent kernel change we need to FREE them after all
This commit is contained in:
parent
e0312f4db0
commit
dcc2fc01fa
|
@ -731,6 +731,7 @@ static int busname_peek_message(BusName *n) {
|
||||||
struct kdbus_cmd_recv cmd_recv = {
|
struct kdbus_cmd_recv cmd_recv = {
|
||||||
.flags = KDBUS_RECV_PEEK,
|
.flags = KDBUS_RECV_PEEK,
|
||||||
};
|
};
|
||||||
|
struct kdbus_cmd_free cmd_free = {};
|
||||||
const char *comm = NULL;
|
const char *comm = NULL;
|
||||||
struct kdbus_item *d;
|
struct kdbus_item *d;
|
||||||
struct kdbus_msg *k;
|
struct kdbus_msg *k;
|
||||||
|
@ -739,11 +740,17 @@ static int busname_peek_message(BusName *n) {
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
/* Generate a friendly debug log message about which process
|
||||||
|
* caused triggering of this bus name. This simply peeks the
|
||||||
|
* metadata of the first queued message and logs it. */
|
||||||
|
|
||||||
assert(n);
|
assert(n);
|
||||||
|
|
||||||
/* Generate a friendly log message about which process caused
|
/* Let's shortcut things a bit, if debug logging is turned off
|
||||||
* triggering of this bus name. This simply peeks the metadata
|
* anyway. */
|
||||||
* of the first queued message and logs it. */
|
|
||||||
|
if (log_get_max_level() < LOG_DEBUG)
|
||||||
|
return 0;
|
||||||
|
|
||||||
r = ioctl(n->starter_fd, KDBUS_CMD_MSG_RECV, &cmd_recv);
|
r = ioctl(n->starter_fd, KDBUS_CMD_MSG_RECV, &cmd_recv);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -795,9 +802,9 @@ finish:
|
||||||
if (p)
|
if (p)
|
||||||
(void) munmap(p, sz);
|
(void) munmap(p, sz);
|
||||||
|
|
||||||
/* Hint: we don't invoke KDBUS_CMD_MSG_FREE here, as we only
|
cmd_free.offset = cmd_recv.offset;
|
||||||
* PEEKed the message, and didn't ask for it to be dropped
|
if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
|
||||||
* from the queue. */
|
log_warning_unit(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue