Skip to content

Commit

Permalink
parameterize the sleep times in thread ddc_recheck_displays_func()
Browse files Browse the repository at this point in the history
set by WATCH_RETRY_THREAD_SLEEP_FACTOR_MILLISEC in parms.h
  • Loading branch information
rockowitz committed Jan 6, 2025
1 parent 4d9179a commit 44c8385
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/base/parms.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
/** Polling interval between stabilization checks */
#define DEFAULT_STABILIZATION_POLL_MILLISEC 100

/// When checking that DDC communication has become enabled,
// checks occur at increasing multipliers of this value.
#define WATCH_RETRY_THREAD_SLEEP_FACTOR_MILLISEC 1000

//
// *** Miscellaneous
Expand Down
15 changes: 7 additions & 8 deletions src/ddc/ddc_watch_displays_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_CONN;

int nonudev_poll_loop_millisec = DEFAULT_UDEV_WATCH_LOOP_MILLISEC; // 2000; // default sleep time on each loop
bool stabilize_added_buses_w_edid;
bool stabilize_added_buses_w_edid; // not set, only stabilize when displays removed
int retry_thread_sleep_factor_millis = WATCH_RETRY_THREAD_SLEEP_FACTOR_MILLISEC;

#ifdef OLD
//
Expand Down Expand Up @@ -500,22 +501,20 @@ gpointer ddc_recheck_displays_func(gpointer data) {
}
#endif

int sleep_sec = 0;
for (int sleepctr = 0; sleepctr < 4 && displays_to_recheck->len > 0; sleepctr++) {
sleep_sec = simple_ipow(2, sleepctr);
// sleep(sleep_sec);
DW_SLEEP_MILLIS(sleep_sec*1000, "Recheck interval");
int sleep_multiplier = simple_ipow(2, sleepctr);
DW_SLEEP_MILLIS(sleep_multiplier*retry_thread_sleep_factor_millis, "Recheck interval");

for (int ndx = displays_to_recheck->len-1; ndx >= 0; ndx--) {
Display_Ref * dref = g_ptr_array_index(displays_to_recheck, ndx);
// DBGMSG(" rechecking %s", dref_repr_t(dref));
bool ddc_enabled = ddc_recheck_dref(dref);
if (!ddc_enabled) {
DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE,
"ddc still not enabled for %s after %d seconds", dref_reprx_t(dref), sleep_sec);
"ddc still not enabled for %s after %d seconds", dref_reprx_t(dref), sleep_multiplier);
}
else {
char * s = g_strdup_printf("ddc became enabled for %s after %d seconds", dref_reprx_t(dref), sleep_sec);
char * s = g_strdup_printf("ddc became enabled for %s after %d seconds", dref_reprx_t(dref), sleep_multiplier);
DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "%s", s);
SYSLOG2(DDCA_SYSLOG_NOTICE, "%s", s);
free(s);
Expand All @@ -535,7 +534,7 @@ gpointer ddc_recheck_displays_func(gpointer data) {
Display_Ref * dref = g_ptr_array_index(displays_to_recheck, ndx);
char * s = g_strdup_printf(
"ddc communication did not become enabled for display %s within %d seconds",
dref_reprx_t(dref), sleep_sec);
dref_reprx_t(dref), sleep_multiplier);
DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "%s", s);
SYSLOG2(DDCA_SYSLOG_ERROR, "%s", s);
free(s);
Expand Down

0 comments on commit 44c8385

Please sign in to comment.