-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 6374 - nsslapd-mdb-max-dbs autotuning doesn't work properly #6400
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4280,9 +4280,12 @@ dbmdb_import_init_writer(ImportJob *job, ImportRole_t role) | |
void | ||
dbmdb_free_import_ctx(ImportJob *job) | ||
{ | ||
if (job->writer_ctx) { | ||
ImportCtx_t *ctx = job->writer_ctx; | ||
job->writer_ctx = NULL; | ||
ImportCtx_t *ctx = NULL; | ||
pthread_mutex_lock(get_import_ctx_mutex()); | ||
ctx = job->writer_ctx; | ||
job->writer_ctx = NULL; | ||
pthread_mutex_unlock(get_import_ctx_mutex()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not moving the unlock up to the end of the function ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The writer_ctx is reset in the lock, so we are sure that the other threads cannot use it and |
||
if (ctx) { | ||
pthread_mutex_destroy(&ctx->workerq.mutex); | ||
pthread_cond_destroy(&ctx->workerq.cv); | ||
slapi_ch_free((void**)&ctx->workerq.slots); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
#define NEED_DN_NORM_SP -25 | ||
#define NEED_DN_NORM_BT -26 | ||
|
||
pthread_mutex_t import_ctx_mutex = PTHREAD_MUTEX_INITIALIZER; /* Protect agains import context destruction */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static ? |
||
|
||
|
||
/********** routines to manipulate the entry fifo **********/ | ||
|
||
|
@@ -143,6 +145,14 @@ ldbm_back_wire_import(Slapi_PBlock *pb) | |
|
||
/* Threads management */ | ||
|
||
/* Return the mutex that protects against import context destruction */ | ||
pthread_mutex_t * | ||
get_import_ctx_mutex() | ||
{ | ||
return &import_ctx_mutex; | ||
} | ||
|
||
|
||
/* tell all the threads to abort */ | ||
void | ||
import_abort_all(ImportJob *job, int wait_for_them) | ||
|
@@ -151,7 +161,7 @@ import_abort_all(ImportJob *job, int wait_for_them) | |
|
||
/* tell all the worker threads to abort */ | ||
job->flags |= FLAG_ABORT; | ||
|
||
pthread_mutex_lock(&import_ctx_mutex); | ||
for (worker = job->worker_list; worker; worker = worker->next) | ||
worker->command = ABORT; | ||
|
||
|
@@ -167,6 +177,7 @@ import_abort_all(ImportJob *job, int wait_for_them) | |
} | ||
} | ||
} | ||
pthread_mutex_unlock(&import_ctx_mutex); | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.