version 1.16, 2025/05/12 14:26:15
|
version 1.17, 2025/05/12 18:18:00
|
Line 24
|
Line 24
|
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* |
* |
* $Log$ |
* $Log$ |
|
* Revision 1.17 2025/05/12 18:18:00 snw |
|
* Further work on shared memory |
|
* |
* Revision 1.16 2025/05/12 14:26:15 snw |
* Revision 1.16 2025/05/12 14:26:15 snw |
* Revert bad change in shared memory manager |
* Revert bad change in shared memory manager |
* |
* |
Line 128 short shm_init(const size_t seg_size)
|
Line 131 short shm_init(const size_t seg_size)
|
NULLPTRCHK(shm_config,"shm_init"); |
NULLPTRCHK(shm_config,"shm_init"); |
|
|
/* figure out how many pages we can fit in the segment, accounting for header size */ |
/* figure out how many pages we can fit in the segment, accounting for header size */ |
shm_config->pgct = (seg_size / pg_size) - sizeof (shm_hdr_t); |
shm_config->pgct = (seg_size - sizeof (shm_hdr_t)) / pg_size; |
|
|
/* how big will the alloc map be? */ |
/* how big will the alloc map be? */ |
alloc_map_size = shm_config->pgct * sizeof (shm_page_t); |
alloc_map_size = shm_config->pgct * sizeof (shm_page_t); |
Line 175 short shm_init(const size_t seg_size)
|
Line 178 short shm_init(const size_t seg_size)
|
daemon_chk = kill (shm_config->hdr->first_process, 0); |
daemon_chk = kill (shm_config->hdr->first_process, 0); |
|
|
if (daemon_chk == -1 && errno == ESRCH) { |
if (daemon_chk == -1 && errno == ESRCH) { |
|
|
logprintf (FM_LOG_WARNING, "shm_init: recovering from crashed daemon pid %ld", shm_config->hdr->first_process); |
logprintf (FM_LOG_WARNING, "shm_init: recovering from crashed daemon pid %ld", shm_config->hdr->first_process); |
|
|
first_process = TRUE; |
first_process = TRUE; |
|
|
shm_daemon_init (); |
shm_daemon_init (); |
|
|
} |
} |
else { |
else { |
|
|
|
|
first_process = FALSE; |
first_process = FALSE; |
|
|
semid_shm = semget (shm_sk, 1, 0); |
semid_shm = semget (shm_sk, 1, 0); |
Line 193 short shm_init(const size_t seg_size)
|
Line 190 short shm_init(const size_t seg_size)
|
logprintf (FM_LOG_FATAL, "shm_init: could not attach to shared memory semaphore [%s]", strerror (errno)); |
logprintf (FM_LOG_FATAL, "shm_init: could not attach to shared memory semaphore [%s]", strerror (errno)); |
} |
} |
|
|
|
|
shm_config->buf = SHMALIGN(shm_config->dta + (sizeof (shm_hdr_t) * shm_config->pgct)); |
shm_config->buf = SHMALIGN(shm_config->dta + (sizeof (shm_hdr_t) * shm_config->pgct)); |
|
|
|
|
} |
} |
|
|
} |
} |