@@ -130,8 +130,6 @@ static void *fr_schedule_worker_thread(void *arg)
130130
131131 if (fr_thread_setup (& sw -> thread , worker_name ) < 0 ) goto fail ;
132132
133- INFO ("%s - Starting" , worker_name );
134-
135133 sw -> worker = fr_worker_alloc (sw -> thread .ctx , sw -> thread .el , worker_name , sc -> log , sc -> lvl , & sc -> config -> worker );
136134 if (!sw -> worker ) {
137135 PERROR ("%s - Failed creating worker" , worker_name );
@@ -156,8 +154,6 @@ static void *fr_schedule_worker_thread(void *arg)
156154 }
157155 }
158156
159- sw -> thread .status = FR_THREAD_RUNNING ;
160-
161157 /*
162158 * Add this worker to all network threads.
163159 */
@@ -170,12 +166,10 @@ static void *fr_schedule_worker_thread(void *arg)
170166 }
171167 }
172168
173- DEBUG3 ("%s - Started" , worker_name );
174-
175169 /*
176170 * Tell the originator that the thread has started.
177171 */
178- sem_post ( sc -> worker_sem );
172+ fr_thread_start ( & sw -> thread , sc -> worker_sem );
179173
180174 /*
181175 * Do all of the work.
@@ -185,30 +179,14 @@ static void *fr_schedule_worker_thread(void *arg)
185179 status = FR_THREAD_EXITED ;
186180
187181fail :
188- sw -> thread .status = status ;
189-
190182 if (sw -> worker ) {
191183 fr_worker_destroy (sw -> worker );
192184 sw -> worker = NULL ;
193185 }
194186
195- INFO ("%s - Exiting" , worker_name );
196-
197187 if (sc -> worker_thread_detach ) sc -> worker_thread_detach (NULL ); /* Fixme once we figure out what uctx should be */
198188
199- /*
200- * Not looping at this point, but may catch timer/fd
201- * insertions being done after the thread should have
202- * exited.
203- */
204- if (sw -> thread .el ) fr_event_loop_exit (sw -> thread .el , 1 );
205-
206- /*
207- * Tell the scheduler we're done.
208- */
209- sem_post (sc -> worker_sem );
210-
211- talloc_free (sw -> thread .ctx );
189+ fr_thread_exit (& sw -> thread , status , sc -> worker_sem );
212190
213191 return NULL ;
214192}
@@ -247,21 +225,18 @@ static void *fr_schedule_network_thread(void *arg)
247225 goto fail ;
248226 }
249227
250- sn -> thread .status = FR_THREAD_RUNNING ;
251-
252228 /*
253229 * Tell the originator that the thread has started.
254230 */
255- sem_post (sc -> network_sem );
256-
257- DEBUG3 ("%s - Started" , network_name );
231+ fr_thread_start (& sn -> thread , sc -> network_sem );
258232
259233 /*
260234 * Print out statistics for this network IO handler.
261235 */
262236 if (fr_time_delta_ispos (sc -> config -> stats_interval )) {
263237 (void ) fr_timer_in (sn , sn -> thread .el -> tl , & sn -> ev , sn -> sc -> config -> stats_interval , false, stats_timer , sn );
264238 }
239+
265240 /*
266241 * Call the main event processing loop of the network
267242 * thread Will not return until the worker is about
@@ -272,16 +247,7 @@ static void *fr_schedule_network_thread(void *arg)
272247 status = FR_THREAD_EXITED ;
273248
274249fail :
275- sn -> thread .status = status ;
276-
277- INFO ("%s - Exiting" , network_name );
278-
279- /*
280- * Tell the scheduler we're done.
281- */
282- sem_post (sc -> network_sem );
283-
284- talloc_free (sn -> thread .ctx );
250+ fr_thread_exit (& sn -> thread , status , sc -> network_sem );
285251
286252 return NULL ;
287253}
0 commit comments