summaryrefslogtreecommitdiffstats
path: root/libusbmuxd
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-04-05 13:58:18 +0200
committerGravatar Nikias Bassen2012-04-05 13:58:18 +0200
commitcd07d72075739d6b59238d16fde6d02a1b97dbb9 (patch)
treec14160d287a0b01dd6dd4843a0a001849624df04 /libusbmuxd
parentb63c3355bd194d1df83b2f5aa0affab411397dd4 (diff)
downloadusbmuxd-cd07d72075739d6b59238d16fde6d02a1b97dbb9.tar.gz
usbmuxd-cd07d72075739d6b59238d16fde6d02a1b97dbb9.tar.bz2
libusbmuxd: fix usbmuxd_unsubscribe() by using shutdown() instead of SIGINT
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)
602 602
603 collection_free(&devices); 603 collection_free(&devices);
604 604
605 close_socket(listenfd);
606 listenfd = -1;
607
605 return NULL; 608 return NULL;
606} 609}
607 610
@@ -634,17 +637,14 @@ int usbmuxd_unsubscribe()
634{ 637{
635 event_cb = NULL; 638 event_cb = NULL;
636 639
640 shutdown_socket(listenfd, SHUT_RDWR);
641
637#ifdef WIN32 642#ifdef WIN32
638 if (devmon != NULL) { 643 if (devmon != NULL) {
639 close_socket(listenfd);
640 listenfd = -1;
641 WaitForSingleObject(devmon, INFINITE); 644 WaitForSingleObject(devmon, INFINITE);
642 } 645 }
643#else 646#else
644 if (pthread_kill(devmon, 0) == 0) { 647 if (pthread_kill(devmon, 0) == 0) {
645 close_socket(listenfd);
646 listenfd = -1;
647 pthread_kill(devmon, SIGINT);
648 pthread_join(devmon, NULL); 648 pthread_join(devmon, NULL);
649 } 649 }
650#endif 650#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)
321 return sret; 321 return sret;
322} 322}
323 323
324int shutdown_socket(int fd, int how)
325{
326 return shutdown(fd, how);
327}
328
324int close_socket(int fd) { 329int close_socket(int fd) {
325#ifdef WIN32 330#ifdef WIN32
326 return closesocket(fd); 331 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 {
33}; 33};
34typedef enum fd_mode fd_mode; 34typedef enum fd_mode fd_mode;
35 35
36#ifdef WIN32
37#include <winsock2.h>
38#define SHUT_RD SD_READ
39#define SHUT_WR SD_WRITE
40#define SHUT_RDWR SD_BOTH
41#endif
42
36#ifndef WIN32 43#ifndef WIN32
37int create_unix_socket(const char *filename); 44int create_unix_socket(const char *filename);
38int connect_unix_socket(const char *filename); 45int connect_unix_socket(const char *filename);
@@ -43,6 +50,7 @@ int connect_socket(const char *addr, uint16_t port);
43#endif 50#endif
44int check_fd(int fd, fd_mode fdm, unsigned int timeout); 51int check_fd(int fd, fd_mode fdm, unsigned int timeout);
45 52
53int shutdown_socket(int fd, int how);
46int close_socket(int fd); 54int close_socket(int fd);
47 55
48int recv_buf(int fd, void *data, size_t size); 56int recv_buf(int fd, void *data, size_t size);