only flush write queue just before waiting for more data,
rather than when fetching more data from the buffer.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
static bool readLong(uint32_t *out_data)
{
- if (out_pos > 0)
- {
- if (!flush_writes())
- {
- return false;
- }
- }
-
uint32_t data = 0;
int i;
for (i = 0; i < 4; i++)
uint8_t c;
if (in_pos == in_write)
{
+ /* If we have some data that we can send, send them before
+ * we wait for more data
+ */
+ if (out_pos > 0)
+ {
+ if (!flush_writes())
+ {
+ return false;
+ }
+ }
+
/* read more */
int t;
t = read(tcp_ip, in_buffer, sizeof(in_buffer));