From b3c271b232e8f73e50efb422b844167550267024 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 21 Aug 2013 16:31:49 +0200 Subject: [PATCH 1/1] 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.) --- rtems/gw/cangw/gw.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.39.2