From: Andy Green Date: Sun, 6 Mar 2011 10:29:38 +0000 (+0000) Subject: introduce lws_issue_raw X-Git-Tag: 1.2~143 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d44bf7f81ba5c6158896cd8e33391b2a7b1c94e4;p=profile%2Fivi%2Flibwebsockets.git introduce lws_issue_raw Signed-off-by: Andy Green --- diff --git a/lib/parsers.c b/lib/parsers.c index 3b72b58..37a4ae6 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -1054,6 +1054,31 @@ libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi) return 0; } +int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len) +{ + int n; + +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->ssl) { + n = SSL_write(wsi->ssl, buf, len); + if (n < 0) { + fprintf(stderr, + "ERROR writing to socket\n"); + return -1; + } + } else { +#endif + n = send(wsi->sock, buf, len, MSG_NOSIGNAL); + if (n < 0) { + fprintf(stderr, + "ERROR writing to socket\n"); + return -1; + } +#ifdef LWS_OPENSSL_SUPPORT + } +#endif + return 0; +} /** * libwebsocket_write() - Apply protocol then write data to client @@ -1300,23 +1325,9 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, } send_raw: -#ifdef LWS_OPENSSL_SUPPORT - if (wsi->ssl) { - n = SSL_write(wsi->ssl, buf - pre, len + pre + post); - if (n < 0) { - fprintf(stderr, "ERROR writing to socket\n"); - return -1; - } - } else { -#endif - n = send(wsi->sock, buf - pre, len + pre + post, MSG_NOSIGNAL); - if (n < 0) { - fprintf(stderr, "ERROR writing to socket\n"); - return -1; - } -#ifdef LWS_OPENSSL_SUPPORT - } -#endif + + if (lws_issue_raw(wsi, buf - pre, len + pre + post)) + return -1; debug("written %d bytes to client\n", (int)len); diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 94802ae..e560f05 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -332,6 +332,9 @@ extern int libwebsockets_get_random(struct libwebsocket_context *context, void *buf, int len); +extern int +lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len); + #ifndef LWS_OPENSSL_SUPPORT unsigned char *