ldap/admin
by Mark Reynolds
ldap/admin/src/scripts/DSCreate.pm.in | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
New commits:
commit afd7699f13b07bd1624432f16b56044840b50031
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jun 9 17:10:20 2015 -0400
Ticket 47913 - remove-ds.pl should not remove /var/lib/dirsrv
Bug Description: When removing the last instance, the remove-ds.pl
script is incorrectly removing the /var/lib/dirsrv
directory.
Fix Description: Only /var/lock/dirsrv & /var/run/dirsrv have their
ownership changed during an install, so only these
directories need to be removed. Also, changed this
cleanup code to be run only if there are no errors.
https://fedorahosted.org/389/ticket/47913
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index ae8d1e3..158a038 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -1482,17 +1482,15 @@ sub removeDSInstance {
# update systemd files
push @errs, updateSystemD();
- # remove /var/lock/dirsrv & /var/run/dirsrv if this was the last instance
- if(!<$pkglockdir/*>){
- rmdir $pkglockdir;
- rmdir $pkgrundir;
- rmdir $pkglibdir;
- }
-
# if we got here, report success
if (@errs) {
debug(1, "Could not successfully remove $instname\n");
} else {
+ if (!<$pkglockdir/*>){
+ # If this was the last instance, remove /var/lock/dirsrv & /var/run/dirsrv
+ rmdir $pkglockdir;
+ rmdir $pkgrundir;
+ }
debug(1, "Instance $instname removed.\n");
}
8 years, 10 months
2 commits - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/replutil.c | 4 ++--
ldap/servers/plugins/retrocl/retrocl_trim.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
New commits:
commit 578f9461a790895e6ce0a0af506a2710f761d194
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Jun 8 17:01:18 2015 -0700
Ticket #47972 - make parsing of nsslapd-changelogmaxage more fool proof
Description: apply the same fix made on the MMR plug-in to the retrocl
plug-in, as well.
https://fedorahosted.org/389/ticket/47972
Reviewed by mreynolds(a)redhat.com (Thanks, Mark!!)
diff --git a/ldap/servers/plugins/retrocl/retrocl_trim.c b/ldap/servers/plugins/retrocl/retrocl_trim.c
index ceb3467..098fc09 100644
--- a/ldap/servers/plugins/retrocl/retrocl_trim.c
+++ b/ldap/servers/plugins/retrocl/retrocl_trim.c
@@ -478,10 +478,10 @@ age_str2time (const char *age)
ageval *= ( 7 * 24 * 60 * 60 );
break;
default:
- slapi_log_error( SLAPI_LOG_PLUGIN, "retrocl",
+ slapi_log_error( SLAPI_LOG_FATAL, "retrocl",
"age_str2time: unknown unit \"%c\" "
"for maxiumum changelog age\n", unit );
- ageval = -1;
+ ageval = 0;
}
done:
if ( maxage) {
commit 170f49ce23238ebbe7b814f23ab5c88e4b7ce63a
Author: Jochen Schneider <scne59(a)gmail.com>
Date: Wed Dec 3 17:11:00 2014 +0100
Fix-for-ticket-47972 - make parsing of nsslapd-changelogmaxage more fault tolerant
When configuring nsslapd-changelogmaxage as a single non numeric character (e.g. "-")
you end up with a changelog that is completely purged with the next run of the purge
thread. The problem is only logged for log level PLUGIN,
As a fix:
in age_str2time: return 0 if unit cannot be parsed and log the error message as FATAL,
so you will at least have a default changelogmaxage and may notice the error message.
https://fedorahosted.org/389/ticket/47972
Resolves: Ticket 47972
Bug Description: make parsing of nsslapd-changelogmaxage more fault tolerant
Reviewed by: mreynolds(a)redhat.com, nhosoi(a)redhat.com
Branch: master
Fix Description: return 0 for unparseable values and log as FATAL
Platforms tested: Centos 6.6
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index a567832..9b94308 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -290,10 +290,10 @@ age_str2time (const char *age)
ageval *= ( 7 * 24 * 60 * 60 );
break;
default:
- slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name,
+ slapi_log_error( SLAPI_LOG_FATAL, repl_plugin_name,
"age_str2time: unknown unit \"%c\" "
"for maxiumum changelog age\n", unit );
- ageval = -1;
+ ageval = 0;
}
return ageval;
8 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/abandon.c | 10 ++---
ldap/servers/slapd/back-ldbm/ldbm_search.c | 13 ++++++-
ldap/servers/slapd/opshared.c | 36 ++++++++++++--------
ldap/servers/slapd/pagedresults.c | 52 ++++++++++++++++-------------
ldap/servers/slapd/proto-slap.h | 2 -
5 files changed, 69 insertions(+), 44 deletions(-)
New commits:
commit 16a8ef16724f1f657366169a7fd0ae1686b61d4b
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Jun 9 10:02:02 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: When a simple paged results is abandoned immediately and
asynchronously just after the request, the abandon request has a chance
to be handled before the simple paged results control is received and
processed. In the case, the search could be executed and the search
result structure could be leaked.
This patch adds more abandon checks. In op_shared_search, after the
send_results_ext call, if the SLAPI_OP_STATUS_ABANDONED bit is set in
the status in the operation object, it cleans up the search results
again, which gives the second chance.
https://fedorahosted.org/389/ticket/48192
Reviewed by tbordaz(a)redhat.com (Thank you so much, Thierry!!)
(cherry picked from commit 1d18dd0107d48ac1d79f7c9988adf18b0905bbdb)
(cherry picked from commit 798eae4f2240a5b47963a2bb09a2a17acfc488ec)
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index 9639701..09da149 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -132,8 +132,7 @@ do_abandon( Slapi_PBlock *pb )
}
operation_set_abandoned_op (pb->pb_op, o->o_abandoned_op);
- if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN )
- == 0 ) {
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN ) == 0 ) {
int rc = 0;
if ( o->o_status != SLAPI_OP_STATUS_RESULT_SENT ) {
@@ -148,14 +147,13 @@ do_abandon( Slapi_PBlock *pb )
suppressed_by_plugin = 1;
}
} else {
- LDAPDebug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0,
- 0 );
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "do_abandon: op not found\n");
}
if ( 0 == pagedresults_free_one_msgid_nolock(pb->pb_conn, id) ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64
- " op=%d ABANDON targetop=Simple Paged Results\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid );
+ " op=%d ABANDON targetop=Simple Paged Results msgid=%d\n",
+ pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
} else if ( NULL == o ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
" targetop=NOTFOUND msgid=%d\n",
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index dcb1490..de688fc 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1807,12 +1807,21 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
}
}
}
+ /* check for the final abandon */
+ if (slapi_op_abandoned(pb)) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate );
+ if ( use_extension ) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL );
+ }
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
+ delete_search_result_set(pb, &sr);
+ rc = SLAPI_FAIL_GENERAL;
+ }
bail:
- if(rc && op) {
+ if (rc && op) {
op->o_reverse_search_state = 0;
}
-
return rc;
}
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 7b160dd..28fe066 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -741,7 +741,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
pagedresults_unlock(pb->pb_conn, pr_idx);
if (next_be) {
/* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 0) < 0) {
goto free_and_return;
}
}
@@ -871,23 +871,23 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
- if (sr) { /* in case a left over sr is found, clean it up */
- pagedresults_free_one(pb->pb_conn, operation, pr_idx);
- }
+ /* no more entries, but at least another backend */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
+ be->be_search_results_release(&sr);
+ rc = pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 1);
+ PR_Unlock(pb->pb_conn->c_mutex);
if (NULL == next_be) {
- /* no more entries && no more backends */
- curr_search_count = -1;
- } else {
- /* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ /* no more entries && no more backends */
+ curr_search_count = -1;
+ } else if (rc < 0) {
goto free_and_return;
- }
}
} else {
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate);
pagedresults_lock(pb->pb_conn, pr_idx);
- if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx) < 0) ||
+ if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx, 0) < 0) ||
(pagedresults_set_search_result(pb->pb_conn, operation, sr, 0, pr_idx) < 0) ||
(pagedresults_set_search_result_count(pb->pb_conn, operation, curr_search_count, pr_idx) < 0) ||
(pagedresults_set_search_result_set_size_estimate(pb->pb_conn, operation, estimate, pr_idx) < 0) ||
@@ -897,10 +897,20 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
pagedresults_unlock(pb->pb_conn, pr_idx);
}
- pagedresults_set_response_control(pb, 0, estimate,
- curr_search_count, pr_idx);
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL );
next_be = NULL; /* to break the loop */
+ if (operation->o_status & SLAPI_OP_STATUS_ABANDONED) {
+ /* It turned out this search was abandoned. */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_free_one_msgid_nolock( pb->pb_conn, operation->o_msgid);
+ PR_Unlock(pb->pb_conn->c_mutex);
+ /* paged-results-request was abandoned; making an empty cookie. */
+ pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
+ send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
+ rc = LDAP_SUCCESS;
+ goto free_and_return;
+ }
+ pagedresults_set_response_control(pb, 0, estimate, curr_search_count, pr_idx);
if (curr_search_count == -1) {
pagedresults_free_one(pb->pb_conn, operation, pr_idx);
}
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 2e70e19..a7fe2cd 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -87,6 +87,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
Operation *op = pb->pb_op;
BerElement *ber = NULL;
PagedResults *prp = NULL;
+ time_t ctime = current_time();
+ int i;
LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_parse_control_value\n");
if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) {
@@ -121,7 +123,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
/* the ber encoding is no longer needed */
ber_free(ber, 1);
if ( cookie.bv_len <= 0 ) {
- int i;
/* first time? */
int maxlen = conn->c_pagedresults.prl_maxlen;
if (conn->c_pagedresults.prl_count == maxlen) {
@@ -138,15 +139,16 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memset(conn->c_pagedresults.prl_list + maxlen, '\0', sizeof(PagedResults) * maxlen);
}
*index = maxlen; /* the first position in the new area */
+ prp = conn->c_pagedresults.prl_list + *index;
+ prp->pr_current_be = be;
} else {
- time_t ctime = current_time();
prp = conn->c_pagedresults.prl_list;
for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
if (!prp->pr_current_be) { /* unused slot; take it */
prp->pr_current_be = be;
*index = i;
break;
- } else if (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
+ } else if (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
(prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) /* abandoned */) {
_pr_cleanup_one_slot(prp);
conn->c_pagedresults.prl_count--;
@@ -155,15 +157,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
break;
}
}
- /* cleaning up the rest of the timedout if any */
- for (++i; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
- if (prp->pr_current_be &&
- (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
- (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
- _pr_cleanup_one_slot(prp);
- conn->c_pagedresults.prl_count--;
- }
- }
}
if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen) &&
!conn->c_pagedresults.prl_list[*index].pr_mutex) {
@@ -181,8 +174,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
+ *index = -1; /* index is invalid. reinitializing it. */
goto bail;
}
prp = conn->c_pagedresults.prl_list + *index;
@@ -206,11 +199,24 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
}
} else {
rc = LDAP_PROTOCOL_ERROR;
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
}
bail:
+ /* cleaning up the rest of the timedout or abandoned if any */
+ prp = conn->c_pagedresults.prl_list;
+ for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
+ if (prp->pr_current_be &&
+ (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
+ (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
+ _pr_cleanup_one_slot(prp);
+ conn->c_pagedresults.prl_count--;
+ if (i == *index) {
+ /* registered slot is expired and cleaned up. return cancelled. */
+ *index = -1;
+ rc = LDAP_CANCELLED;
+ }
+ }
+ }
PR_Unlock(conn->c_mutex);
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -326,7 +332,9 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
return rc;
}
-/* Used for abandoning */
+/*
+ * Used for abandoning - conn->c_mutex is already locked in do_abandone.
+ */
int
pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
{
@@ -334,7 +342,7 @@ pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
int i;
if (conn && (msgid > -1)) {
- if (conn->c_pagedresults.prl_count <= 0) {
+ if (conn->c_pagedresults.prl_maxlen <= 0) {
; /* Not a paged result. */
} else {
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -381,18 +389,18 @@ pagedresults_get_current_be(Connection *conn, int index)
}
int
-pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index)
+pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock)
{
int rc = -1;
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_current_be: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ if (!nolock) PR_Lock(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_current_be = be;
}
- PR_Unlock(conn->c_mutex);
rc = 0;
+ if (!nolock) PR_Unlock(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_current_be: %d\n", rc);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 4c3c29d..55d53bd 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1437,7 +1437,7 @@ void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical,
ber_int_t estimate,
int curr_search_count, int index);
Slapi_Backend *pagedresults_get_current_be(Connection *conn, int index);
-int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index);
+int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock);
void *pagedresults_get_search_result(Connection *conn, Operation *op,
int index);
int pagedresults_set_search_result(Connection *conn, Operation *op, void *sr,
8 years, 10 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/abandon.c | 10 ++---
ldap/servers/slapd/back-ldbm/ldbm_search.c | 13 ++++++-
ldap/servers/slapd/opshared.c | 36 ++++++++++++--------
ldap/servers/slapd/pagedresults.c | 52 ++++++++++++++++-------------
ldap/servers/slapd/proto-slap.h | 2 -
5 files changed, 69 insertions(+), 44 deletions(-)
New commits:
commit 798eae4f2240a5b47963a2bb09a2a17acfc488ec
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Jun 9 10:02:02 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: When a simple paged results is abandoned immediately and
asynchronously just after the request, the abandon request has a chance
to be handled before the simple paged results control is received and
processed. In the case, the search could be executed and the search
result structure could be leaked.
This patch adds more abandon checks. In op_shared_search, after the
send_results_ext call, if the SLAPI_OP_STATUS_ABANDONED bit is set in
the status in the operation object, it cleans up the search results
again, which gives the second chance.
https://fedorahosted.org/389/ticket/48192
Reviewed by tbordaz(a)redhat.com (Thank you so much, Thierry!!)
(cherry picked from commit 1d18dd0107d48ac1d79f7c9988adf18b0905bbdb)
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index 43158a8..9797f7c 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -132,8 +132,7 @@ do_abandon( Slapi_PBlock *pb )
}
operation_set_abandoned_op (pb->pb_op, o->o_abandoned_op);
- if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN )
- == 0 ) {
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN ) == 0 ) {
int rc = 0;
if ( o->o_status != SLAPI_OP_STATUS_RESULT_SENT ) {
@@ -148,14 +147,13 @@ do_abandon( Slapi_PBlock *pb )
suppressed_by_plugin = 1;
}
} else {
- LDAPDebug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0,
- 0 );
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "do_abandon: op not found\n");
}
if ( 0 == pagedresults_free_one_msgid_nolock(pb->pb_conn, id) ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64
- " op=%d ABANDON targetop=Simple Paged Results\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid );
+ " op=%d ABANDON targetop=Simple Paged Results msgid=%d\n",
+ pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
} else if ( NULL == o ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
" targetop=NOTFOUND msgid=%d\n",
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index fe0a6ca..ae0eef5 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1836,12 +1836,21 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
}
}
}
+ /* check for the final abandon */
+ if (slapi_op_abandoned(pb)) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate );
+ if ( use_extension ) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL );
+ }
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
+ delete_search_result_set(pb, &sr);
+ rc = SLAPI_FAIL_GENERAL;
+ }
bail:
- if(rc){
+ if (rc && op) {
op->o_reverse_search_state = 0;
}
-
return rc;
}
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 1623fb0..9a5a141 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -748,7 +748,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
pagedresults_unlock(pb->pb_conn, pr_idx);
if (next_be) {
/* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 0) < 0) {
goto free_and_return;
}
}
@@ -878,23 +878,23 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
- if (sr) { /* in case a left over sr is found, clean it up */
- pagedresults_free_one(pb->pb_conn, operation, pr_idx);
- }
+ /* no more entries, but at least another backend */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
+ be->be_search_results_release(&sr);
+ rc = pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 1);
+ PR_Unlock(pb->pb_conn->c_mutex);
if (NULL == next_be) {
- /* no more entries && no more backends */
- curr_search_count = -1;
- } else {
- /* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ /* no more entries && no more backends */
+ curr_search_count = -1;
+ } else if (rc < 0) {
goto free_and_return;
- }
}
} else {
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate);
pagedresults_lock(pb->pb_conn, pr_idx);
- if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx) < 0) ||
+ if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx, 0) < 0) ||
(pagedresults_set_search_result(pb->pb_conn, operation, sr, 0, pr_idx) < 0) ||
(pagedresults_set_search_result_count(pb->pb_conn, operation, curr_search_count, pr_idx) < 0) ||
(pagedresults_set_search_result_set_size_estimate(pb->pb_conn, operation, estimate, pr_idx) < 0) ||
@@ -904,10 +904,20 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
pagedresults_unlock(pb->pb_conn, pr_idx);
}
- pagedresults_set_response_control(pb, 0, estimate,
- curr_search_count, pr_idx);
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL );
next_be = NULL; /* to break the loop */
+ if (operation->o_status & SLAPI_OP_STATUS_ABANDONED) {
+ /* It turned out this search was abandoned. */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_free_one_msgid_nolock( pb->pb_conn, operation->o_msgid);
+ PR_Unlock(pb->pb_conn->c_mutex);
+ /* paged-results-request was abandoned; making an empty cookie. */
+ pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
+ send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
+ rc = LDAP_SUCCESS;
+ goto free_and_return;
+ }
+ pagedresults_set_response_control(pb, 0, estimate, curr_search_count, pr_idx);
if (curr_search_count == -1) {
pagedresults_free_one(pb->pb_conn, operation, pr_idx);
}
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 2e70e19..a7fe2cd 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -87,6 +87,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
Operation *op = pb->pb_op;
BerElement *ber = NULL;
PagedResults *prp = NULL;
+ time_t ctime = current_time();
+ int i;
LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_parse_control_value\n");
if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) {
@@ -121,7 +123,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
/* the ber encoding is no longer needed */
ber_free(ber, 1);
if ( cookie.bv_len <= 0 ) {
- int i;
/* first time? */
int maxlen = conn->c_pagedresults.prl_maxlen;
if (conn->c_pagedresults.prl_count == maxlen) {
@@ -138,15 +139,16 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memset(conn->c_pagedresults.prl_list + maxlen, '\0', sizeof(PagedResults) * maxlen);
}
*index = maxlen; /* the first position in the new area */
+ prp = conn->c_pagedresults.prl_list + *index;
+ prp->pr_current_be = be;
} else {
- time_t ctime = current_time();
prp = conn->c_pagedresults.prl_list;
for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
if (!prp->pr_current_be) { /* unused slot; take it */
prp->pr_current_be = be;
*index = i;
break;
- } else if (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
+ } else if (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
(prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) /* abandoned */) {
_pr_cleanup_one_slot(prp);
conn->c_pagedresults.prl_count--;
@@ -155,15 +157,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
break;
}
}
- /* cleaning up the rest of the timedout if any */
- for (++i; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
- if (prp->pr_current_be &&
- (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
- (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
- _pr_cleanup_one_slot(prp);
- conn->c_pagedresults.prl_count--;
- }
- }
}
if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen) &&
!conn->c_pagedresults.prl_list[*index].pr_mutex) {
@@ -181,8 +174,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
+ *index = -1; /* index is invalid. reinitializing it. */
goto bail;
}
prp = conn->c_pagedresults.prl_list + *index;
@@ -206,11 +199,24 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
}
} else {
rc = LDAP_PROTOCOL_ERROR;
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
}
bail:
+ /* cleaning up the rest of the timedout or abandoned if any */
+ prp = conn->c_pagedresults.prl_list;
+ for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
+ if (prp->pr_current_be &&
+ (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
+ (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
+ _pr_cleanup_one_slot(prp);
+ conn->c_pagedresults.prl_count--;
+ if (i == *index) {
+ /* registered slot is expired and cleaned up. return cancelled. */
+ *index = -1;
+ rc = LDAP_CANCELLED;
+ }
+ }
+ }
PR_Unlock(conn->c_mutex);
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -326,7 +332,9 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
return rc;
}
-/* Used for abandoning */
+/*
+ * Used for abandoning - conn->c_mutex is already locked in do_abandone.
+ */
int
pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
{
@@ -334,7 +342,7 @@ pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
int i;
if (conn && (msgid > -1)) {
- if (conn->c_pagedresults.prl_count <= 0) {
+ if (conn->c_pagedresults.prl_maxlen <= 0) {
; /* Not a paged result. */
} else {
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -381,18 +389,18 @@ pagedresults_get_current_be(Connection *conn, int index)
}
int
-pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index)
+pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock)
{
int rc = -1;
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_current_be: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ if (!nolock) PR_Lock(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_current_be = be;
}
- PR_Unlock(conn->c_mutex);
rc = 0;
+ if (!nolock) PR_Unlock(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_current_be: %d\n", rc);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index a4c6b58..3f88f55 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1481,7 +1481,7 @@ void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical,
ber_int_t estimate,
int curr_search_count, int index);
Slapi_Backend *pagedresults_get_current_be(Connection *conn, int index);
-int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index);
+int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock);
void *pagedresults_get_search_result(Connection *conn, Operation *op,
int index);
int pagedresults_set_search_result(Connection *conn, Operation *op, void *sr,
8 years, 10 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/abandon.c | 10 ++---
ldap/servers/slapd/back-ldbm/ldbm_search.c | 13 ++++++-
ldap/servers/slapd/opshared.c | 36 ++++++++++++--------
ldap/servers/slapd/pagedresults.c | 52 ++++++++++++++++-------------
ldap/servers/slapd/proto-slap.h | 2 -
5 files changed, 69 insertions(+), 44 deletions(-)
New commits:
commit 1d18dd0107d48ac1d79f7c9988adf18b0905bbdb
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Jun 9 10:02:02 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: When a simple paged results is abandoned immediately and
asynchronously just after the request, the abandon request has a chance
to be handled before the simple paged results control is received and
processed. In the case, the search could be executed and the search
result structure could be leaked.
This patch adds more abandon checks. In op_shared_search, after the
send_results_ext call, if the SLAPI_OP_STATUS_ABANDONED bit is set in
the status in the operation object, it cleans up the search results
again, which gives the second chance.
https://fedorahosted.org/389/ticket/48192
Reviewed by tbordaz(a)redhat.com (Thank you so much, Thierry!!)
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index 43158a8..9797f7c 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -132,8 +132,7 @@ do_abandon( Slapi_PBlock *pb )
}
operation_set_abandoned_op (pb->pb_op, o->o_abandoned_op);
- if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN )
- == 0 ) {
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN ) == 0 ) {
int rc = 0;
if ( o->o_status != SLAPI_OP_STATUS_RESULT_SENT ) {
@@ -148,14 +147,13 @@ do_abandon( Slapi_PBlock *pb )
suppressed_by_plugin = 1;
}
} else {
- LDAPDebug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0,
- 0 );
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "do_abandon: op not found\n");
}
if ( 0 == pagedresults_free_one_msgid_nolock(pb->pb_conn, id) ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64
- " op=%d ABANDON targetop=Simple Paged Results\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid );
+ " op=%d ABANDON targetop=Simple Paged Results msgid=%d\n",
+ pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
} else if ( NULL == o ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
" targetop=NOTFOUND msgid=%d\n",
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index fe0a6ca..ae0eef5 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1836,12 +1836,21 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
}
}
}
+ /* check for the final abandon */
+ if (slapi_op_abandoned(pb)) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate );
+ if ( use_extension ) {
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL );
+ }
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
+ delete_search_result_set(pb, &sr);
+ rc = SLAPI_FAIL_GENERAL;
+ }
bail:
- if(rc){
+ if (rc && op) {
op->o_reverse_search_state = 0;
}
-
return rc;
}
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 1623fb0..9a5a141 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -748,7 +748,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
pagedresults_unlock(pb->pb_conn, pr_idx);
if (next_be) {
/* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 0) < 0) {
goto free_and_return;
}
}
@@ -878,23 +878,23 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
- if (sr) { /* in case a left over sr is found, clean it up */
- pagedresults_free_one(pb->pb_conn, operation, pr_idx);
- }
+ /* no more entries, but at least another backend */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
+ be->be_search_results_release(&sr);
+ rc = pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 1);
+ PR_Unlock(pb->pb_conn->c_mutex);
if (NULL == next_be) {
- /* no more entries && no more backends */
- curr_search_count = -1;
- } else {
- /* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
+ /* no more entries && no more backends */
+ curr_search_count = -1;
+ } else if (rc < 0) {
goto free_and_return;
- }
}
} else {
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate);
pagedresults_lock(pb->pb_conn, pr_idx);
- if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx) < 0) ||
+ if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx, 0) < 0) ||
(pagedresults_set_search_result(pb->pb_conn, operation, sr, 0, pr_idx) < 0) ||
(pagedresults_set_search_result_count(pb->pb_conn, operation, curr_search_count, pr_idx) < 0) ||
(pagedresults_set_search_result_set_size_estimate(pb->pb_conn, operation, estimate, pr_idx) < 0) ||
@@ -904,10 +904,20 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
pagedresults_unlock(pb->pb_conn, pr_idx);
}
- pagedresults_set_response_control(pb, 0, estimate,
- curr_search_count, pr_idx);
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL );
next_be = NULL; /* to break the loop */
+ if (operation->o_status & SLAPI_OP_STATUS_ABANDONED) {
+ /* It turned out this search was abandoned. */
+ PR_Lock(pb->pb_conn->c_mutex);
+ pagedresults_free_one_msgid_nolock( pb->pb_conn, operation->o_msgid);
+ PR_Unlock(pb->pb_conn->c_mutex);
+ /* paged-results-request was abandoned; making an empty cookie. */
+ pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
+ send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
+ rc = LDAP_SUCCESS;
+ goto free_and_return;
+ }
+ pagedresults_set_response_control(pb, 0, estimate, curr_search_count, pr_idx);
if (curr_search_count == -1) {
pagedresults_free_one(pb->pb_conn, operation, pr_idx);
}
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 2e70e19..a7fe2cd 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -87,6 +87,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
Operation *op = pb->pb_op;
BerElement *ber = NULL;
PagedResults *prp = NULL;
+ time_t ctime = current_time();
+ int i;
LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_parse_control_value\n");
if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) {
@@ -121,7 +123,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
/* the ber encoding is no longer needed */
ber_free(ber, 1);
if ( cookie.bv_len <= 0 ) {
- int i;
/* first time? */
int maxlen = conn->c_pagedresults.prl_maxlen;
if (conn->c_pagedresults.prl_count == maxlen) {
@@ -138,15 +139,16 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memset(conn->c_pagedresults.prl_list + maxlen, '\0', sizeof(PagedResults) * maxlen);
}
*index = maxlen; /* the first position in the new area */
+ prp = conn->c_pagedresults.prl_list + *index;
+ prp->pr_current_be = be;
} else {
- time_t ctime = current_time();
prp = conn->c_pagedresults.prl_list;
for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
if (!prp->pr_current_be) { /* unused slot; take it */
prp->pr_current_be = be;
*index = i;
break;
- } else if (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
+ } else if (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
(prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) /* abandoned */) {
_pr_cleanup_one_slot(prp);
conn->c_pagedresults.prl_count--;
@@ -155,15 +157,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
break;
}
}
- /* cleaning up the rest of the timedout if any */
- for (++i; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
- if (prp->pr_current_be &&
- (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
- (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
- _pr_cleanup_one_slot(prp);
- conn->c_pagedresults.prl_count--;
- }
- }
}
if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen) &&
!conn->c_pagedresults.prl_list[*index].pr_mutex) {
@@ -181,8 +174,8 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
+ *index = -1; /* index is invalid. reinitializing it. */
goto bail;
}
prp = conn->c_pagedresults.prl_list + *index;
@@ -206,11 +199,24 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
}
} else {
rc = LDAP_PROTOCOL_ERROR;
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "pagedresults_parse_control_value: invalid cookie: %d\n",
- *index);
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "pagedresults_parse_control_value: invalid cookie: %d\n", *index);
}
bail:
+ /* cleaning up the rest of the timedout or abandoned if any */
+ prp = conn->c_pagedresults.prl_list;
+ for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
+ if (prp->pr_current_be &&
+ (((prp->pr_timelimit > 0) && (ctime > prp->pr_timelimit)) || /* timelimit exceeded */
+ (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
+ _pr_cleanup_one_slot(prp);
+ conn->c_pagedresults.prl_count--;
+ if (i == *index) {
+ /* registered slot is expired and cleaned up. return cancelled. */
+ *index = -1;
+ rc = LDAP_CANCELLED;
+ }
+ }
+ }
PR_Unlock(conn->c_mutex);
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -326,7 +332,9 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
return rc;
}
-/* Used for abandoning */
+/*
+ * Used for abandoning - conn->c_mutex is already locked in do_abandone.
+ */
int
pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
{
@@ -334,7 +342,7 @@ pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
int i;
if (conn && (msgid > -1)) {
- if (conn->c_pagedresults.prl_count <= 0) {
+ if (conn->c_pagedresults.prl_maxlen <= 0) {
; /* Not a paged result. */
} else {
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -381,18 +389,18 @@ pagedresults_get_current_be(Connection *conn, int index)
}
int
-pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index)
+pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock)
{
int rc = -1;
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_current_be: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ if (!nolock) PR_Lock(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_current_be = be;
}
- PR_Unlock(conn->c_mutex);
rc = 0;
+ if (!nolock) PR_Unlock(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_current_be: %d\n", rc);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index ee32bd0..8410e66 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1492,7 +1492,7 @@ void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical,
ber_int_t estimate,
int curr_search_count, int index);
Slapi_Backend *pagedresults_get_current_be(Connection *conn, int index);
-int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index);
+int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int nolock);
void *pagedresults_get_search_result(Connection *conn, Operation *op,
int index);
int pagedresults_set_search_result(Connection *conn, Operation *op, void *sr,
8 years, 10 months
admserv/newinst
by Mark Reynolds
admserv/newinst/src/register-ds-admin.pl.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 42d65608dc312e0fa753841764ca8208a047e01a
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 5 14:28:53 2015 -0400
Ticket 47548 - register-ds-admin - silent file incorrectly processed
Bug Description: There was an improper check to see if any "instances"
were set in the INF file. THis lead to an erroneous
error.
FIx Description: Check that the instance array actually has elements.
https://fedorahosted.org/389/ticket/47548
Reviewed by: nhosoi(Thanks!)
diff --git a/admserv/newinst/src/register-ds-admin.pl.in b/admserv/newinst/src/register-ds-admin.pl.in
index 04e936a..dd100d9 100644
--- a/admserv/newinst/src/register-ds-admin.pl.in
+++ b/admserv/newinst/src/register-ds-admin.pl.in
@@ -123,7 +123,7 @@ sub get_cred_from_inst
# Check the remaining instances
#
my @insts = $mysetup->{inf}->{register}->{instance};
- if (@insts){
+ if ($#insts){
my $i = 0;
for (; $i <= $#insts; $i++){
my @inst_parts = split('::', $insts[$i]);
@@ -267,7 +267,7 @@ if ($setup->{inf}->{register}){
# Add the other instances (if any)
#
@silent_instances = $setup->{inf}->{register}->{instance};
- if (@silent_instances){
+ if ($#silent_instances){
my $i = 0;
for (; $i <= $#silent_instances; $i++){
my @inst_parts = split('::', $silent_instances[$i]);
8 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pagedresults.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 7db5fdd5f1c5e1979784833173864e9c8c49c89d
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jun 5 10:13:17 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: Checking the cookie value passed by the client was not
sufficient. The negative value check was missing, which lead to
the simple paged results array out of bounds. Plus, a minor memory
leak was fixed. Thanks to Thierry Bordaz for his reviews!
https://fedorahosted.org/389/ticket/48192
(cherry picked from commit 298371d372678cf553594ae73ae57a6ea35358bf)
(cherry picked from commit 7718eb6a6714d1a284c3c706e621a7eb0ca5655a)
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 402dd10..2e70e19 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -177,14 +177,14 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memcpy(ptr, cookie.bv_val, cookie.bv_len);
*(ptr+cookie.bv_len) = '\0';
*index = strtol(ptr, NULL, 10);
- if (conn->c_pagedresults.prl_maxlen <= *index) {
+ slapi_ch_free_string(&ptr);
+ if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"pagedresults_parse_control_value: invalid cookie: %d\n",
*index);
goto bail;
}
- slapi_ch_free_string(&ptr);
prp = conn->c_pagedresults.prl_list + *index;
if (!(prp->pr_search_result_set)) { /* freed and reused for the next backend. */
conn->c_pagedresults.prl_count++;
8 years, 10 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pagedresults.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 7718eb6a6714d1a284c3c706e621a7eb0ca5655a
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jun 5 10:13:17 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: Checking the cookie value passed by the client was not
sufficient. The negative value check was missing, which lead to
the simple paged results array out of bounds. Plus, a minor memory
leak was fixed. Thanks to Thierry Bordaz for his reviews!
https://fedorahosted.org/389/ticket/48192
(cherry picked from commit 298371d372678cf553594ae73ae57a6ea35358bf)
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 402dd10..2e70e19 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -177,14 +177,14 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memcpy(ptr, cookie.bv_val, cookie.bv_len);
*(ptr+cookie.bv_len) = '\0';
*index = strtol(ptr, NULL, 10);
- if (conn->c_pagedresults.prl_maxlen <= *index) {
+ slapi_ch_free_string(&ptr);
+ if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"pagedresults_parse_control_value: invalid cookie: %d\n",
*index);
goto bail;
}
- slapi_ch_free_string(&ptr);
prp = conn->c_pagedresults.prl_list + *index;
if (!(prp->pr_search_result_set)) { /* freed and reused for the next backend. */
conn->c_pagedresults.prl_count++;
8 years, 10 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pagedresults.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 298371d372678cf553594ae73ae57a6ea35358bf
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jun 5 10:13:17 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: Checking the cookie value passed by the client was not
sufficient. The negative value check was missing, which lead to
the simple paged results array out of bounds. Plus, a minor memory
leak was fixed. Thanks to Thierry Bordaz for his reviews!
https://fedorahosted.org/389/ticket/48192
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 402dd10..2e70e19 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -177,14 +177,14 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
memcpy(ptr, cookie.bv_val, cookie.bv_len);
*(ptr+cookie.bv_len) = '\0';
*index = strtol(ptr, NULL, 10);
- if (conn->c_pagedresults.prl_maxlen <= *index) {
+ slapi_ch_free_string(&ptr);
+ if ((conn->c_pagedresults.prl_maxlen <= *index) || (*index < 0)){
rc = LDAP_PROTOCOL_ERROR;
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"pagedresults_parse_control_value: invalid cookie: %d\n",
*index);
goto bail;
}
- slapi_ch_free_string(&ptr);
prp = conn->c_pagedresults.prl_list + *index;
if (!(prp->pr_search_result_set)) { /* freed and reused for the next backend. */
conn->c_pagedresults.prl_count++;
8 years, 10 months
Branch '389-ds-base-1.2.11' - 3 commits - ldap/admin ldap/servers
by Noriko Hosoi
ldap/admin/src/scripts/restart-dirsrv.in | 2
ldap/admin/src/scripts/start-dirsrv.in | 2
ldap/admin/src/scripts/stop-dirsrv.in | 2
ldap/servers/slapd/back-ldbm/dblayer.c | 10 +-
ldap/servers/slapd/opshared.c | 41 +++++------
ldap/servers/slapd/pagedresults.c | 110 ++++++++++++++++++++-----------
6 files changed, 98 insertions(+), 69 deletions(-)
New commits:
commit 490830fab691c904f5f88f503cf510a9c68477a4
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 4 16:27:05 2015 -0700
Ticket #48192 - Individual abandoned simple paged results request has no chance to be cleaned up
Description: When allocating a slot in simple paged results array stashed
in a connection in pagedresults_parse_control_value, a new code is added
to scan the array if the existing slot is timed out or not. If it is, the
slot is released and a search results is released if it is attached.
Also, if a request is abandoned, instead of returning a valid cookie, it
changed to return an empty cookie to inform the client the request was not
successfully completed.
https://fedorahosted.org/389/ticket/48192
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit f3c3125fc9fd4dc1cbd41027d6442cb525efd014)
(cherry picked from commit 97c707df4e11936202310e99bcf5f45d15b49f0f)
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index d446f50..7b160dd 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -510,8 +510,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
rc = pagedresults_parse_control_value(pb, ctl_value, &pagesize, &pr_idx, be);
/* Let's set pr_idx even if it fails; in case, pr_idx == -1. */
slapi_pblock_set(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
- if ((LDAP_SUCCESS == rc) ||
- (LDAP_CANCELLED == rc) || (0 == pagesize)) {
+ if ((LDAP_SUCCESS == rc) || (LDAP_CANCELLED == rc) || (0 == pagesize)) {
unsigned int opnote = SLAPI_OP_NOTE_SIMPLEPAGED;
op_set_pagedresults(operation);
pr_be = pagedresults_get_current_be(pb->pb_conn, pr_idx);
@@ -538,9 +537,8 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
if ((LDAP_CANCELLED == rc) || (0 == pagesize)) {
- /* paged-results-request was abandoned */
- pagedresults_set_response_control(pb, 0, estimate,
- curr_search_count, pr_idx);
+ /* paged-results-request was abandoned; making an empty cookie. */
+ pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
send_ldap_result(pb, 0, NULL,
"Simple Paged Results Search abandoned",
0, NULL);
@@ -567,10 +565,21 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* adjust time and size limits */
compute_limits (pb);
-
- /* call the pre-search plugins. if they succeed, call the backend
- search function. then call the post-search plugins. */
+ /* set the timelimit to clean up the too-long-lived-paged results requests */
+ if (op_is_pagedresults(operation)) {
+ time_t optime, time_up;
+ int tlimit;
+ slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit );
+ slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
+ time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */
+ pagedresults_set_timelimit(pb->pb_conn, pb->pb_op, time_up, pr_idx);
+ }
+
+ /*
+ * call the pre-search plugins. if they succeed, call the backend
+ * search function. then call the post-search plugins.
+ */
/* ONREPL - should regular plugin be called for internal searches ? */
if (plugin_call_plugins(pb, SLAPI_PLUGIN_PRE_SEARCH_FN) == 0)
{
@@ -635,16 +644,6 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
}
- /* set the timelimit to clean up the too-long-lived-paged results requests */
- if (op_is_pagedresults(operation)) {
- time_t optime, time_up;
- int tlimit;
- slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit );
- slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
- time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */
- pagedresults_set_timelimit(pb->pb_conn, pb->pb_op, time_up, pr_idx);
- }
-
/* PAR: now filters have been rewritten, we can assign plugins to work on them */
index_subsys_assign_filter_decoders(pb);
@@ -873,10 +872,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
if (sr) { /* in case a left over sr is found, clean it up */
- PR_Lock(pb->pb_conn->c_mutex);
- pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
- be->be_search_results_release(&sr);
- PR_Unlock(pb->pb_conn->c_mutex);
+ pagedresults_free_one(pb->pb_conn, operation, pr_idx);
}
if (NULL == next_be) {
/* no more entries && no more backends */
@@ -1299,7 +1295,6 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
operation_out_of_disk_space();
}
pr_stat = PAGEDRESULTS_SEARCH_END;
- pagedresults_set_timelimit(pb->pb_conn, pb->pb_op, 0, pr_idx);
rval = -1;
done = 1;
continue;
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 327da54..402dd10 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -41,6 +41,27 @@
#include "slap.h"
+/* helper function to clean up one prp slot */
+static void
+_pr_cleanup_one_slot(PagedResults *prp)
+{
+ PRLock *prmutex = NULL;
+ if (!prp) {
+ return;
+ }
+ if (prp->pr_current_be && prp->pr_current_be->be_search_results_release) {
+ /* sr is left; release it. */
+ prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set));
+ }
+ /* clean up the slot */
+ if (prp->pr_mutex) {
+ /* pr_mutex is reused; back it up and reset it. */
+ prmutex = prp->pr_mutex;
+ }
+ memset(prp, '\0', sizeof(PagedResults));
+ prp->pr_mutex = prmutex;
+}
+
/*
* Parse the value from an LDAPv3 "Simple Paged Results" control. They look
* like this:
@@ -65,6 +86,7 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
Connection *conn = pb->pb_conn;
Operation *op = pb->pb_op;
BerElement *ber = NULL;
+ PagedResults *prp = NULL;
LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_parse_control_value\n");
if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) {
@@ -117,13 +139,31 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
}
*index = maxlen; /* the first position in the new area */
} else {
- for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) {
- if (!conn->c_pagedresults.prl_list[i].pr_current_be) {
- conn->c_pagedresults.prl_list[i].pr_current_be = be;
+ time_t ctime = current_time();
+ prp = conn->c_pagedresults.prl_list;
+ for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
+ if (!prp->pr_current_be) { /* unused slot; take it */
+ prp->pr_current_be = be;
+ *index = i;
+ break;
+ } else if (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
+ (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) /* abandoned */) {
+ _pr_cleanup_one_slot(prp);
+ conn->c_pagedresults.prl_count--;
+ prp->pr_current_be = be;
*index = i;
break;
}
}
+ /* cleaning up the rest of the timedout if any */
+ for (++i; i < conn->c_pagedresults.prl_maxlen; i++, prp++) {
+ if (prp->pr_current_be &&
+ (((prp->pr_timelimit > 0) && (ctime < prp->pr_timelimit)) || /* timelimit exceeded */
+ (prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED)) /* abandoned */) {
+ _pr_cleanup_one_slot(prp);
+ conn->c_pagedresults.prl_count--;
+ }
+ }
}
if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen) &&
!conn->c_pagedresults.prl_list[*index].pr_mutex) {
@@ -131,7 +171,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
}
conn->c_pagedresults.prl_count++;
} else {
- PagedResults *prp = NULL;
/* Repeated paged results request.
* PagedResults is already allocated. */
char *ptr = slapi_ch_malloc(cookie.bv_len + 1);
@@ -156,8 +195,10 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
slapi_ch_free((void **)&cookie.bv_val);
if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen)) {
- if (conn->c_pagedresults.prl_list[*index].pr_flags &
- CONN_FLAG_PAGEDRESULTS_ABANDONED) {
+ if (conn->c_pagedresults.prl_list[*index].pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) {
+ /* repeated case? */
+ prp = conn->c_pagedresults.prl_list + *index;
+ _pr_cleanup_one_slot(prp);
rc = LDAP_CANCELLED;
} else {
/* Need to keep the latest msgid to prepare for the abandon. */
@@ -273,20 +314,8 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
"conn=%d paged requests list count is %d\n",
conn->c_connid, conn->c_pagedresults.prl_count);
} else if (index < conn->c_pagedresults.prl_maxlen) {
- PRLock *prmutex = NULL;
PagedResults *prp = conn->c_pagedresults.prl_list + index;
- if (prp && prp->pr_current_be &&
- prp->pr_current_be->be_search_results_release &&
- prp->pr_search_result_set) {
- prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set));
- }
- prp->pr_current_be = NULL;
- if (prp->pr_mutex) {
- /* pr_mutex is reused; back it up and reset it. */
- prmutex = prp->pr_mutex;
- }
- memset(prp, '\0', sizeof(PagedResults));
- prp->pr_mutex = prmutex;
+ _pr_cleanup_one_slot(prp);
conn->c_pagedresults.prl_count--;
rc = 0;
}
@@ -309,7 +338,7 @@ pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
; /* Not a paged result. */
} else {
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
- "--> pagedresults_free_one: msgid=%d\n", msgid);
+ "--> pagedresults_free_one_msgid_nolock: msgid=%d\n", msgid);
for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) {
if (conn->c_pagedresults.prl_list[i].pr_msgid == msgid) {
PagedResults *prp = conn->c_pagedresults.prl_list + i;
@@ -318,16 +347,14 @@ pagedresults_free_one_msgid_nolock( Connection *conn, ber_int_t msgid )
prp->pr_search_result_set) {
prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set));
}
- prp->pr_current_be = NULL;
prp->pr_flags |= CONN_FLAG_PAGEDRESULTS_ABANDONED;
prp->pr_flags &= ~CONN_FLAG_PAGEDRESULTS_PROCESSING;
- conn->c_pagedresults.prl_count--;
rc = 0;
break;
}
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
- "<-- pagedresults_free_one: %d\n", rc);
+ "<-- pagedresults_free_one_msgid_nolock: %d\n", rc);
}
}
@@ -845,37 +872,42 @@ pagedresults_reset_processing(Connection *conn, int index)
}
#endif
-/* Are all the paged results requests timed out? */
+/*
+ * This timedout is mainly for an end user leaves a commandline untouched
+ * for a long time. This should not affect a permanent connection which
+ * manages multiple simple paged results requests over the connection.
+ *
+ * [rule]
+ * If there is just one slot and it's timed out, we return it is timedout.
+ * If there are multiple slots, the connection may be a permanent one.
+ * Do not return timed out here. But let the next request take care the
+ * timedout slot(s).
+ */
int
pagedresults_is_timedout_nolock(Connection *conn)
{
- int i;
PagedResults *prp = NULL;
time_t ctime;
- int rc = 0;
LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_is_timedout\n");
- if (NULL == conn || 0 == conn->c_pagedresults.prl_count) {
- LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: -\n");
- return rc;
+ if (!conn || (0 == conn->c_pagedresults.prl_maxlen)) {
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: false\n");
+ return 0;
}
ctime = current_time();
- for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) {
- prp = conn->c_pagedresults.prl_list + i;
+ prp = conn->c_pagedresults.prl_list;
+ if (prp && (1 == conn->c_pagedresults.prl_maxlen)) {
if (prp->pr_current_be && (prp->pr_timelimit > 0)) {
- if (ctime < prp->pr_timelimit) {
- LDAPDebug0Args(LDAP_DEBUG_TRACE,
- "<-- pagedresults_is_timedout: 0\n");
- return 0; /* at least, one request is not timed out. */
- } else {
- rc = 1; /* possibly timed out */
+ if (ctime > prp->pr_timelimit) {
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: true\n");
+ return 1;
}
}
}
- LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: 1\n");
- return rc; /* all requests are timed out. */
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: false\n");
+ return 0;
}
/* reset all timeout */
commit d49ef9b91ae60799e3c497a907d22400499b33f8
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jun 3 15:02:40 2015 -0700
Ticket #48148 - start/stop/restart-dirsrv utilities should ignore admin-serv directory
Description: coverity defect
Defect type: SHELLCHECK_WARNING
/usr/sbin/start|stop|restart-dirsrv: warning: In POSIX sh, == is not supported.
Replacing
if [ $SERV_ID == "admin" ]; then
with
if [ "$SERV_ID" = "admin" ] ; then
https://fedorahosted.org/389/ticket/48148
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index 79fc1b1..87c9581 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -10,7 +10,7 @@
restart_instance() {
SERV_ID=$1
- if [ $SERV_ID == "admin" ]; then
+ if [ "$SERV_ID" = "admin" ] ; then
#ignore admin
return 0
fi
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 4e36939..32fb7fa 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -19,7 +19,7 @@ start_instance() {
shift
# source env. for this instance
- if [ $SERV_ID == "admin" ] ; then
+ if [ "$SERV_ID" = "admin" ] ; then
# ignore admin
return 0
elif [ -f $initconfig_dir/dirsrv-$SERV_ID ] ; then
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 15a84a4..8889ecc 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -10,7 +10,7 @@ stop_instance() {
SERV_ID=$1
# source env. for this instance
- if [ $SERV_ID == "admin" ] ; then
+ if [ "$SERV_ID" = "admin" ] ; then
# ignore admin
return 0
elif [ -f $initconfig_dir/dirsrv-$SERV_ID ] ; then
commit 608fcdfcd792e351edfc12cf89c2c9c6fc2a56d0
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jun 3 12:12:54 2015 -0700
Ticket #48149 - ns-slapd double free or corruption crash
Description: coverity defect: 2. Defect type: FORWARD_NULL
If mempstat is issued while an online import is running, it'd crash
the server.
https://fedorahosted.org/389/ticket/48149
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index c0e278a..68710b4 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4769,22 +4769,24 @@ int dblayer_memp_stat_instance(ldbm_instance *inst, DB_MPOOL_STAT **gsp,
{
DB_ENV *env = NULL;
dblayer_private *priv = NULL;
+ struct dblayer_private_env *dblayerenv;
int rc;
PR_ASSERT(NULL != inst);
if (inst->import_env->dblayer_DB_ENV) {
- env = inst->import_env->dblayer_DB_ENV;
+ dblayerenv = inst->import_env;
} else {
priv = (dblayer_private *)inst->inst_li->li_dblayer_private;
PR_ASSERT(NULL != priv);
- env = priv->dblayer_env->dblayer_DB_ENV;
+ dblayerenv = priv->dblayer_env;
}
+ env = dblayerenv->dblayer_DB_ENV;
PR_ASSERT(NULL != env);
- slapi_rwlock_wrlock(priv->dblayer_env->dblayer_env_lock);
+ slapi_rwlock_wrlock(dblayerenv->dblayer_env_lock);
rc = MEMP_STAT(env, gsp, fsp, 0, (void *)slapi_ch_malloc);
- slapi_rwlock_unlock(priv->dblayer_env->dblayer_env_lock);
+ slapi_rwlock_unlock(dblayerenv->dblayer_env_lock);
return rc;
}
8 years, 10 months