mirror of https://github.com/commaai/cereal.git
msgq: pre-allocate full queue size
This commit is contained in:
parent
d81d86e7cd
commit
07bfca1c97
|
@ -105,6 +105,13 @@ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
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);
|
char * mem = (char*)mmap(NULL, size + sizeof(msgq_header_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue