aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2020-03-10 16:31:15 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2020-03-10 16:31:15 +0200
commit99434a37b31ac9a6f5cf9ba5b773da2c4775124b (patch)
tree621fc688cde1a483dd2dfad5d6623fd1ca08b8c3
parentdd82507e6ca3f420eee5d6160515b3b8026731bc (diff)
downloadping903-99434a37b31ac9a6f5cf9ba5b773da2c4775124b.tar.gz
ping903-99434a37b31ac9a6f5cf9ba5b773da2c4775124b.tar.bz2
Remove superfluous saver thread.
* src/ping903.c (ping903): Call p903_update_commit instead of starting a new thread. * src/ping903.h (p903_update_commit): New proto. * src/pinger.c (update_commit): Rename to p903_update_commit; remove static.
-rw-r--r--src/json.h3
-rw-r--r--src/ping903.c4
-rw-r--r--src/ping903.h2
-rw-r--r--src/pinger.c13
4 files changed, 6 insertions, 16 deletions
diff --git a/src/json.h b/src/json.h
index b5fa9d3..f31496c 100644
--- a/src/json.h
+++ b/src/json.h
@@ -54,14 +54,13 @@ struct json_value {
struct json_pair {
struct json_pair *next;
char *k;
struct json_value *v;
};
-struct json_format
-{
+struct json_format {
size_t indent;
int precision;
void (*write) (void *, char const *, size_t);
void *data;
};
diff --git a/src/ping903.c b/src/ping903.c
index b4ea906..06597bb 100644
--- a/src/ping903.c
+++ b/src/ping903.c
@@ -1309,13 +1309,12 @@ ping903(void)
struct MHD_Daemon *mhd;
sigset_t sigs;
int i;
pthread_t tid;
int fd = -1;
struct sockaddr *server_addr;
- void *p;
struct sigaction act;
p903_init();
fd = open_listener(httpd_addr, &server_addr);
@@ -1355,9 +1354,8 @@ ping903(void)
pthread_create(&tid, NULL, p903_scheduler, NULL);
/* Wait for signal to arrive */
sigwait(&sigs, &i);
info("shutting down on signal %s", strsignal(i));
MHD_stop_daemon(mhd);
- pthread_create(&tid, NULL, p903_saver, NULL);
- pthread_join(tid, &p);
+ p903_update_commit();
}
diff --git a/src/ping903.h b/src/ping903.h
index f0065f3..06cf629 100644
--- a/src/ping903.h
+++ b/src/ping903.h
@@ -173,11 +173,11 @@ int get_all_hosts(struct json_value **);
int get_all_host_stat(struct json_value **);
int get_host_matches(struct json_value *);
int file_read_ip_list(FILE *fp, char const *fname);
void p903_init(void);
+void p903_update_commit(void);
void *p903_sender(void *p);
void *p903_receiver(void *p);
void *p903_scheduler(void *p);
-void *p903_saver(void *p);
diff --git a/src/pinger.c b/src/pinger.c
index c0276cd..8bb1090 100644
--- a/src/pinger.c
+++ b/src/pinger.c
@@ -862,14 +862,14 @@ hostlist_copy_stat(HOSTLIST *hl)
HOSTPING *cur = hostping_find_local(hp->name);
if (cur)
hp->stat_last = cur->stat_last;
}
}
-static void
-update_commit(void)
+void
+p903_update_commit(void)
{
HOSTPING *hp;
int upd;
pthread_mutex_lock(&update_mutex);
pthread_rwlock_wrlock(&hostlist_rwlock);
@@ -1475,13 +1475,13 @@ p903_scheduler(void *p)
pthread_mutex_lock(&sendq_mutex);
/* Reset all statistics */
FOR_EACH_HOSTPING(hp) {
hostping_reset(hp);
}
/* Commit updates */
- update_commit();
+ p903_update_commit();
send_p = 1;
pthread_cond_broadcast(&sendq_cond);
pthread_mutex_unlock(&sendq_mutex);
sleep(probe_interval);
@@ -1489,13 +1489,6 @@ p903_scheduler(void *p)
info("total sent=%u, received=%u",
xmit_total, recv_total);
xmit_total = recv_total = 0;
}
}
-void *
-p903_saver(void *p)
-{
- update_commit();
- return NULL;
-}
-

Return to:

Send suggestions and report system problems to the System administrator.