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
@@ -57,8 +57,7 @@ struct json_pair {
57 struct json_value *v; 57 struct json_value *v;
58}; 58};
59 59
60struct json_format 60struct json_format {
61{
62 size_t indent; 61 size_t indent;
63 int precision; 62 int precision;
64 void (*write) (void *, char const *, size_t); 63 void (*write) (void *, char const *, size_t);
diff --git a/src/ping903.c b/src/ping903.c
index b4ea906..06597bb 100644
--- a/src/ping903.c
+++ b/src/ping903.c
@@ -1312,7 +1312,6 @@ ping903(void)
1312 pthread_t tid; 1312 pthread_t tid;
1313 int fd = -1; 1313 int fd = -1;
1314 struct sockaddr *server_addr; 1314 struct sockaddr *server_addr;
1315 void *p;
1316 struct sigaction act; 1315 struct sigaction act;
1317 1316
1318 p903_init(); 1317 p903_init();
@@ -1358,6 +1357,5 @@ ping903(void)
1358 sigwait(&sigs, &i); 1357 sigwait(&sigs, &i);
1359 info("shutting down on signal %s", strsignal(i)); 1358 info("shutting down on signal %s", strsignal(i));
1360 MHD_stop_daemon(mhd); 1359 MHD_stop_daemon(mhd);
1361 pthread_create(&tid, NULL, p903_saver, NULL); 1360 p903_update_commit();
1362 pthread_join(tid, &p);
1363} 1361}
diff --git a/src/ping903.h b/src/ping903.h
index f0065f3..06cf629 100644
--- a/src/ping903.h
+++ b/src/ping903.h
@@ -176,8 +176,8 @@ int get_host_matches(struct json_value *);
176int file_read_ip_list(FILE *fp, char const *fname); 176int file_read_ip_list(FILE *fp, char const *fname);
177 177
178void p903_init(void); 178void p903_init(void);
179void p903_update_commit(void);
179void *p903_sender(void *p); 180void *p903_sender(void *p);
180void *p903_receiver(void *p); 181void *p903_receiver(void *p);
181void *p903_scheduler(void *p); 182void *p903_scheduler(void *p);
182void *p903_saver(void *p);
183 183
diff --git a/src/pinger.c b/src/pinger.c
index c0276cd..8bb1090 100644
--- a/src/pinger.c
+++ b/src/pinger.c
@@ -865,8 +865,8 @@ hostlist_copy_stat(HOSTLIST *hl)
865 } 865 }
866} 866}
867 867
868static void 868void
869update_commit(void) 869p903_update_commit(void)
870{ 870{
871 HOSTPING *hp; 871 HOSTPING *hp;
872 int upd; 872 int upd;
@@ -1478,7 +1478,7 @@ p903_scheduler(void *p)
1478 hostping_reset(hp); 1478 hostping_reset(hp);
1479 } 1479 }
1480 /* Commit updates */ 1480 /* Commit updates */
1481 update_commit(); 1481 p903_update_commit();
1482 1482
1483 send_p = 1; 1483 send_p = 1;
1484 pthread_cond_broadcast(&sendq_cond); 1484 pthread_cond_broadcast(&sendq_cond);
@@ -1492,10 +1492,3 @@ p903_scheduler(void *p)
1492 } 1492 }
1493} 1493}
1494 1494
1495void *
1496p903_saver(void *p)
1497{
1498 update_commit();
1499 return NULL;
1500}
1501

Return to:

Send suggestions and report system problems to the System administrator.