[389-ds-base] branch 389-ds-base-1.3.10 updated: Issue 50653 - objectclass parsing fails to log error message text
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.3.10
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.3.10 by this push:
new b89df90 Issue 50653 - objectclass parsing fails to log error message text
b89df90 is described below
commit b89df902174e93a75a6e25a0f1769fb790faf22b
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Wed Oct 16 14:16:55 2019 -0400
Issue 50653 - objectclass parsing fails to log error message text
Description: When replacing an objectclass, if it already exists we
log an error but we do not log what objectclass it is.
This commit adds the error message text.
relates: https://pagure.io/389-ds-base/issue/50653
Reviewed by: abbra(Thanks!)
---
ldap/servers/slapd/schema.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 68c9834..e4f0d66 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -126,7 +126,7 @@ static struct dse *pschemadse = NULL;
static void oc_add_nolock(struct objclass *newoc);
static int oc_delete_nolock(char *ocname);
-static int oc_replace_nolock(const char *ocname, struct objclass *newoc);
+static int oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize);
static int oc_check_required(Slapi_PBlock *, Slapi_Entry *, struct objclass *);
static int oc_check_allowed_sv(Slapi_PBlock *, Slapi_Entry *e, const char *type, struct objclass **oclist);
static int schema_delete_objectclasses(Slapi_Entry *entryBefore,
@@ -1110,7 +1110,7 @@ oc_find_oid_nolock(const char *ocoid)
*/
static int
-oc_replace_nolock(const char *ocname, struct objclass *newoc)
+oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize)
{
struct objclass *oc, *pnext;
int rc = LDAP_SUCCESS;
@@ -1130,6 +1130,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
for (pnext = oc; pnext != NULL;
oc = pnext, pnext = pnext->oc_next) {
if (pnext->oc_name == NULL) {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Failed to replace objectclass");
rc = LDAP_OPERATIONS_ERROR;
break;
}
@@ -1146,6 +1148,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
break;
} else {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Can not replace objectclass that already exists");
rc = LDAP_TYPE_OR_VALUE_EXISTS;
break;
}
@@ -2817,7 +2821,7 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize, i
/* insert new objectclass exactly where the old one one in the linked list*/
if (!rc && redefined_oc) {
pnew_oc->oc_flags |= OC_FLAG_REDEFINED_OC;
- rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc);
+ rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc, errorbuf, errorbufsize);
}
if (!rc && !redefined_oc) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch 389-ds-base-1.4.0 updated: Issue 50653 - objectclass parsing fails to log error message text
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.4.0
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.0 by this push:
new 2d398a2 Issue 50653 - objectclass parsing fails to log error message text
2d398a2 is described below
commit 2d398a24375439058556a6b6e6c7e5ae16f1233a
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Wed Oct 16 14:16:55 2019 -0400
Issue 50653 - objectclass parsing fails to log error message text
Description: When replacing an objectclass, if it already exists we
log an error but we do not log what objectclass it is.
This commit adds the error message text.
relates: https://pagure.io/389-ds-base/issue/50653
Reviewed by: abbra(Thanks!)
---
ldap/servers/slapd/schema.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 458e143..59447c1 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -126,7 +126,7 @@ static struct dse *pschemadse = NULL;
static void oc_add_nolock(struct objclass *newoc);
static int oc_delete_nolock(char *ocname);
-static int oc_replace_nolock(const char *ocname, struct objclass *newoc);
+static int oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize);
static int oc_check_required(Slapi_PBlock *, Slapi_Entry *, struct objclass *);
static int oc_check_allowed_sv(Slapi_PBlock *, Slapi_Entry *e, const char *type, struct objclass **oclist);
static int schema_delete_objectclasses(Slapi_Entry *entryBefore,
@@ -1110,7 +1110,7 @@ oc_find_oid_nolock(const char *ocoid)
*/
static int
-oc_replace_nolock(const char *ocname, struct objclass *newoc)
+oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize)
{
struct objclass *oc, *pnext;
int rc = LDAP_SUCCESS;
@@ -1130,6 +1130,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
for (pnext = oc; pnext != NULL;
oc = pnext, pnext = pnext->oc_next) {
if (pnext->oc_name == NULL) {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Failed to replace objectclass");
rc = LDAP_OPERATIONS_ERROR;
break;
}
@@ -1146,6 +1148,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
break;
} else {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Can not replace objectclass that already exists");
rc = LDAP_TYPE_OR_VALUE_EXISTS;
break;
}
@@ -2817,7 +2821,7 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize, i
/* insert new objectclass exactly where the old one one in the linked list*/
if (!rc && redefined_oc) {
pnew_oc->oc_flags |= OC_FLAG_REDEFINED_OC;
- rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc);
+ rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc, errorbuf, errorbufsize);
}
if (!rc && !redefined_oc) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch 389-ds-base-1.4.1 updated: Issue 50653 - objectclass parsing fails to log error message text
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.4.1
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.1 by this push:
new f3f99c4 Issue 50653 - objectclass parsing fails to log error message text
f3f99c4 is described below
commit f3f99c43db1178681e8b0c73939f0747bebee2cf
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Wed Oct 16 14:16:55 2019 -0400
Issue 50653 - objectclass parsing fails to log error message text
Description: When replacing an objectclass, if it already exists we
log an error but we do not log what objectclass it is.
This commit adds the error message text.
relates: https://pagure.io/389-ds-base/issue/50653
Reviewed by: abbra(Thanks!)
---
ldap/servers/slapd/schema.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 7b3cac5..6e853fc 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -124,7 +124,7 @@ static struct dse *pschemadse = NULL;
static void oc_add_nolock(struct objclass *newoc);
static int oc_delete_nolock(char *ocname);
-static int oc_replace_nolock(const char *ocname, struct objclass *newoc);
+static int oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize);
static int oc_check_required(Slapi_PBlock *, Slapi_Entry *, struct objclass *);
static int oc_check_allowed_sv(Slapi_PBlock *, Slapi_Entry *e, const char *type, struct objclass **oclist);
static int schema_delete_objectclasses(Slapi_Entry *entryBefore,
@@ -1003,7 +1003,7 @@ oc_find_oid_nolock(const char *ocoid)
*/
static int
-oc_replace_nolock(const char *ocname, struct objclass *newoc)
+oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize)
{
struct objclass *oc, *pnext;
int rc = LDAP_SUCCESS;
@@ -1023,6 +1023,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
for (pnext = oc; pnext != NULL;
oc = pnext, pnext = pnext->oc_next) {
if (pnext->oc_name == NULL) {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Failed to replace objectclass");
rc = LDAP_OPERATIONS_ERROR;
break;
}
@@ -1039,6 +1041,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
break;
} else {
+ schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
+ ocname, "Can not replace objectclass that already exists");
rc = LDAP_TYPE_OR_VALUE_EXISTS;
break;
}
@@ -2699,7 +2703,7 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize, i
/* insert new objectclass exactly where the old one one in the linked list*/
if (!rc && redefined_oc) {
pnew_oc->oc_flags |= OC_FLAG_REDEFINED_OC;
- rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc);
+ rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc, errorbuf, errorbufsize);
}
if (!rc && !redefined_oc) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch master updated: Issue 50646 - Improve task handling during shutdowns
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch master
in repository 389-ds-base.
The following commit(s) were added to refs/heads/master by this push:
new 7a0a090 Issue 50646 - Improve task handling during shutdowns
7a0a090 is described below
commit 7a0a090cf3ddfc4c8afff6af17b0c75e54d7f601
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Wed Oct 16 14:56:46 2019 -0400
Issue 50646 - Improve task handling during shutdowns
Bug Description: There is a race condition when stopping the server and
a running import task that can cause a heap-use-after-free.
Fix Description: For an import task, encapsulate the import thread with
a global thread increment/decrement (just like the export
task). Also improved how tasks are notified to abort by
notifiying them before we wait for active threads to finish.
Then the tasks get destroyed after all threads are complete.
relates: https://pagure.io/389-ds-base/issue/50646
Reviewed by: lkrispen & tbordaz (Thanks!!)
---
ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c | 3 ++
ldap/servers/slapd/daemon.c | 5 +++
ldap/servers/slapd/main.c | 2 +-
ldap/servers/slapd/slapi-private.h | 1 +
ldap/servers/slapd/task.c | 39 +++++++++++++++---------
5 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
index 3086c4c..2fd7524 100644
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
@@ -2606,7 +2606,10 @@ error:
void
import_main(void *arg)
{
+ /* For online import tasks increment/decrement the global thread count */
+ g_incr_active_threadcnt();
import_main_offline(arg);
+ g_decr_active_threadcnt();
}
int
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 567a9b7..345e292 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1116,6 +1116,11 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
ns_thrpool_wait(tp);
}
+ if (!in_referral_mode) {
+ /* signal tasks to start shutting down */
+ task_cancel_all();
+ }
+
threads = g_get_active_threadcnt();
if (threads > 0) {
slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 2163213..183750b 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -2001,7 +2001,7 @@ lookup_plugin_by_instance_name(const char *name)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = slapi_pblock_new();
- struct slapdplugin *plugin;
+ struct slapdplugin *plugin = NULL;
char *query, *dn, *cn;
int ret = 0;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 3d196b0..04c0455 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -802,6 +802,7 @@ int slapi_lookup_instance_name_by_suffix(char *suffix,
/* begin and end the task subsystem */
void task_init(void);
+void task_cancel_all(void);
void task_shutdown(void);
void task_cleanup(void);
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 76a08a6..78f14c7 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -26,7 +26,7 @@
*/
static Slapi_Task *global_task_list = NULL;
static PRLock *global_task_lock = NULL;
-static int shutting_down = 0;
+static uint64_t shutting_down = 0;
/***********************************
* Private Defines
@@ -582,7 +582,7 @@ new_task(const char *rawdn, void *plugin)
Slapi_Task *task = NULL;
char *dn = NULL;
- if (rawdn == NULL) {
+ if (rawdn == NULL || shutting_down) {
return NULL;
}
@@ -611,6 +611,16 @@ new_task(const char *rawdn, void *plugin)
PR_Lock(task->task_log_lock);
PR_Lock(global_task_lock);
+ if (shutting_down) {
+ /* Abort! Free everything and return NULL */
+ PR_Unlock(task->task_log_lock);
+ PR_Unlock(global_task_lock);
+ PR_DestroyLock(task->task_log_lock);
+ slapi_ch_free((void **)&task);
+ slapi_ch_free_string(&dn);
+ slapi_log_err(SLAPI_LOG_ERR, "new_task", "Server is shutting down, aborting task: %s\n", rawdn);
+ return NULL;
+ }
task->next = global_task_list;
global_task_list = task;
PR_Unlock(global_task_lock);
@@ -2987,32 +2997,31 @@ task_init(void)
/* called when the server is shutting down -- abort all existing tasks */
void
-task_shutdown(void)
-{
+task_cancel_all(void) {
Slapi_Task *task;
- int found_any = 0;
- /* first, cancel all tasks */
PR_Lock(global_task_lock);
shutting_down = 1;
for (task = global_task_list; task; task = task->next) {
- if ((task->task_state != SLAPI_TASK_CANCELLED) &&
- (task->task_state != SLAPI_TASK_FINISHED)) {
+ if (task->task_state != SLAPI_TASK_CANCELLED &&
+ task->task_state != SLAPI_TASK_FINISHED)
+ {
task->task_state = SLAPI_TASK_CANCELLED;
if (task->cancel) {
- slapi_log_err(SLAPI_LOG_INFO, "task_shutdown", "Cancelling task '%s'\n",
+ slapi_log_err(SLAPI_LOG_INFO, "task_cancel_all", "Canceling task '%s'\n",
task->task_dn);
(*task->cancel)(task);
- found_any = 1;
}
}
}
+ PR_Unlock(global_task_lock);
+}
- if (found_any) {
- /* give any tasks 1 second to say their last rites */
- DS_Sleep(PR_SecondsToInterval(1));
- }
-
+void
+task_shutdown(void)
+{
+ /* Now we can destroy the tasks... */
+ PR_Lock(global_task_lock);
while (global_task_list) {
destroy_task(0, global_task_list);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch 389-ds-base-1.3.10 updated: Issue 50646 - Improve task handling during shutdowns
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.3.10
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.3.10 by this push:
new 9e88768 Issue 50646 - Improve task handling during shutdowns
9e88768 is described below
commit 9e887680f76912046bfa43a23a80b83c62b72d49
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Tue Oct 15 11:02:24 2019 -0400
Issue 50646 - Improve task handling during shutdowns
Bug Description: There is a race condition when stopping the server and
a running import task that can cause a heap-use-after-free.
Fix Description: For an import task, encapsulate the import thread with
a global thread increment/decrement (just like the export
task). Also improved how tasks are notified to abort by
notifiying them before we wait for active threads to finish.
Then the tasks get destroyed after all threads are complete.
relates: https://pagure.io/389-ds-base/issue/50646
Reviewed by: lkrispen & tbordaz (Thanks!!)
---
ldap/servers/slapd/back-ldbm/import.c | 3 +++
ldap/servers/slapd/daemon.c | 5 +++++
ldap/servers/slapd/main.c | 2 +-
ldap/servers/slapd/slapi-private.h | 1 +
ldap/servers/slapd/task.c | 40 ++++++++++++++++++++++-------------
5 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index 42e2696..1c21f6e 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1626,7 +1626,10 @@ error:
void
import_main(void *arg)
{
+ /* For online import tasks increment/decrement the global thread count */
+ g_incr_active_threadcnt();
import_main_offline(arg);
+ g_decr_active_threadcnt();
}
int
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index afe0fb7..5d8767d 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1218,6 +1218,11 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
ns_thrpool_wait(tp);
}
+ if (!in_referral_mode) {
+ /* signal tasks to start shutting down */
+ task_cancel_all();
+ }
+
threads = g_get_active_threadcnt();
if (threads > 0) {
slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 5e24b3b..5ca52ce 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1989,7 +1989,7 @@ lookup_plugin_by_instance_name(const char *name)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = slapi_pblock_new();
- struct slapdplugin *plugin;
+ struct slapdplugin *plugin = NULL;
char *query, *dn, *cn;
int ret = 0;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index b347b61..d676486 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -794,6 +794,7 @@ int slapi_lookup_instance_name_by_suffix(char *suffix,
/* begin and end the task subsystem */
void task_init(void);
+void task_cancel_all(void);
void task_shutdown(void);
void task_cleanup(void);
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 80a2383..7e70947 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -26,7 +26,7 @@
*/
static Slapi_Task *global_task_list = NULL;
static PRLock *global_task_lock = NULL;
-static int shutting_down = 0;
+static uint64_t shutting_down = 0;
/***********************************
* Private Defines
@@ -588,7 +588,7 @@ new_task(const char *rawdn, void *plugin)
Slapi_Task *task = NULL;
char *dn = NULL;
- if (rawdn == NULL) {
+ if (rawdn == NULL || shutting_down) {
return NULL;
}
@@ -600,9 +600,20 @@ new_task(const char *rawdn, void *plugin)
}
task = (Slapi_Task *)slapi_ch_calloc(1, sizeof(Slapi_Task));
PR_Lock(global_task_lock);
+ if (shutting_down) {
+ /* Abort! Free everything and return NULL */
+ PR_Unlock(task->task_log_lock);
+ PR_Unlock(global_task_lock);
+ PR_DestroyLock(task->task_log_lock);
+ slapi_ch_free((void **)&task);
+ slapi_ch_free_string(&dn);
+ slapi_log_err(SLAPI_LOG_ERR, "new_task", "Server is shutting down, aborting task: %s\n", rawdn);
+ return NULL;
+ }
task->next = global_task_list;
global_task_list = task;
PR_Unlock(global_task_lock);
+
task->task_dn = dn;
task->task_state = SLAPI_TASK_SETUP;
task->task_flags = SLAPI_TASK_RUNNING_AS_TASK;
@@ -2990,32 +3001,31 @@ task_init(void)
/* called when the server is shutting down -- abort all existing tasks */
void
-task_shutdown(void)
-{
+task_cancel_all(void) {
Slapi_Task *task;
- int found_any = 0;
- /* first, cancel all tasks */
PR_Lock(global_task_lock);
shutting_down = 1;
for (task = global_task_list; task; task = task->next) {
- if ((task->task_state != SLAPI_TASK_CANCELLED) &&
- (task->task_state != SLAPI_TASK_FINISHED)) {
+ if (task->task_state != SLAPI_TASK_CANCELLED &&
+ task->task_state != SLAPI_TASK_FINISHED)
+ {
task->task_state = SLAPI_TASK_CANCELLED;
if (task->cancel) {
- slapi_log_err(SLAPI_LOG_INFO, "task_shutdown", "Cancelling task '%s'\n",
+ slapi_log_err(SLAPI_LOG_INFO, "task_cancel_all", "Canceling task '%s'\n",
task->task_dn);
(*task->cancel)(task);
- found_any = 1;
}
}
}
+ PR_Unlock(global_task_lock);
+}
- if (found_any) {
- /* give any tasks 1 second to say their last rites */
- DS_Sleep(PR_SecondsToInterval(1));
- }
-
+void
+task_shutdown(void)
+{
+ /* Now we can destroy the tasks... */
+ PR_Lock(global_task_lock);
while (global_task_list) {
destroy_task(0, global_task_list);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch 389-ds-base-1.4.0 updated: Issue 50646 - Improve task handling during shutdowns
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.4.0
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.0 by this push:
new 4898470 Issue 50646 - Improve task handling during shutdowns
4898470 is described below
commit 48984709eed2d0fa6b4f7cb6898b94fe3ed4deac
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Tue Oct 15 11:02:24 2019 -0400
Issue 50646 - Improve task handling during shutdowns
Bug Description: There is a race condition when stopping the server and
a running import task that can cause a heap-use-after-free.
Fix Description: For an import task, encapsulate the import thread with
a global thread increment/decrement (just like the export
task). Also improved how tasks are notified to abort by
notifiying them before we wait for active threads to finish.
Then the tasks get destroyed after all threads are complete.
relates: https://pagure.io/389-ds-base/issue/50646
Reviewed by: lkrispen & tbordaz (Thanks!!)
---
ldap/servers/slapd/back-ldbm/import.c | 3 +++
ldap/servers/slapd/daemon.c | 5 +++++
ldap/servers/slapd/main.c | 2 +-
ldap/servers/slapd/slapi-private.h | 1 +
ldap/servers/slapd/task.c | 40 ++++++++++++++++++++++-------------
5 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index 42e2696..1c21f6e 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1626,7 +1626,10 @@ error:
void
import_main(void *arg)
{
+ /* For online import tasks increment/decrement the global thread count */
+ g_incr_active_threadcnt();
import_main_offline(arg);
+ g_decr_active_threadcnt();
}
int
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index b1d41c8..9f9c3a7 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1218,6 +1218,11 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
ns_thrpool_wait(tp);
}
+ if (!in_referral_mode) {
+ /* signal tasks to start shutting down */
+ task_cancel_all();
+ }
+
threads = g_get_active_threadcnt();
if (threads > 0) {
slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 8224cd0..bd8db5f 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -2002,7 +2002,7 @@ lookup_plugin_by_instance_name(const char *name)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = slapi_pblock_new();
- struct slapdplugin *plugin;
+ struct slapdplugin *plugin = NULL;
char *query, *dn, *cn;
int ret = 0;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 4161002..b4e7028 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -794,6 +794,7 @@ int slapi_lookup_instance_name_by_suffix(char *suffix,
/* begin and end the task subsystem */
void task_init(void);
+void task_cancel_all(void);
void task_shutdown(void);
void task_cleanup(void);
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 025ffcb..31a6f2b 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -26,7 +26,7 @@
*/
static Slapi_Task *global_task_list = NULL;
static PRLock *global_task_lock = NULL;
-static int shutting_down = 0;
+static uint64_t shutting_down = 0;
/***********************************
* Private Defines
@@ -582,7 +582,7 @@ new_task(const char *rawdn, void *plugin)
Slapi_Task *task = NULL;
char *dn = NULL;
- if (rawdn == NULL) {
+ if (rawdn == NULL || shutting_down) {
return NULL;
}
@@ -611,9 +611,20 @@ new_task(const char *rawdn, void *plugin)
PR_Lock(task->task_log_lock);
PR_Lock(global_task_lock);
+ if (shutting_down) {
+ /* Abort! Free everything and return NULL */
+ PR_Unlock(task->task_log_lock);
+ PR_Unlock(global_task_lock);
+ PR_DestroyLock(task->task_log_lock);
+ slapi_ch_free((void **)&task);
+ slapi_ch_free_string(&dn);
+ slapi_log_err(SLAPI_LOG_ERR, "new_task", "Server is shutting down, aborting task: %s\n", rawdn);
+ return NULL;
+ }
task->next = global_task_list;
global_task_list = task;
PR_Unlock(global_task_lock);
+
task->task_dn = dn;
task->task_state = SLAPI_TASK_SETUP;
task->task_flags = SLAPI_TASK_RUNNING_AS_TASK;
@@ -3004,32 +3015,31 @@ task_init(void)
/* called when the server is shutting down -- abort all existing tasks */
void
-task_shutdown(void)
-{
+task_cancel_all(void) {
Slapi_Task *task;
- int found_any = 0;
- /* first, cancel all tasks */
PR_Lock(global_task_lock);
shutting_down = 1;
for (task = global_task_list; task; task = task->next) {
- if ((task->task_state != SLAPI_TASK_CANCELLED) &&
- (task->task_state != SLAPI_TASK_FINISHED)) {
+ if (task->task_state != SLAPI_TASK_CANCELLED &&
+ task->task_state != SLAPI_TASK_FINISHED)
+ {
task->task_state = SLAPI_TASK_CANCELLED;
if (task->cancel) {
- slapi_log_err(SLAPI_LOG_INFO, "task_shutdown", "Cancelling task '%s'\n",
+ slapi_log_err(SLAPI_LOG_INFO, "task_cancel_all", "Canceling task '%s'\n",
task->task_dn);
(*task->cancel)(task);
- found_any = 1;
}
}
}
+ PR_Unlock(global_task_lock);
+}
- if (found_any) {
- /* give any tasks 1 second to say their last rites */
- DS_Sleep(PR_SecondsToInterval(1));
- }
-
+void
+task_shutdown(void)
+{
+ /* Now we can destroy the tasks... */
+ PR_Lock(global_task_lock);
while (global_task_list) {
destroy_task(0, global_task_list);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 6 months
[389-ds-base] branch 389-ds-base-1.4.1 updated: Ticket 50622 - ds_selinux_enabled may crash on suse
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch 389-ds-base-1.4.1
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.1 by this push:
new aa17602 Ticket 50622 - ds_selinux_enabled may crash on suse
aa17602 is described below
commit aa1760272fca05f5be6f82c50baa4db5af6ace50
Author: William Brown <william(a)blackhats.net.au>
AuthorDate: Wed Sep 25 12:19:37 2019 +1000
Ticket 50622 - ds_selinux_enabled may crash on suse
Bug Description: SUSE doesn't have the python-selinux module by
default, so this tool crashes as it can't find the python
module for import.
Fix Description: ATtempt to import the library, and on failure
return false for enabled.
https://pagure.io/389-ds-base/issue/50622
Author: William Brown <william(a)blackhats.net.au>
Review by: mhonek (Thanks!)
---
ldap/admin/src/scripts/ds_selinux_enabled.in | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ldap/admin/src/scripts/ds_selinux_enabled.in b/ldap/admin/src/scripts/ds_selinux_enabled.in
index 54a79b0..6720660 100755
--- a/ldap/admin/src/scripts/ds_selinux_enabled.in
+++ b/ldap/admin/src/scripts/ds_selinux_enabled.in
@@ -13,11 +13,13 @@
import sys
-import selinux
-import semanage
# Returns 1 for true, 0 for false.
-sys.exit(selinux.is_selinux_enabled())
+try:
+ import selinux
+ sys.exit(selinux.is_selinux_enabled())
+except ImportError:
+ sys.exit(0)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 7 months
[389-ds-base] branch 389-ds-base-1.4.0 updated: Ticket 50622 - ds_selinux_enabled may crash on suse
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch 389-ds-base-1.4.0
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.0 by this push:
new 6304942 Ticket 50622 - ds_selinux_enabled may crash on suse
6304942 is described below
commit 6304942ba43282a463e2b29eb66a0afa3ca1f951
Author: William Brown <william(a)blackhats.net.au>
AuthorDate: Wed Sep 25 12:19:37 2019 +1000
Ticket 50622 - ds_selinux_enabled may crash on suse
Bug Description: SUSE doesn't have the python-selinux module by
default, so this tool crashes as it can't find the python
module for import.
Fix Description: ATtempt to import the library, and on failure
return false for enabled.
https://pagure.io/389-ds-base/issue/50622
Author: William Brown <william(a)blackhats.net.au>
Review by: mhonek (Thanks!)
---
ldap/admin/src/scripts/ds_selinux_enabled.in | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ldap/admin/src/scripts/ds_selinux_enabled.in b/ldap/admin/src/scripts/ds_selinux_enabled.in
index 54a79b0..6720660 100755
--- a/ldap/admin/src/scripts/ds_selinux_enabled.in
+++ b/ldap/admin/src/scripts/ds_selinux_enabled.in
@@ -13,11 +13,13 @@
import sys
-import selinux
-import semanage
# Returns 1 for true, 0 for false.
-sys.exit(selinux.is_selinux_enabled())
+try:
+ import selinux
+ sys.exit(selinux.is_selinux_enabled())
+except ImportError:
+ sys.exit(0)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 7 months