From 45c961faa6468ade2a35551e902e0bcddc65e377 Mon Sep 17 00:00:00 2001 From: jmatthew Date: Fri, 31 Mar 2023 03:38:26 +0000 Subject: [PATCH] Only send the used portion of struct idm_req in imsgs from the ldapclient process to the main process. This significantly reduces memory usage when updating larger directories. ok aisha@ --- usr.sbin/ypldap/ldapclient.c | 5 +++-- usr.sbin/ypldap/ypldap.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index f9e089aeb80..c47fb2314e8 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.46 2022/10/13 04:55:33 jmatthew Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.47 2023/03/31 03:38:26 jmatthew Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver @@ -567,7 +567,8 @@ client_search_idm(struct env *env, struct idm *idm, struct aldap *al, if (client_build_req(idm, &ir, m, min_attr, max_attr) == 0) imsg_compose_event(env->sc_iev, type, 0, 0, -1, - &ir, sizeof(ir)); + &ir, sizeof(ir.ir_key) + + strlen(ir.ir_line) + 1); aldap_freemsg(m); } diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index 0d3d11703ba..8aa2c2b0077 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.c,v 1.23 2022/08/22 08:02:02 jmatthew Exp $ */ +/* $OpenBSD: ypldap.c,v 1.24 2023/03/31 03:38:26 jmatthew Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -392,7 +392,7 @@ main_dispatch_client(int fd, short events, void *p) if (env->update_trashed) break; - (void)memcpy(&ir, imsg.data, sizeof(ir)); + (void)memcpy(&ir, imsg.data, n - IMSG_HEADER_SIZE); if ((ue = calloc(1, sizeof(*ue))) == NULL || (ue->ue_line = strdup(ir.ir_line)) == NULL) { /* @@ -418,7 +418,7 @@ main_dispatch_client(int fd, short events, void *p) if (env->update_trashed) break; - (void)memcpy(&ir, imsg.data, sizeof(ir)); + (void)memcpy(&ir, imsg.data, n - IMSG_HEADER_SIZE); if ((ge = calloc(1, sizeof(*ge))) == NULL || (ge->ge_line = strdup(ir.ir_line)) == NULL) { /* -- 2.20.1