msgq: pre-allocate full queue size

This commit is contained in:
Adeeb Shihadeh 2024-01-11 19:52:24 -08:00
parent d81d86e7cd
commit 07bfca1c97
1 changed files with 7 additions and 0 deletions

View File

@ -105,6 +105,13 @@ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){
close(fd);
return -1;
}
rc = fallocate(fd, 0, 0, size + sizeof(msgq_header_t));
if (rc < 0){
close(fd);
return -1;
}
char * mem = (char*)mmap(NULL, size + sizeof(msgq_header_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);