journal-remote: split out µhttpd support and main() into a separate file

This is in preparation to reusing the RemoteServer in other concepts.
I tried to keep changes to minimum:
- arg_* global variables are now passed as state in RemoteServer
- exported functions get the "journal_remote_" prefix
- some variables are renamed

In particular, there is an ugly global RemoveServer* variable. It was originally
added because µhttpd did not allow state to be passed to the callbacks. I'm not
sure if this has been remediated in µhttpd, but either way, this is not changed
here, the global variable is only renamed for clarity.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-05-16 10:21:58 +02:00
parent 5d889c1365
commit c064d8db40
5 changed files with 1242 additions and 1162 deletions

View File

@ -2007,7 +2007,8 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
s_j_remote = executable('systemd-journal-remote',
systemd_journal_remote_sources,
include_directories : includes,
link_with : [libshared],
link_with : [libshared,
libsystemd_journal_remote],
dependencies : [threads,
libmicrohttpd,
libgnutls,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,27 @@ struct RemoteServer {
Writer *_single_writer;
uint64_t event_count;
bool check_trust;
Hashmap *daemons;
const char *output; /* either the output file or directory */
JournalWriteSplitMode split_mode;
bool compress;
bool seal;
bool check_trust;
};
extern RemoteServer *journal_remote_server_global;
int journal_remote_server_init(
RemoteServer *s,
const char *output,
JournalWriteSplitMode split_mode,
bool compress,
bool seal);
int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer);
int journal_remote_add_source(RemoteServer *s, int fd, char* name, bool own_name);
int journal_remote_add_raw_socket(RemoteServer *s, int fd);
RemoteServer* journal_remote_server_destroy(RemoteServer *s);

View File

@ -8,15 +8,26 @@ systemd_journal_upload_sources = files('''
journal-upload-journal.c
'''.split())
libsystemd_journal_remote = static_library(
'systemd-journal-remote',
'journal-remote-parse.h',
'journal-remote-parse.c',
'journal-remote-write.h',
'journal-remote-write.c',
'journal-remote.h',
'journal-remote.c',
'microhttpd-util.h',
'microhttpd-util.c',
include_directories : includes,
dependencies : [threads,
libmicrohttpd,
libgnutls,
libxz,
liblz4],
install : false)
systemd_journal_remote_sources = files('''
journal-remote-parse.h
journal-remote-parse.c
journal-remote-write.h
journal-remote-write.c
journal-remote.h
journal-remote.c
microhttpd-util.h
microhttpd-util.c
journal-remote-main.c
'''.split())
systemd_journal_gatewayd_sources = files('''