drivers/win32/win32.c
changeset 629 b9274b595650
parent 600 7767029937aa
child 638 00bc03cb5606
--- a/drivers/win32/win32.c	Fri Nov 12 22:02:32 2010 +0100
+++ b/drivers/win32/win32.c	Fri Nov 12 22:24:06 2010 +0100
@@ -190,16 +190,18 @@
 	}
 
 	tmp = (CANPort*)d->canHandle;
-	d->canHandle = NULL;
 
 	if(tmp)
 	{
+	  // kill receiver task before port is closed and handle set to NULL
+	  WaitReceiveTaskEnd(&tmp->receiveTask);
+
 	  // close CAN port
 	  res = m_canClose(tmp->fd);
-
-	  // kill receiver task
-	  WaitReceiveTaskEnd(&tmp->receiveTask);
-	}
+	}
+
+	d->canHandle = NULL;
+
 	return res;
 }