andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From b43454d68fa53799a2fcf80ab00e9377638424cb Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Wed, 29 Apr 2015 17:15:45 -0700
Subject: [PATCH 317/319] Ticket #48146 - async simple paged results issue; log
 pr index

Description: When the request is a simple paged results search,
             log pr index in the access log.
Sample access log for "getent netgroup <name>":
  [..] conn=23 op=521 SRCH base="cn=accounts,dc=testrelm,dc=test" scope=2 filter="(&(|(memberOf=ipaUniqueID=3036b6a0-ee18-11e4-b7dd-00215e2032c0,cn=ng,cn=alt,dc=testrelm,dc=test))(objectClass=ipaHost))" attrs="objectClass cn fqdn serverHostName memberOf ipaSshPubKey ipaUniqueID"
  [..] conn=23 op=521 RESULT err=0 tag=101 nentries=200 etime=0 notes=P pr_idx=3

(cherry picked from commit 0bff700c0a50f26819f203772085e440a1fa8c23)
---
 ldap/servers/slapd/result.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index caf3014..6ed6c55 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1689,7 +1689,10 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 	int	internal_op;
 	CSN *operationcsn = NULL;
 	char csn_str[CSN_STRSIZE + 5];
-        char etime[ETIME_BUFSIZ];
+	char etime[ETIME_BUFSIZ];
+	int pr_idx = -1;
+
+	slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
 
 	internal_op = operation_is_flag_set( op, OP_FLAG_INTERNAL );
 
@@ -1784,7 +1787,32 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 								  notes_str, csn_str, dn ? dn : "");
 			}
             slapi_ch_free((void**)&dn);
-        } else {
+        } else if (pr_idx > -1) {
+			if ( !internal_op )
+			{
+				slapi_log_access( LDAP_DEBUG_STATS,
+								  "conn=%" NSPRIu64 " op=%d RESULT err=%d"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
+								  " pr_idx=%d\n",
+								  op->o_connid, 
+								  op->o_opid,
+								  err, tag, nentries, 
+								  etime, 
+								  notes_str, csn_str, pr_idx );
+			}
+			else
+			{
+				slapi_log_access( LDAP_DEBUG_ARGS,
+								  "conn=%s op=%d RESULT err=%d"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
+								  " pr_idx=%d\n",
+								  LOG_INTERNAL_OP_CON_ID,
+								  LOG_INTERNAL_OP_OP_ID,
+								  err, tag, nentries, 
+								  etime, 
+								  notes_str, csn_str, pr_idx );
+			}
+		} else {
 			if ( !internal_op )
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
-- 
1.9.3