reflect send completeness in lws_write return

under load, writing packet sizes to the socket that are normally fine
can do partial writes, eg asking to write 4096 may only take 2800 of
it and return 2800 from the actual send.

Until now lws assumed that if it was safe to send, it could take any
size buffer, that's not the case under load.

This patch changes lws_write to return the amount actually taken...
that and the meaning of it becomes tricky when dealing with
compressed links, the amount taken and the amount sent differ.  Also
there is no way to recover at the moment from a protocol-encoded
frame only being partially accepted... however for http file send
content it can and does recover now.

Small frames don't have to take any care about it but large atomic
sends (> 2K) have been seen to fail under load.

Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/changelog b/changelog
index 97c0f64..f0278dc 100644
--- a/changelog
+++ b/changelog
@@ -23,6 +23,11 @@
 	LWS_CALLBACK_FILTER_NETWORK_CONNECTION also has the socket descriptor
 	delivered by @in now instead of @user.
 
+ - libwebsocket_write() now returns -1 for error, or the amount of data
+ 	actually accepted for send.  Under load, the OS may signal it is
+	ready to send new data on the socket, but have only a restricted
+	amount of memory to buffer the packet compared to usual.
+
 
 User api removal
 ----------------