summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar poesty2023-05-09 23:11:57 +0800
committerGravatar poesty2023-05-09 23:11:57 +0800
commit3bd83457d9d9e9bb7eda31e8bdd669eeabd121c0 (patch)
treec2dad6184b57c5f96c876bbfff3c8bcdb703b636 /httpd.c
parentMoved sem_close() further to the end. (diff)
downloadpenes-snac2-3bd83457d9d9e9bb7eda31e8bdd669eeabd121c0.tar.gz
penes-snac2-3bd83457d9d9e9bb7eda31e8bdd669eeabd121c0.tar.xz
penes-snac2-3bd83457d9d9e9bb7eda31e8bdd669eeabd121c0.zip
Fixed the issue of semaphore name conflicts.
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/httpd.c b/httpd.c
index e8223f5..d946eae 100644
--- a/httpd.c
+++ b/httpd.c
@@ -480,6 +480,7 @@ void httpd(void)
480 pthread_t threads[MAX_THREADS] = {0}; 480 pthread_t threads[MAX_THREADS] = {0};
481 int n_threads = 0; 481 int n_threads = 0;
482 int n; 482 int n;
483 char sem_name[24];
483 484
484 address = xs_dict_get(srv_config, "address"); 485 address = xs_dict_get(srv_config, "address");
485 port = xs_number_get(xs_dict_get(srv_config, "port")); 486 port = xs_number_get(xs_dict_get(srv_config, "port"));
@@ -505,7 +506,8 @@ void httpd(void)
505 506
506 /* initialize the job control engine */ 507 /* initialize the job control engine */
507 pthread_mutex_init(&job_mutex, NULL); 508 pthread_mutex_init(&job_mutex, NULL);
508 job_sem = sem_open("/job", O_CREAT, 0644, 0); 509 sprintf(sem_name, "/job_%d", getpid());
510 job_sem = sem_open(sem_name, O_CREAT, 0644, 0);
509 job_fifo = xs_list_new(); 511 job_fifo = xs_list_new();
510 512
511 /* initialize sleep control */ 513 /* initialize sleep control */
@@ -565,6 +567,7 @@ void httpd(void)
565 pthread_mutex_unlock(&job_mutex); 567 pthread_mutex_unlock(&job_mutex);
566 568
567 sem_close(job_sem); 569 sem_close(job_sem);
570 sem_unlink(sem_name);
568 571
569 srv_log(xs_fmt("httpd stop %s:%d", address, port)); 572 srv_log(xs_fmt("httpd stop %s:%d", address, port));
570} 573}