@@ -133,21 +133,21 @@ ocs::MirrorDataStore::event_mirror_update_func([[maybe_unused]] u_long32 ec_id,
133
133
}
134
134
135
135
/* * @brief Block executing thread till initial events are handled.
136
- * Recheck every 100ms.
137
136
*/
138
137
void
139
138
ocs::MirrorDataStore::block_till_initial_events_handled () {
140
139
DENTER (TOP_LAYER);
141
140
volatile bool wait = true ;
142
141
143
142
do {
144
- if (wait ) {
145
- sge_usleep (25000 );
146
- }
147
- DPRINTF (" still waiting for initial events to be handled\n " );
148
143
sge_mutex_lock (mutex_name.c_str (), __func__, __LINE__, &mutex);
149
144
wait = !did_handle_initial_events;
150
145
sge_mutex_unlock (mutex_name.c_str (), __func__, __LINE__, &mutex);
146
+
147
+ if (wait ) {
148
+ DPRINTF (" still waiting for initial events to be handled\n " );
149
+ sge_usleep (25000 );
150
+ }
151
151
} while (wait );
152
152
DRETURN_VOID;
153
153
}
@@ -332,8 +332,7 @@ ocs::MirrorDataStore::main([[maybe_unused]] void *arg) {
332
332
lList *event_list = nullptr ;
333
333
334
334
// wait for new events
335
- MONITOR_IDLE_TIME (wait_for_event (&event_list), (&monitor),
336
- mconf_get_monitoring_options ());
335
+ MONITOR_IDLE_TIME (wait_for_event (&event_list), (&monitor), mconf_get_monitoring_options ());
337
336
338
337
// if we lost connection we have to register again
339
338
if (evc->ec_need_new_registration (evc)) {
@@ -388,24 +387,23 @@ ocs::MirrorDataStore::main([[maybe_unused]] void *arg) {
388
387
389
388
// process the events
390
389
sge_mirror_error mirror_ret = sge_mirror_process_event_list (evc, event_list);
391
- #if 0
392
- DPRINTF("processed events\n");
393
- #endif
394
- lFreeList (&event_list);
395
390
if (mirror_ret == SGE_EM_OK) {
396
- did_handle_initial_events = true ;
391
+ // the first handling of non-empty event_list (== the initial list events)
392
+ // will cause the data store to be ready for other threads (listener, reader, scheduler, ...)
393
+ if (event_list != nullptr ) {
394
+ did_handle_initial_events = true ;
395
+ }
396
+
397
397
did_handle_events = true ;
398
398
399
399
// update the sessions about the last event that we processed so that waiting requests can continue
400
400
if (found_last_event) {
401
401
update_sessions_and_move_requests (last_unique_id);
402
- #if 0
403
- DPRINTF("updates sessions and moved requests\n");
404
- #endif
405
402
}
406
403
} else {
407
404
DPRINTF (" error during event processing\n " );
408
405
}
406
+ lFreeList (&event_list);
409
407
410
408
// Unlock the data store
411
409
unlock ();
@@ -423,7 +421,7 @@ ocs::MirrorDataStore::main([[maybe_unused]] void *arg) {
423
421
424
422
// actions if events where processed
425
423
if (did_handle_events) {
426
- thread_output_profiling (" scheduler thread profiling summary:\n " , &next_prof_output);
424
+ thread_output_profiling (" thread profiling summary:\n " , &next_prof_output);
427
425
sge_monitor_output (&monitor);
428
426
}
429
427
}
0 commit comments