summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/device.c')
-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
int res;
int size;
- if(events & POLLOUT) {
+ if((events & POLLOUT) && conn->ib_size > 0) {
// Client is ready to receive data, send what we have
- // in the client's connection buffer
+ // in the client's connection buffer (if there is any)
size = client_write(conn->client, conn->ib_buf, conn->ib_size);
if(size <= 0) {
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
memmove(conn->ib_buf, conn->ib_buf + size, conn->ib_size);
}
}
- if(events & POLLIN) {
+ if((events & POLLIN) && conn->sendable > 0) {
// There is inbound trafic on the client socket,
// convert it to tcp and send to the device
+ // (if the device's input buffer is not full)
size = client_read(conn->client, conn->ob_buf, conn->sendable);
if(size <= 0) {
if (size < 0) {