Patchwork Added cleanup for Win32 TAP interface

login
register
mail settings
Submitter Pavel Dovgaluk
Date March 13, 2013, 12:23 p.m.
Message ID <006101ce1fe5$9f9bc200$ded34600$@Dovgaluk@ispras.ru>
Download mbox | patch
Permalink /patch/227260/
State New
Headers show

Comments

Pavel Dovgaluk - March 13, 2013, 12:23 p.m.
Added cleanup for Win32 TAP interface.

Signed-off-by: Pavel Dovgalyuk<pavel.dovgaluk@gmail.com>
---
 net/tap-win32.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Patch

diff --git a/net/tap-win32.c b/net/tap-win32.c
index 91e9e84..1c1176c 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -99,6 +99,7 @@  typedef struct tap_win32_overlapped {
     HANDLE output_queue_semaphore;
     HANDLE free_list_semaphore;
     HANDLE tap_semaphore;
+    HANDLE hThread;
     CRITICAL_SECTION output_queue_cs;
     CRITICAL_SECTION free_list_cs;
     OVERLAPPED read_overlapped;
@@ -625,7 +626,7 @@  static int tap_win32_open(tap_win32_overlapped_t **phandle,
 
     *phandle = &tap_overlapped;
 
-    CreateThread(NULL, 0, tap_win32_thread_entry,
+    tap_overlapped.hThread = CreateThread(NULL, 0, tap_win32_thread_entry,
                  (LPVOID)&tap_overlapped, 0, &idThread);
     return 0;
 }
@@ -643,9 +644,8 @@  static void tap_cleanup(NetClientState *nc)
 
     qemu_del_wait_object(s->handle->tap_semaphore, NULL, NULL);
 
-    /* FIXME: need to kill thread and close file handle:
-       tap_win32_close(s);
-    */
+    TerminateThread(s->handle->hThread, 0);
+    CloseHandle(s->handle->handle);
 }
 
 static ssize_t tap_receive(NetClientState *nc, const uint8_t *buf, size_t size)