diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index 09d777bb47..3a0579bece 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -280,12 +280,30 @@ public: { slct_main = port; slct_port = port; +#ifdef WIRE_COMPRESS_SUPPORT + slct_zport = NULL; +#endif } // get port to check for readyness // assume port_mutex is locked HandleState checkNext(RemPortPtr& port) { +#ifdef WIRE_COMPRESS_SUPPORT + if (slct_zport) + { + if ((slct_zport->port_flags & PORT_z_data) && + (slct_zport->port_state != rem_port::DISCONNECTED)) + { + port = slct_zport; + slct_zport = NULL; // Will be set again by select_multi() if needed + return SEL_READY; + } + + slct_zport = NULL; + } +#endif + if (slct_port && slct_port->port_state == rem_port::DISCONNECTED) { // restart from main port @@ -309,6 +327,13 @@ public: return ok(port); } + void setZDataPort(RemPortPtr& port) + { +#ifdef WIRE_COMPRESS_SUPPORT + slct_zport = port; +#endif + } + HandleState ok(const rem_port* port) { #ifdef WIRE_COMPRESS_SUPPORT @@ -388,6 +413,9 @@ public: #endif slct_main = NULL; slct_port = NULL; +#ifdef WIRE_COMPRESS_SUPPORT + slct_zport = NULL; +#endif } void select(timeval* timeout) @@ -456,6 +484,9 @@ private: #endif RemPortPtr slct_main; // first port to check for readyness RemPortPtr slct_port; // next port to check for readyness +#ifdef WIRE_COMPRESS_SUPPORT + RemPortPtr slct_zport; // port with some compressed data remaining in the buffer +#endif }; static bool accept_connection(rem_port*, const P_CNCT*); @@ -2085,6 +2116,10 @@ static bool select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize, SSH { *length = 0; } +#ifdef WIRE_COMPRESS_SUPPORT + if (port->port_flags & PORT_z_data) + INET_select->setZDataPort(port); +#endif return (*length) ? true : false; } @@ -2109,6 +2144,10 @@ static bool select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize, SSH } *length = 0; } +#ifdef WIRE_COMPRESS_SUPPORT + if (port->port_flags & PORT_z_data) + INET_select->setZDataPort(port); +#endif return (*length) ? true : false; } if (!select_wait(main_port, &INET_select)) diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp index 978391701f..8e8f50b108 100644 --- a/src/remote/remote.cpp +++ b/src/remote/remote.cpp @@ -1509,6 +1509,10 @@ bool REMOTE_inflate(rem_port* port, PacketReceive* packet_receive, UCHAR* buffer else port->port_flags &= ~PORT_z_data; +#ifdef COMPRESS_DEBUG + fprintf(stderr, "Z-buffer %s\n", port->port_flags & PORT_z_data ? "has data" : "is empty"); +#endif + return true; #else return packet_receive(port, buffer, buffer_length, length);