summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/device.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c
index e36509e..1c8ec8c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -424,9 +424,9 @@ void device_client_process(int device_id, struct mux_client *client, short event
424 424
425 int res; 425 int res;
426 int size; 426 int size;
427 if(events & POLLOUT) { 427 if((events & POLLOUT) && conn->ib_size > 0) {
428 // Client is ready to receive data, send what we have 428 // Client is ready to receive data, send what we have
429 // in the client's connection buffer 429 // in the client's connection buffer (if there is any)
430 size = client_write(conn->client, conn->ib_buf, conn->ib_size); 430 size = client_write(conn->client, conn->ib_buf, conn->ib_size);
431 if(size <= 0) { 431 if(size <= 0) {
432 usbmuxd_log(LL_DEBUG, "error writing to client (%d)", size); 432 usbmuxd_log(LL_DEBUG, "error writing to client (%d)", size);
@@ -441,9 +441,10 @@ void device_client_process(int device_id, struct mux_client *client, short event
441 memmove(conn->ib_buf, conn->ib_buf + size, conn->ib_size); 441 memmove(conn->ib_buf, conn->ib_buf + size, conn->ib_size);
442 } 442 }
443 } 443 }
444 if(events & POLLIN) { 444 if((events & POLLIN) && conn->sendable > 0) {
445 // There is inbound trafic on the client socket, 445 // There is inbound trafic on the client socket,
446 // convert it to tcp and send to the device 446 // convert it to tcp and send to the device
447 // (if the device's input buffer is not full)
447 size = client_read(conn->client, conn->ob_buf, conn->sendable); 448 size = client_read(conn->client, conn->ob_buf, conn->sendable);
448 if(size <= 0) { 449 if(size <= 0) {
449 if (size < 0) { 450 if (size < 0) {