fr_ldap_query_t find = { .msgid = -1 }, *query = NULL;
request_t *request;
bool really_no_result = false;
+ fr_trunk_request_t *treq;
/*
* Reset the idle timeout event
* Mark the trunk request as complete and set the request as runnable
*/
if (query->treq->request) unlang_interpret_mark_runnable(query->treq->request);
- fr_trunk_request_signal_complete(query->treq);
+
+ /*
+ * If the query is parented off just the treq, then it will be freed when
+ * the request is completed. If it has other parenting, then it will not.
+ */
+ treq = query->treq;
query->treq = NULL;
+ fr_trunk_request_signal_complete(treq);
} while (1);
}
{
fr_ldap_query_t *query;
static char const *attrs[] = LDAP_DIRECTORY_ATTRS;
+ fr_trunk_request_t *treq;
ttrunk->directory = talloc_zero(ctx, fr_ldap_directory_t);
if (!ttrunk->directory) return -1;
ttrunk->directory->type = FR_LDAP_DIRECTORY_UNKNOWN;
- query = fr_ldap_search_alloc(ctx, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, NULL, NULL);
+ treq = fr_trunk_request_alloc(ttrunk->trunk, NULL);
+ if (!treq) return -1;
+
+ query = fr_ldap_search_alloc(treq, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, NULL, NULL);
query->parser = ldap_trunk_directory_alloc_read;
+ query->treq = treq;
fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, NULL, query, ttrunk->directory);