@@ -102,6 +102,8 @@ vartab_t *vartab_h = NULL;
102102time_t poll_interval = 2 ;
103103static char * chroot_path = NULL , * user = NULL , * group = NULL ;
104104static int user_from_cmdline = 0 , group_from_cmdline = 0 ;
105+ /* visible to driver implementations */
106+ int reconnect_max_tries = -1 , reconnect_count = 0 ;
105107
106108/* signal handling */
107109int exit_flag = 0 ;
@@ -1397,6 +1399,18 @@ static int main_arg(char *var, char *val)
13971399 return 1 ; /* handled */
13981400 }
13991401
1402+ /* Allow per-driver overrides of the global setting
1403+ * and allow to reload this, why not. */
1404+ if (!strcmp (var , "reconnect_max_tries" )) {
1405+ int intval = -1 ;
1406+ if ( str_to_int (val , & intval , 10 ) ) {
1407+ reconnect_max_tries = intval ;
1408+ reconnect_count = 0 ;
1409+ } else {
1410+ upslogx (LOG_INFO , "WARNING : Invalid reconnect_max_tries value found in ups.conf global settings" );
1411+ }
1412+ }
1413+
14001414 /* only for upsdrvctl - ignored here */
14011415 if (!strcmp (var , "sdorder" ))
14021416 return 1 ; /* handled */
@@ -1571,6 +1585,18 @@ static void do_global_args(const char *var, const char *val)
15711585 return ;
15721586 }
15731587
1588+ if (!strcmp (var , "reconnect_max_tries" )) {
1589+ int intval = -1 ;
1590+ if ( str_to_int (val , & intval , 10 ) ) {
1591+ reconnect_max_tries = intval ;
1592+ reconnect_count = 0 ;
1593+ } else {
1594+ upslogx (LOG_INFO , "WARNING : Invalid reconnect_max_tries value found in ups.conf global settings" );
1595+ }
1596+
1597+ return ;
1598+ }
1599+
15741600 /* Allow to specify its minimal debugging level for all drivers -
15751601 * admins can set more with command-line args, but can't set
15761602 * less without changing config. Should help debug of services.
0 commit comments