diff options
| author | 2023-05-09 15:19:32 +0000 | |
|---|---|---|
| committer | 2023-05-09 15:19:32 +0000 | |
| commit | d91150997c9a37462913124f8e453894d4d7dae8 (patch) | |
| tree | c2dad6184b57c5f96c876bbfff3c8bcdb703b636 | |
| parent | Moved sem_close() further to the end. (diff) | |
| parent | Fixed the issue of semaphore name conflicts. (diff) | |
| download | penes-snac2-d91150997c9a37462913124f8e453894d4d7dae8.tar.gz penes-snac2-d91150997c9a37462913124f8e453894d4d7dae8.tar.xz penes-snac2-d91150997c9a37462913124f8e453894d4d7dae8.zip | |
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
| -rw-r--r-- | httpd.c | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -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 | } |