Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make client terminate gracefully #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JonnyKong
Copy link

@JonnyKong JonnyKong commented Apr 19, 2021

Currently, when the client is terminated on SIGINT, Tracking::~Tracking() shows unsafe behavior:

edgeslam/src/Tracking.cc

Lines 2323 to 2330 in d548979

Tracking::~Tracking(){
keyframe_socket->~TcpSocket();
frame_socket->~TcpSocket();
map_socket->~TcpSocket();
// This is just a dummy enqueue to unblock the wait_dequeue function in tcp_send()
keyframe_queue.enqueue("exit");
frame_queue.enqueue("exit");
}

The sockets are destroyed, then "exit" messages are sent through the queue to signal keyframe_thread and frame_thread to terminate.

After the two threads are un-blocked in tcp_send(), they will then call TcpSocket::checkAlive() before terminating. This is unsafe since the sockets might have already been destroyed (it causes a segfault on my machine):

if(!socketObject->checkAlive())

This pull request fixes this issue.

@dasda-asd
Copy link

Can the code run monocular mode, please?

@dasda-asd
Copy link

@JonnyKong

@dasda-asd
Copy link

@dkkarthik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants