summaryrefslogtreecommitdiff
path: root/error_utils.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-10-17 08:15:39 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-10-17 08:15:39 -0400
commit8b369f263f10de056c3633806a7f1ed87e2b7145 (patch)
tree8a0d9c4ed35663da416abb08412eb0aa920ba697 /error_utils.c
parentb4a429729774f91ff259fe17d256b00134bc9f1f (diff)
init threading properly, added more mutex locks
Diffstat (limited to 'error_utils.c')
-rw-r--r--error_utils.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/error_utils.c b/error_utils.c
index d4c48a3..bb2cd32 100644
--- a/error_utils.c
+++ b/error_utils.c
@@ -528,13 +528,16 @@ void get_error_text(gchar **response, int error_num)
int Error_check(ChannelStruct ChannelStateToTest[max_channels])
{
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ g_static_mutex_lock (&mutex);
float max_duty_high_ampl,max_duty_low_ampl,max_duty_this_ampl;
float ampl_fixed_max_duty;
float temp;
float duty_scale;
float duty_cycle;
- int report_error;
+ int report_error = OK;
+ gboolean early_quit = FALSE;
int i;
int num_of_chan;
@@ -640,29 +643,33 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
- report_error=OK;
-
- for (i=0; i<num_of_chan; ++i) {
+ for (i=0; (i<num_of_chan) && !early_quit; ++i) {
/* Must be changing a setting */
globals.Timers.last_activity_at[i] = sec_timer ();
/* ignore errors if it is in programming mode */
if (globals.Flash.fully_programmed != All_Programmed) {
- return OK;
+ early_quit = TRUE;
+ break;
}
if (globals.Flags.do_check_settings==NO) {
- return OK;
+ early_quit = TRUE;
+ break;
}
/* check for settings that would cause divide-by-zero errors in the error-checking routine */
if (ChannelStateToTest[i].frequency<smallest_allowed_number) {
- return freq_lower_limit;
+ early_quit = TRUE;
+ report_error = freq_lower_limit;
+ break;
}
if (ChannelStateToTest[i].pw<smallest_allowed_number
&& globals.Flash.min_pw[i]>0.0) {
- return pw_lower_limit;
+ early_quit = TRUE;
+ report_error = pw_lower_limit;
+ break;
}
/* calculate maximum duty cycle based on amplitude and load, for later use */
@@ -1421,6 +1428,8 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
/* --- done all per-channel checking ---- */
}
+ g_static_mutex_unlock (&mutex);
+
return report_error;
}