Skip to content

Commit

Permalink
move logic into request_enqueue()
Browse files Browse the repository at this point in the history
in our quest to simplify queue_or_run.  So that eventually the
timer, etc. work can be done in a child thread
  • Loading branch information
alandekok committed Feb 19, 2016
1 parent 4173135 commit fd06a09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/main/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,22 +888,7 @@ static void request_queue_or_run(REQUEST *request,

STATE_MACHINE_TIMER(FR_ACTION_TIMER);

if (spawn_workers) {
request_enqueue(request);
return;
}

request->child_state = REQUEST_RUNNING;
request->process(request, FR_ACTION_RUN);

#ifdef WNOHANG
/*
* Requests that care about child process exit
* codes have already either called
* rad_waitpid(), or they've given up.
*/
while (waitpid(-1, NULL, WNOHANG) > 0);
#endif
request_enqueue(request);
}


Expand Down
19 changes: 19 additions & 0 deletions src/main/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,25 @@ void request_enqueue(REQUEST *request)

request->component = "<core>";
request->module = "<queue>";

/*
* No child threads, just process it here.
*/
if (!thread_pool.spawn_workers) {
request->child_state = REQUEST_RUNNING;
request->process(request, FR_ACTION_RUN);

#ifdef WNOHANG
/*
* Requests that care about child process exit
* codes have already either called
* rad_waitpid(), or they've given up.
*/
while (waitpid(-1, NULL, WNOHANG) > 0);
#endif
return;
}

request->child_state = REQUEST_QUEUED;

/*
Expand Down

0 comments on commit fd06a09

Please sign in to comment.