diff options
| author | 2023-05-09 17:22:31 +0200 | |
|---|---|---|
| committer | 2023-05-09 17:22:31 +0200 | |
| commit | a15ec49a1d4c47d91c8455ad486b5e62f0cdfd11 (patch) | |
| tree | bb768cab5cffb235e96d747df3d163149bc200c6 | |
| parent | Backport from xs. (diff) | |
| parent | Merge pull request 'Fixed the issue of semaphore name conflicts.' (#33) from ... (diff) | |
| download | snac2-a15ec49a1d4c47d91c8455ad486b5e62f0cdfd11.tar.gz snac2-a15ec49a1d4c47d91c8455ad486b5e62f0cdfd11.tar.xz snac2-a15ec49a1d4c47d91c8455ad486b5e62f0cdfd11.zip | |
Fixed conflict.
| -rw-r--r-- | httpd.c | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -482,6 +482,7 @@ void httpd(void) | |||
| 482 | int n_threads = 0; | 482 | int n_threads = 0; |
| 483 | int n; | 483 | int n; |
| 484 | time_t start_time = time(NULL); | 484 | time_t start_time = time(NULL); |
| 485 | char sem_name[24]; | ||
| 485 | 486 | ||
| 486 | address = xs_dict_get(srv_config, "address"); | 487 | address = xs_dict_get(srv_config, "address"); |
| 487 | port = xs_number_get(xs_dict_get(srv_config, "port")); | 488 | port = xs_number_get(xs_dict_get(srv_config, "port")); |
| @@ -507,7 +508,8 @@ void httpd(void) | |||
| 507 | 508 | ||
| 508 | /* initialize the job control engine */ | 509 | /* initialize the job control engine */ |
| 509 | pthread_mutex_init(&job_mutex, NULL); | 510 | pthread_mutex_init(&job_mutex, NULL); |
| 510 | job_sem = sem_open("/job", O_CREAT, 0644, 0); | 511 | sprintf(sem_name, "/job_%d", getpid()); |
| 512 | job_sem = sem_open(sem_name, O_CREAT, 0644, 0); | ||
| 511 | job_fifo = xs_list_new(); | 513 | job_fifo = xs_list_new(); |
| 512 | 514 | ||
| 513 | /* initialize sleep control */ | 515 | /* initialize sleep control */ |
| @@ -567,6 +569,7 @@ void httpd(void) | |||
| 567 | pthread_mutex_unlock(&job_mutex); | 569 | pthread_mutex_unlock(&job_mutex); |
| 568 | 570 | ||
| 569 | sem_close(job_sem); | 571 | sem_close(job_sem); |
| 572 | sem_unlink(sem_name); | ||
| 570 | 573 | ||
| 571 | xs *uptime = xs_str_time_diff(time(NULL) - start_time); | 574 | xs *uptime = xs_str_time_diff(time(NULL) - start_time); |
| 572 | 575 | ||