Skip to content

Commit

Permalink
Release messaging sockets and context on shutdown (commaai#1391)
Browse files Browse the repository at this point in the history
* release resources when thread is done

* add white space

* add white space

Co-authored-by: deanlee <deanlee3@gmail.com>
  • Loading branch information
pd0wm and deanlee authored Apr 17, 2020
1 parent 3e2e241 commit 02e4745
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
11 changes: 11 additions & 0 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ void *can_send_thread(void *crap) {
while (!do_exit) {
can_send(subscriber);
}

delete subscriber;
delete context;
return NULL;
}

Expand Down Expand Up @@ -662,6 +665,9 @@ void *can_recv_thread(void *crap) {

next_frame_time += dt;
}

delete publisher;
delete c;
return NULL;
}

Expand All @@ -677,6 +683,9 @@ void *can_health_thread(void *crap) {
can_health(publisher);
usleep(500*1000);
}

delete publisher;
delete c;
return NULL;
}

Expand Down Expand Up @@ -911,6 +920,8 @@ void *pigeon_thread(void *crap) {
cnt++;
}

delete publisher;
delete context;
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/clocksd/clocksd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ int main() {

close(timerfd);
delete clock_publisher;

delete context;
return 0;
}
3 changes: 2 additions & 1 deletion selfdrive/loggerd/loggerd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ int main(int argc, char** argv) {
for (auto s : socks){
delete s;
}


delete poller;
delete s.ctx;
return 0;
}
2 changes: 1 addition & 1 deletion selfdrive/modeld/dmonitoringmodeld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(int argc, char **argv) {
visionstream_destroy(&stream);

delete dmonitoring_sock;
delete dmonstate_sock;
delete msg_context;
dmonitoring_free(&dmonitoringmodel);

return 0;
Expand Down
10 changes: 8 additions & 2 deletions selfdrive/modeld/modeld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ void* live_thread(void *arg) {
}

}


delete live_calibration_sock;
delete poller;
delete c;

return NULL;
}
Expand Down Expand Up @@ -236,7 +239,10 @@ int main(int argc, char **argv) {
visionstream_destroy(&stream);

delete model_sock;

delete posenet_sock;
delete pathplan_sock;
delete msg_context;

model_free(&model);

LOG("joining live_thread");
Expand Down

0 comments on commit 02e4745

Please sign in to comment.