]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
Commit fixing that threads not cleaning up after themselves.
authorMartin Hořeňovský <Martin.Horenovsky@gmail.com>
Wed, 21 Aug 2013 14:31:49 +0000 (16:31 +0200)
committerMartin Hořeňovský <Martin.Horenovsky@gmail.com>
Wed, 21 Aug 2013 14:31:49 +0000 (16:31 +0200)
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

index 87dc7560ea184d96af590cc0c69f19a922d4f5cb..2e56fb495352c44193ac29eeb97f9062a8483bf3 100644 (file)
@@ -133,8 +133,9 @@ static int start_tasks(){
         return 1;\r
     }\r
     \r
-//    pthread_detach(CAN_B_to_A_thread);\r
-//    pthread_detach(CAN_A_to_B_thread);\r
+    /* detach is needed so that the threads call clean up handlers automatically. */\r
+    pthread_detach(CAN_B_to_A_thread);\r
+    pthread_detach(CAN_A_to_B_thread);\r
 \r
     /* Threads are started and running at this point. */\r
     return 0;\r
@@ -170,13 +171,13 @@ static int end_tasks(){
     printf("Attempting to stop thread 1\n");\r
     res = pthread_cancel(CAN_A_to_B_thread);\r
     if (res != 0){\r
-        printf("Failed./n");\r
+        printf("Failed.\n");\r
         /* Not sure what to do with error here, will have to figure out later. */\r
     }\r
     printf("Attempting to stop thread 2\n");\r
     res = pthread_cancel(CAN_B_to_A_thread);\r
     if (res != 0){\r
-        printf("Failed./n");\r
+        printf("Failed.\n");\r
         /* Not sure what to do with error here, will have to figure out later. */\r
     }\r
     sleep(1);\r