#include "logs-show.h"
#include "main-func.h"
#include "memory-util.h"
+#include "microhttpd-util.h"
#include "parse-argument.h"
#include "parse-helpers.h"
#include "pretty-print.h"
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(journal_write_split_mode, JournalWriteSplitMode);
static DEFINE_CONFIG_PARSE_ENUM(config_parse_write_split_mode, journal_write_split_mode, JournalWriteSplitMode);
+typedef struct MHDDaemonWrapper {
+ uint64_t fd;
+ struct MHD_Daemon *daemon;
+
+ sd_event_source *io_event;
+ sd_event_source *timer_event;
+} MHDDaemonWrapper;
+
+static MHDDaemonWrapper* MHDDaemonWrapper_free(MHDDaemonWrapper *d) {
+ if (!d)
+ return NULL;
+
+ if (d->daemon)
+ MHD_stop_daemon(d->daemon);
+ sd_event_source_unref(d->io_event);
+ sd_event_source_unref(d->timer_event);
+
+ return mfree(d);
+}
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(MHDDaemonWrapper*, MHDDaemonWrapper_free);
+
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ mhd_daemon_hash_ops,
+ uint64_t, uint64_hash_func, uint64_compare_func,
+ MHDDaemonWrapper, MHDDaemonWrapper_free);
+
/**********************************************************************
**********************************************************************
**********************************************************************/
if (r < 0)
return log_error_errno(r, "Failed to set source name: %m");
- r = hashmap_ensure_put(&s->daemons, &uint64_hash_ops, &d->fd, d);
+ r = hashmap_ensure_put(&s->daemons, &mhd_daemon_hash_ops, &d->fd, d);
if (r == -ENOMEM)
return log_oom();
if (r < 0)
#define filename_escape(s) xescape((s), "/ ")
-#if HAVE_MICROHTTPD
-MHDDaemonWrapper* MHDDaemonWrapper_free(MHDDaemonWrapper *d) {
- if (!d)
- return NULL;
-
- if (d->daemon)
- MHD_stop_daemon(d->daemon);
- sd_event_source_unref(d->io_event);
- sd_event_source_unref(d->timer_event);
-
- return mfree(d);
-}
-#endif
-
static int open_output(RemoteServer *s, Writer *w, const char *host) {
_cleanup_free_ char *_filename = NULL;
const char *filename;
if (!s)
return;
-#if HAVE_MICROHTTPD
- hashmap_free_with_destructor(s->daemons, MHDDaemonWrapper_free);
-#endif
+ hashmap_free(s->daemons);
for (i = 0; i < MALLOC_ELEMENTSOF(s->sources); i++)
remove_source(s, i);
#include "journal-remote-write.h"
#include "journal-vacuum.h"
-#if HAVE_MICROHTTPD
-#include "microhttpd-util.h"
-
-typedef struct MHDDaemonWrapper MHDDaemonWrapper;
-
-struct MHDDaemonWrapper {
- uint64_t fd;
- struct MHD_Daemon *daemon;
-
- sd_event_source *io_event;
- sd_event_source *timer_event;
-};
-
-MHDDaemonWrapper* MHDDaemonWrapper_free(MHDDaemonWrapper *d);
-DEFINE_TRIVIAL_CLEANUP_FUNC(MHDDaemonWrapper*, MHDDaemonWrapper_free);
-#endif
-
struct RemoteServer {
RemoteSource **sources;
size_t active;
Writer *_single_writer;
uint64_t event_count;
-#if HAVE_MICROHTTPD
Hashmap *daemons;
-#endif
const char *output; /* either the output file or directory */
JournalWriteSplitMode split_mode;