1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-11 20:58:27 +03:00

journal-gateway: use journal_add_match_pair() and add_match_boot_id()

This commit is contained in:
Yu Watanabe 2024-03-22 05:26:02 +09:00
parent 8334b36653
commit f936ae2120

View File

@ -22,6 +22,7 @@
#include "fileio.h" #include "fileio.h"
#include "glob-util.h" #include "glob-util.h"
#include "hostname-util.h" #include "hostname-util.h"
#include "journal-internal.h"
#include "journal-remote.h" #include "journal-remote.h"
#include "log.h" #include "log.h"
#include "logs-show.h" #include "logs-show.h"
@ -460,7 +461,6 @@ static mhd_result request_parse_arguments_iterator(
const char *value) { const char *value) {
RequestMeta *m = ASSERT_PTR(cls); RequestMeta *m = ASSERT_PTR(cls);
_cleanup_free_ char *p = NULL;
int r; int r;
if (isempty(key)) { if (isempty(key)) {
@ -512,7 +512,6 @@ static mhd_result request_parse_arguments_iterator(
} }
if (r) { if (r) {
char match[9 + 32 + 1] = "_BOOT_ID=";
sd_id128_t bid; sd_id128_t bid;
r = sd_id128_get_boot(&bid); r = sd_id128_get_boot(&bid);
@ -521,8 +520,7 @@ static mhd_result request_parse_arguments_iterator(
return MHD_NO; return MHD_NO;
} }
sd_id128_to_string(bid, match + 9); r = add_match_boot_id(m->journal, bid);
r = sd_journal_add_match(m->journal, match, sizeof(match)-1);
if (r < 0) { if (r < 0) {
m->argument_parse_error = r; m->argument_parse_error = r;
return MHD_NO; return MHD_NO;
@ -532,13 +530,7 @@ static mhd_result request_parse_arguments_iterator(
return MHD_YES; return MHD_YES;
} }
p = strjoin(key, "=", strempty(value)); r = journal_add_match_pair(m->journal, key, strempty(value));
if (!p) {
m->argument_parse_error = log_oom();
return MHD_NO;
}
r = sd_journal_add_match(m->journal, p, 0);
if (r < 0) { if (r < 0) {
m->argument_parse_error = r; m->argument_parse_error = r;
return MHD_NO; return MHD_NO;