handle EAGAIN during send

This patch deploys the truncated send work to buffer output in case
either send() or the SSL send return a temporary "unable to send"
condition even though they signalled as writeable.

I added a by-default #if 0 test jig which enforces only half of what
you want to send is sendable, this is working when enabled.

One subtle change is that the pipe reports choked if there is any
pending remaining truncated send.  Otherwise it should be transparent.

Hopefully...

Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 31e1424..7342e9b 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -376,10 +376,10 @@
 			free(wsi->u.ws.rxflow_buffer);
 			wsi->u.ws.rxflow_buffer = NULL;
 		}
-		if (wsi->u.ws.truncated_send_malloc) {
+		if (wsi->truncated_send_malloc) {
 			/* not going to be completed... nuke it */
-			free(wsi->u.ws.truncated_send_malloc);
-			wsi->u.ws.truncated_send_malloc = NULL;
+			free(wsi->truncated_send_malloc);
+			wsi->truncated_send_malloc = NULL;
 		}
 	}
 
@@ -642,6 +642,10 @@
 {
 	struct pollfd fds;
 
+	/* treat the fact we got a truncated send pending as if we're choked */
+	if (wsi->truncated_send_malloc)
+		return 1;
+
 	fds.fd = wsi->sock;
 	fds.events = POLLOUT;
 	fds.revents = 0;
@@ -671,10 +675,10 @@
 
 	/* pending truncated sends have uber priority */
 
-	if (wsi->u.ws.truncated_send_malloc) {
-		lws_issue_raw(wsi, wsi->u.ws.truncated_send_malloc +
-				wsi->u.ws.truncated_send_offset,
-						wsi->u.ws.truncated_send_len);
+	if (wsi->truncated_send_malloc) {
+		lws_issue_raw(wsi, wsi->truncated_send_malloc +
+				wsi->truncated_send_offset,
+						wsi->truncated_send_len);
 		/* leave POLLOUT active either way */
 		return 0;
 	}