Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Jan 16, 2024
1 parent bb72bd4 commit 18aca47
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion messaging/impl_msgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int MSGQPubSocket::connect(Context *context, std::string endpoint, bool check_en
}

q = new msgq_queue_t;
int r = msgq_new_queue(q, endpoint.c_str(), DEFAULT_SEGMENT_SIZE);
int r = msgq_new_queue(q, endpoint.c_str(), DEFAULT_SEGMENT_SIZE, true);
if (r != 0){
return r;
}
Expand Down
7 changes: 2 additions & 5 deletions messaging/msgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#include "cereal/messaging/msgq.h"


const bool preallocate = std::getenv("MSGQ_PREALLOCATE") != nullptr;


void sigusr2_handler(int signal) {
assert(signal == SIGUSR2);
}
Expand Down Expand Up @@ -87,7 +84,7 @@ void msgq_wait_for_subscriber(msgq_queue_t *q){
return;
}

int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){
int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size, bool preallocate) {
assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes
std::signal(SIGUSR2, sigusr2_handler);

Expand All @@ -110,7 +107,7 @@ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){
return -1;
}

if (preallocate) {
if (preallocate && (std::getenv("MSGQ_PREALLOCATE") != nullptr)) {
rc = fallocate(fd, 0, 0, size + sizeof(msgq_header_t));
if (rc < 0){
close(fd);
Expand Down
2 changes: 1 addition & 1 deletion messaging/msgq.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int msgq_msg_init_size(msgq_msg_t *msg, size_t size);
int msgq_msg_init_data(msgq_msg_t *msg, char * data, size_t size);
int msgq_msg_close(msgq_msg_t *msg);

int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size);
int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size, bool preallocate = false);
void msgq_close_queue(msgq_queue_t *q);
void msgq_init_publisher(msgq_queue_t * q);
void msgq_init_subscriber(msgq_queue_t * q);
Expand Down

0 comments on commit 18aca47

Please sign in to comment.