summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-19 08:08:38 +0200
committerGravatar Nikias Bassen2013-09-19 08:08:38 +0200
commit17a5fa85e2978b385448e1a16822cb31ba64e284 (patch)
tree460f759a5a1fbaebc4bec4c073ff167112c721a6
parentf631e8e055dfcdae440631902ed8a38eb5109cb8 (diff)
downloadusbmuxd-17a5fa85e2978b385448e1a16822cb31ba64e284.tar.gz
usbmuxd-17a5fa85e2978b385448e1a16822cb31ba64e284.tar.bz2
make sure usbmuxd -x does not terminate when unpaired devices are still present
-rw-r--r--src/client.c4
-rw-r--r--src/device.c8
-rw-r--r--src/device.h4
-rw-r--r--src/main.c2
4 files changed, 9 insertions, 9 deletions
diff --git a/src/client.c b/src/client.c
index b2e3644..8f7d945 100644
--- a/src/client.c
+++ b/src/client.c
@@ -311,11 +311,11 @@ static int start_listen(struct mux_client *client)
int count, i;
client->state = CLIENT_LISTEN;
- count = device_get_count();
+ count = device_get_count(0);
if(!count)
return 0;
devs = malloc(sizeof(struct device_info) * count);
- count = device_get_list(devs);
+ count = device_get_list(0, devs);
// going to need a larger buffer for many devices
uint32_t needed_buffer = count * (sizeof(struct usbmuxd_device_record) + sizeof(struct usbmuxd_header)) + REPLY_BUF_SIZE;
diff --git a/src/device.c b/src/device.c
index 27e25d5..99e0153 100644
--- a/src/device.c
+++ b/src/device.c
@@ -693,21 +693,21 @@ void device_set_visible(int device_id)
} ENDFOREACH
}
-int device_get_count(void)
+int device_get_count(int include_hidden)
{
int count = 0;
FOREACH(struct mux_device *dev, &device_list) {
- if((dev->state == MUXDEV_ACTIVE) && dev->visible)
+ if((dev->state == MUXDEV_ACTIVE) && (include_hidden || dev->visible))
count++;
} ENDFOREACH
return count;
}
-int device_get_list(struct device_info *p)
+int device_get_list(int include_hidden, struct device_info *p)
{
int count = 0;
FOREACH(struct mux_device *dev, &device_list) {
- if((dev->state == MUXDEV_ACTIVE) && dev->visible) {
+ if((dev->state == MUXDEV_ACTIVE) && (include_hidden || dev->visible)) {
p->id = dev->id;
p->serial = usb_get_serial(dev->usbdev);
p->location = usb_get_location(dev->usbdev);
diff --git a/src/device.h b/src/device.h
index 4b1a581..d7c82ca 100644
--- a/src/device.h
+++ b/src/device.h
@@ -42,8 +42,8 @@ void device_abort_connect(int device_id, struct mux_client *client);
void device_set_visible(int device_id);
-int device_get_count(void);
-int device_get_list(struct device_info *p);
+int device_get_count(int include_hidden);
+int device_get_list(int include_hidden, struct device_info *p);
int device_get_timeout(void);
void device_check_timeouts(void);
diff --git a/src/main.c b/src/main.c
index 1804c30..bb2eb2c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -108,7 +108,7 @@ static void handle_signal(int sig)
if(opt_udev) {
if (sig == SIGUSR1) {
usbmuxd_log(LL_INFO, "Caught SIGUSR1, checking if we can terminate (no more devices attached)...");
- if (device_get_count() > 0) {
+ if (device_get_count(1) > 0) {
// we can't quit, there are still devices attached.
usbmuxd_log(LL_NOTICE, "Refusing to terminate, there are still devices attached. Kill me with signal 15 (TERM) to force quit.");
} else {