Patrick Williams | da29531 | 2023-12-05 16:48:56 -0600 | [diff] [blame] | 1 | From 9430646e72ea5d260ade300038a6d976fecf7da5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 2 Aug 2023 12:20:40 -0700 |
| 4 | Subject: [PATCH 4/4] shared: Do not use malloc_info on musl |
| 5 | |
| 6 | Upstream-Status: Inappropriate [musl-specific] |
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 8 | --- |
| 9 | src/shared/bus-util.c | 5 +++-- |
| 10 | src/shared/common-signal.c | 4 ++-- |
| 11 | 2 files changed, 5 insertions(+), 4 deletions(-) |
| 12 | |
| 13 | --- a/src/shared/bus-util.c |
| 14 | +++ b/src/shared/bus-util.c |
| 15 | @@ -617,15 +617,16 @@ static int method_dump_memory_state_by_f |
| 16 | _cleanup_close_ int fd = -EBADF; |
| 17 | size_t dump_size; |
| 18 | FILE *f; |
| 19 | - int r; |
| 20 | + int r = 0; |
| 21 | |
| 22 | assert(message); |
| 23 | |
| 24 | f = memstream_init(&m); |
| 25 | if (!f) |
| 26 | return -ENOMEM; |
| 27 | - |
| 28 | +#ifdef __GLIBC__ |
| 29 | r = RET_NERRNO(malloc_info(/* options= */ 0, f)); |
| 30 | +#endif |
| 31 | if (r < 0) |
| 32 | return r; |
| 33 | |
| 34 | --- a/src/shared/common-signal.c |
| 35 | +++ b/src/shared/common-signal.c |
| 36 | @@ -65,12 +65,12 @@ int sigrtmin18_handler(sd_event_source * |
| 37 | log_oom(); |
| 38 | break; |
| 39 | } |
| 40 | - |
| 41 | +#ifdef __GLIBC__ |
| 42 | if (malloc_info(0, f) < 0) { |
| 43 | log_error_errno(errno, "Failed to invoke malloc_info(): %m"); |
| 44 | break; |
| 45 | } |
| 46 | - |
| 47 | +#endif |
| 48 | (void) memstream_dump(LOG_INFO, &m); |
| 49 | break; |
| 50 | } |