diff options
author | grunfink <grunfink@noreply.codeberg.org> | 2023-05-09 15:19:32 +0000 |
---|---|---|
committer | grunfink <grunfink@noreply.codeberg.org> | 2023-05-09 15:19:32 +0000 |
commit | d91150997c9a37462913124f8e453894d4d7dae8 (patch) | |
tree | c2dad6184b57c5f96c876bbfff3c8bcdb703b636 /httpd.c | |
parent | 6bad2355ef8d7a4013a73888416c8a90e6b6dab0 (diff) | |
parent | 3bd83457d9d9e9bb7eda31e8bdd669eeabd121c0 (diff) |
Merge pull request 'Fixed the issue of semaphore name conflicts.' (#33) from poesty/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/33
Diffstat (limited to 'httpd.c')
-rw-r--r-- | httpd.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -480,6 +480,7 @@ void httpd(void) pthread_t threads[MAX_THREADS] = {0}; int n_threads = 0; int n; + char sem_name[24]; address = xs_dict_get(srv_config, "address"); port = xs_number_get(xs_dict_get(srv_config, "port")); @@ -505,7 +506,8 @@ void httpd(void) /* initialize the job control engine */ pthread_mutex_init(&job_mutex, NULL); - job_sem = sem_open("/job", O_CREAT, 0644, 0); + sprintf(sem_name, "/job_%d", getpid()); + job_sem = sem_open(sem_name, O_CREAT, 0644, 0); job_fifo = xs_list_new(); /* initialize sleep control */ @@ -565,6 +567,7 @@ void httpd(void) pthread_mutex_unlock(&job_mutex); sem_close(job_sem); + sem_unlink(sem_name); srv_log(xs_fmt("httpd stop %s:%d", address, port)); } |