X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/0c60e90bdf1a75402f9cc86eb300c5619dd895bc..892bd75ffefedb5fdf4de47bbdaa97071e4f0909:/rtems/gw/cangw/gw.c diff --git a/rtems/gw/cangw/gw.c b/rtems/gw/cangw/gw.c index 87dc756..24d4087 100644 --- a/rtems/gw/cangw/gw.c +++ b/rtems/gw/cangw/gw.c @@ -51,7 +51,7 @@ static void fd_closer(void* arg){ * This function implements the main thread loop and enough decision logic so that it knows which device to take messages from and which device to send the messages to. * */ -void* CAN_GW_thread(void* arg){ +static void* CAN_GW_thread(void* arg){ int fd_in, fd_out; int res; unsigned long int *total, *succ, *err; @@ -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);