Skip to content

Commit

Permalink
Ticket 49435 - Fix NS race condition on loaded test systems
Browse files Browse the repository at this point in the history
Bug Description:  During a test run, on a heavily loaded systems
some events would time out before they could occur correctly.

Fix Description:  Change the structure of events to mitigate
a deref performance hit, and add a ns_job_wait conditional
that allows blocking on a job to complete so that tests do not
require time based checks.

https://pagure.io/389-ds-base/issue/49435

Author: wibrown

Review by: mreynolds (Thanks!)
  • Loading branch information
Firstyear committed Nov 6, 2017
1 parent e622d95 commit 11974a0
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 137 deletions.
12 changes: 12 additions & 0 deletions src/nunc-stans/include/nunc-stans.h
Expand Up @@ -77,6 +77,10 @@ typedef enum _ns_result_t {
* This occurs when a lower level OS issue occurs, generally thread related.
*/
NS_THREAD_FAILURE = 5,
/**
* The job is being deleted
*/
NS_DELETING = 6,
} ns_result_t;

/**
Expand Down Expand Up @@ -836,6 +840,14 @@ ns_job_type_t ns_job_get_output_type(struct ns_job_t *job);
*/
ns_result_t ns_job_set_done_cb(struct ns_job_t *job, ns_job_func_t func);

/**
* Block until a job is completed. This returns the next state of the job as as a return.
*
* \param job The job to set the callback for.
* \retval ns_job_state_t The next state the job will move to. IE, WAITING, DELETED, ARMED.
*/
ns_result_t ns_job_wait(struct ns_job_t *job);

/**
* Creates a new thread pool
*
Expand Down
3 changes: 2 additions & 1 deletion src/nunc-stans/ns/ns_event_fw.h
Expand Up @@ -80,7 +80,8 @@ typedef enum _ns_job_state {
interface between the app/thread pool/event framework */
typedef struct ns_job_t
{
pthread_mutex_t *monitor;
pthread_mutex_t monitor;
pthread_cond_t notify;
struct ns_thrpool_t *tp;
ns_job_func_t func;
struct ns_job_data_t *data;
Expand Down

0 comments on commit 11974a0

Please sign in to comment.