mirror of
https://github.com/commaai/msgq.git
synced 2026-06-13 00:14:32 +08:00
msgq: pre-allocate full queue size
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user