summaryrefslogtreecommitdiffstats
path: root/libusbmuxd
diff options
context:
space:
mode:
Diffstat (limited to 'libusbmuxd')
-rw-r--r--libusbmuxd/libusbmuxd.c10
-rw-r--r--libusbmuxd/sock_stuff.c5
-rw-r--r--libusbmuxd/sock_stuff.h8
3 files changed, 18 insertions, 5 deletions
diff --git a/libusbmuxd/libusbmuxd.c b/libusbmuxd/libusbmuxd.c
index 172da80..02aa750 100644
--- a/libusbmuxd/libusbmuxd.c
+++ b/libusbmuxd/libusbmuxd.c
@@ -602,6 +602,9 @@ static void *device_monitor(void *data)
collection_free(&devices);
+ close_socket(listenfd);
+ listenfd = -1;
+
return NULL;
}
@@ -634,17 +637,14 @@ int usbmuxd_unsubscribe()
{
event_cb = NULL;
+ shutdown_socket(listenfd, SHUT_RDWR);
+
#ifdef WIN32
if (devmon != NULL) {
- close_socket(listenfd);
- listenfd = -1;
WaitForSingleObject(devmon, INFINITE);
}
#else
if (pthread_kill(devmon, 0) == 0) {
- close_socket(listenfd);
- listenfd = -1;
- pthread_kill(devmon, SIGINT);
pthread_join(devmon, NULL);
}
#endif
diff --git a/libusbmuxd/sock_stuff.c b/libusbmuxd/sock_stuff.c
index edc738e..609c8ad 100644
--- a/libusbmuxd/sock_stuff.c
+++ b/libusbmuxd/sock_stuff.c
@@ -321,6 +321,11 @@ int check_fd(int fd, fd_mode fdm, unsigned int timeout)
return sret;
}
+int shutdown_socket(int fd, int how)
+{
+ return shutdown(fd, how);
+}
+
int close_socket(int fd) {
#ifdef WIN32
return closesocket(fd);
diff --git a/libusbmuxd/sock_stuff.h b/libusbmuxd/sock_stuff.h
index eb9622c..5efcd27 100644
--- a/libusbmuxd/sock_stuff.h
+++ b/libusbmuxd/sock_stuff.h
@@ -33,6 +33,13 @@ enum fd_mode {
};
typedef enum fd_mode fd_mode;
+#ifdef WIN32
+#include <winsock2.h>
+#define SHUT_RD SD_READ
+#define SHUT_WR SD_WRITE
+#define SHUT_RDWR SD_BOTH
+#endif
+
#ifndef WIN32
int create_unix_socket(const char *filename);
int connect_unix_socket(const char *filename);
@@ -43,6 +50,7 @@ int connect_socket(const char *addr, uint16_t port);
#endif
int check_fd(int fd, fd_mode fdm, unsigned int timeout);
+int shutdown_socket(int fd, int how);
int close_socket(int fd);
int recv_buf(int fd, void *data, size_t size);