From: Martin Hořeňovský Date: Wed, 21 Aug 2013 14:31:49 +0000 (+0200) Subject: Commit fixing that threads not cleaning up after themselves. X-Git-Tag: fix-allnoconfig~157 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/commitdiff_plain/b3c271b232e8f73e50efb422b844167550267024?ds=sidebyside Commit fixing that threads not cleaning up after themselves. As it turns out, I forgot to uncomment lines detaching the GW threads, so that as they are cancelled they can automatically call clean up handlers. This also fixes related bug, where messages sent to the board after the gw was activated and deactivated, are delivered once gw is activated again. (Unless the whole board was reset in the meantime.) --- diff --git a/rtems/gw/cangw/gw.c b/rtems/gw/cangw/gw.c index 87dc756..2e56fb4 100644 --- a/rtems/gw/cangw/gw.c +++ b/rtems/gw/cangw/gw.c @@ -133,8 +133,9 @@ static int start_tasks(){ return 1; } -// pthread_detach(CAN_B_to_A_thread); -// pthread_detach(CAN_A_to_B_thread); + /* detach is needed so that the threads call clean up handlers automatically. */ + pthread_detach(CAN_B_to_A_thread); + pthread_detach(CAN_A_to_B_thread); /* Threads are started and running at this point. */ return 0; @@ -170,13 +171,13 @@ static int end_tasks(){ printf("Attempting to stop thread 1\n"); res = pthread_cancel(CAN_A_to_B_thread); if (res != 0){ - printf("Failed./n"); + printf("Failed.\n"); /* Not sure what to do with error here, will have to figure out later. */ } printf("Attempting to stop thread 2\n"); res = pthread_cancel(CAN_B_to_A_thread); if (res != 0){ - printf("Failed./n"); + printf("Failed.\n"); /* Not sure what to do with error here, will have to figure out later. */ } sleep(1);