diff options
| author | 2020-01-17 05:11:37 +0100 | |
|---|---|---|
| committer | 2020-01-17 05:11:37 +0100 | |
| commit | 7c7a897e1e2e63c2aa9416844bd96b2910b81479 (patch) | |
| tree | b0d529129c7ebab2ec37ce9474f9573666e868f9 | |
| parent | ec5ff91cfabd30637f8af8f5c79baf4d7818ce57 (diff) | |
| download | usbmuxd-7c7a897e1e2e63c2aa9416844bd96b2910b81479.tar.gz usbmuxd-7c7a897e1e2e63c2aa9416844bd96b2910b81479.tar.bz2 | |
device: Fix potential deadlock (#130)
| -rw-r--r-- | src/device.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c index 87a36cc..5e32ce2 100644 --- a/src/device.c +++ b/src/device.c | |||
| @@ -147,7 +147,6 @@ static struct mux_device* get_mux_device_for_id(int device_id) | |||
| 147 | static struct mux_connection* get_mux_connection(int device_id, struct mux_client *client) | 147 | static struct mux_connection* get_mux_connection(int device_id, struct mux_client *client) |
| 148 | { | 148 | { |
| 149 | struct mux_connection *conn = NULL; | 149 | struct mux_connection *conn = NULL; |
| 150 | pthread_mutex_lock(&device_list_mutex); | ||
| 151 | FOREACH(struct mux_device *dev, &device_list) { | 150 | FOREACH(struct mux_device *dev, &device_list) { |
| 152 | if(dev->id == device_id) { | 151 | if(dev->id == device_id) { |
| 153 | FOREACH(struct mux_connection *lconn, &dev->connections) { | 152 | FOREACH(struct mux_connection *lconn, &dev->connections) { |
| @@ -159,7 +158,6 @@ static struct mux_connection* get_mux_connection(int device_id, struct mux_clien | |||
| 159 | break; | 158 | break; |
| 160 | } | 159 | } |
| 161 | } ENDFOREACH | 160 | } ENDFOREACH |
| 162 | pthread_mutex_unlock(&device_list_mutex); | ||
| 163 | 161 | ||
| 164 | return conn; | 162 | return conn; |
| 165 | } | 163 | } |
| @@ -466,8 +464,9 @@ static int send_tcp_ack(struct mux_connection *conn) | |||
| 466 | */ | 464 | */ |
| 467 | void device_client_process(int device_id, struct mux_client *client, short events) | 465 | void device_client_process(int device_id, struct mux_client *client, short events) |
| 468 | { | 466 | { |
| 467 | pthread_mutex_lock(&device_list_mutex); | ||
| 469 | struct mux_connection *conn = get_mux_connection(device_id, client); | 468 | struct mux_connection *conn = get_mux_connection(device_id, client); |
| 470 | 469 | pthread_mutex_unlock(&device_list_mutex); | |
| 471 | if(!conn) { | 470 | if(!conn) { |
| 472 | usbmuxd_log(LL_WARNING, "Could not find connection for device %d client %p", device_id, client); | 471 | usbmuxd_log(LL_WARNING, "Could not find connection for device %d client %p", device_id, client); |
| 473 | return; | 472 | return; |
