diff options
| -rw-r--r-- | src/device.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c index 9f45ea9..ec0c9f2 100644 --- a/src/device.c +++ b/src/device.c | |||
| @@ -300,6 +300,7 @@ static int send_tcp(struct mux_connection *conn, uint8_t flags, const unsigned c | |||
| 300 | static void connection_teardown(struct mux_connection *conn) | 300 | static void connection_teardown(struct mux_connection *conn) |
| 301 | { | 301 | { |
| 302 | int res; | 302 | int res; |
| 303 | int size; | ||
| 303 | if(conn->state == CONN_DEAD) | 304 | if(conn->state == CONN_DEAD) |
| 304 | return; | 305 | return; |
| 305 | usbmuxd_log(LL_DEBUG, "connection_teardown dev %d sport %d dport %d", conn->dev->id, conn->sport, conn->dport); | 306 | usbmuxd_log(LL_DEBUG, "connection_teardown dev %d sport %d dport %d", conn->dev->id, conn->sport, conn->dport); |
| @@ -313,6 +314,21 @@ static void connection_teardown(struct mux_connection *conn) | |||
| 313 | client_notify_connect(conn->client, RESULT_CONNREFUSED); | 314 | client_notify_connect(conn->client, RESULT_CONNREFUSED); |
| 314 | } else { | 315 | } else { |
| 315 | conn->state = CONN_DEAD; | 316 | conn->state = CONN_DEAD; |
| 317 | if((conn->events & POLLOUT) && conn->ib_size > 0){ | ||
| 318 | while(1){ | ||
| 319 | size = client_write(conn->client, conn->ib_buf, conn->ib_size); | ||
| 320 | if(size <= 0) { | ||
| 321 | break; | ||
| 322 | } | ||
| 323 | if(size == (int)conn->ib_size) { | ||
| 324 | conn->ib_size = 0; | ||
| 325 | break; | ||
| 326 | } else { | ||
| 327 | conn->ib_size -= size; | ||
| 328 | memmove(conn->ib_buf, conn->ib_buf + size, conn->ib_size); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | } | ||
| 316 | client_close(conn->client); | 332 | client_close(conn->client); |
| 317 | } | 333 | } |
| 318 | } | 334 | } |
