Mercurial > hg > nnchat
diff libnnchat.c @ 403:7bec02f382fb
Refactor the connection and protocol handling a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 May 2012 05:28:44 +0300 |
parents | 07a46ca075ab |
children |
line wrap: on
line diff
--- a/libnnchat.c Thu May 24 05:03:58 2012 +0300 +++ b/libnnchat.c Thu May 24 05:28:44 2012 +0300 @@ -373,6 +373,16 @@ if (conn == NULL) return -10; + /* Prod the input buffer */ + if (conn->in_ptr > conn->buf && conn->in_ptr - conn->ptr > 0) + { + size_t delta = conn->in_ptr - conn->ptr; + memmove(conn->buf, conn->in_ptr, delta); + conn->ptr = conn->buf; + conn->in_ptr -= delta; + conn->total_bytes -= delta; + } + /* Check for incoming data */ socktv.tv_sec = 0; socktv.tv_usec = NN_DELAY_USEC;