Blob Blame History Raw
From 01fb4193778aa165070c3a8b4fe2c48e83ce3828 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Fri, 1 May 2015 10:50:39 -0700
Subject: [PATCH 65/72] 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

https://fedorahosted.org/389/ticket/48146

Reviewed by rmeggins@redhat.com (Thanks, Rich!!)

(cherry picked from commit 9eb20d89755160aa916544c7cfce0ad066e538f7)
---
 ldap/servers/slapd/result.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 2198337..226f01c 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1961,6 +1961,9 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag, int nentrie
 	CSN *operationcsn = NULL;
 	char csn_str[CSN_STRSIZE + 5];
 	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 );
 
@@ -2054,7 +2057,34 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag, int nentrie
 		}
 		slapi_ch_free((void**)&dn);
 	} else {
-		if ( !internal_op )
+		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,
 							  "conn=%" NSPRIu64 " op=%d RESULT err=%d"
-- 
1.9.3