Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
instead of calling exit, sleep for a minute
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Apr 21, 2016
1 parent 4185f4e commit 034691e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
37 changes: 23 additions & 14 deletions src/apinger.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ struct alarm_cfg *a;
}
}

void
configure_targets(struct config *cfg, int reload)
int
configure_targets(struct config *cfg)
{
struct target *t,*pt,*nt;
struct target_cfg *tc;
Expand Down Expand Up @@ -729,13 +729,18 @@ configure_targets(struct config *cfg, int reload)
t->config=tc;
}

if (targets==NULL){
logit("No usable targets found, exiting");
exit(1);
if (!targets) {
logit("No usable targets found, sleeping...");
return (1);
}
gettimeofday(&operation_started,NULL);
if (cfg->rrd_interval)

gettimeofday(&operation_started, NULL);

if (cfg->rrd_interval) {
rrd_create();
}

return (0);
}

void
Expand Down Expand Up @@ -862,18 +867,22 @@ main_loop(void)
struct timeval event_time, cur_time, tv;
struct timeval next_status = { 0, 0 };
struct timeval next_report = { 0, 0 };
struct target *t;
struct active_alarm_list *aal;
struct alarm_list *al, *nal;
struct pollfd pfd[1024];
int timeout, timedelta;
int npfd = 0;
int i;
struct alarm_cfg *a;
struct target *t;
char buf[100];
int npfd = 0;
int downtime;
struct alarm_list *al,*nal;
struct active_alarm_list *aal;
struct alarm_cfg *a;
int i;

while (configure_targets(config)) {
/* retry every minute, beats exit() */
sleep(60);
}

configure_targets(config, 0);
memset(&pfd, '\0', sizeof pfd);

if (config->status_interval) {
Expand Down
9 changes: 5 additions & 4 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int ret;
}
}
if (config!=NULL){
configure_targets(&cur_config, 1);
configure_targets(&cur_config);

struct pool_item *pool=config->pool;
pool_clear(&pool);
Expand All @@ -211,9 +211,10 @@ int ret;
return ret;
}

void free_config(void){
struct pool_item *pool;
void
free_config(void)
{
struct pool_item *pool = config->pool;

pool=config->pool;
pool_clear(&pool);
}
2 changes: 1 addition & 1 deletion src/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void add_target(void);
struct alarm_list *alarm2list(const char *aname,struct alarm_list *list);

int load_config(const char *filename);
void configure_targets(struct config *, int);
void configure_targets(struct config *);
void free_config(void);

#endif

0 comments on commit 034691e

Please sign in to comment.