diff --git a/messaging/impl_msgq.cc b/messaging/impl_msgq.cc index 50ea95c7b..0bb347ba0 100644 --- a/messaging/impl_msgq.cc +++ b/messaging/impl_msgq.cc @@ -12,6 +12,7 @@ volatile sig_atomic_t msgq_do_exit = 0; void sig_handler(int signal) { assert(signal == SIGINT || signal == SIGTERM); msgq_do_exit = 1; + printf("sig received *************\n"); } static bool service_exists(std::string path){ @@ -93,7 +94,9 @@ Message * MSGQSubSocket::receive(bool non_blocking){ MSGQMessage *r = NULL; int rc = msgq_msg_recv(&msg, q); - + static std::atomic dd; + ++dd; + printf("begin recev %d\n", dd.load()); // Hack to implement blocking read with a poller. Don't use this while (!non_blocking && rc == 0 && msgq_do_exit == 0){ msgq_pollitem_t items[1]; @@ -114,6 +117,8 @@ Message * MSGQSubSocket::receive(bool non_blocking){ } } + printf("end recev %d\n", dd.load()); + if (!non_blocking){ std::signal(SIGINT, prev_handler_sigint); diff --git a/messaging/msgq.cc b/messaging/msgq.cc index c3e7265f7..3d6cde5a6 100644 --- a/messaging/msgq.cc +++ b/messaging/msgq.cc @@ -78,8 +78,10 @@ SharedMemory::SharedMemory(const std::string &name, size_t size) :shm_name(name) } SharedMemory::~SharedMemory() { + printf("before ~SharedMemory\n"); munmap(shm_ptr, shm_size); ::close(shm_fd); + printf("end ~SharedMemory\n"); } void SharedMemory::notifyAll() { @@ -89,7 +91,13 @@ void SharedMemory::notifyAll() { } void SharedMemory::waitFor(const struct timespec *abstime) { - + static std::atomic d = 0; + ++d; + printf("before wait for %d\n", d.load()); + pthread_mutex_lock(&(header->mutex)); + pthread_cond_timedwait(&(header->cond), &(header->mutex), abstime); + pthread_mutex_unlock(&(header->mutex)); + printf("end wait for %d\n", d.load()); } msgq_context::msgq_context() : shm("msgq_poll", 0) { @@ -178,7 +186,9 @@ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){ } void msgq_close_queue(msgq_queue_t *q){ + printf("close queue...\n"); delete q->shm; + printf("close queue finished\n"); } void msgq_init_publisher(msgq_queue_t * q) { diff --git a/messaging/msgq.h b/messaging/msgq.h index e676c4035..75f8624bf 100644 --- a/messaging/msgq.h +++ b/messaging/msgq.h @@ -36,6 +36,7 @@ class SharedMemory { struct msgq_context { msgq_context(); + ~msgq_context() {printf("msgq_context closed*************\n");} SharedMemory shm; SharedMemoryHeader *ctx; };