From 54c2db319a252c841605535a128d6d473453e75b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sat, 10 Dec 2011 08:14:50 +0000 Subject: [PATCH] we've got NODELAY, may as well add CORK SVN revision: 66082 --- legacy/ecore/ChangeLog | 1 + legacy/ecore/NEWS | 1 + legacy/ecore/src/lib/ecore_con/Ecore_Con.h | 4 ++ legacy/ecore/src/lib/ecore_con/ecore_con.c | 43 +++++++++++++++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog index f58daa75f8..aac665502d 100644 --- a/legacy/ecore/ChangeLog +++ b/legacy/ecore/ChangeLog @@ -394,3 +394,4 @@ 2011-12-10 Mike Blumenkrantz * Fix case where SSL certificates would not be used + * Added ECORE_CON_REMOTE_CORK for applying TCP_CORK to sends diff --git a/legacy/ecore/NEWS b/legacy/ecore/NEWS index 61a13d06de..1da17aff45 100644 --- a/legacy/ecore/NEWS +++ b/legacy/ecore/NEWS @@ -10,6 +10,7 @@ Additions: - ecore_con_socks api - ecore_con_ssl_server_verify_name_set/get - ecore_con_ssl_server_cafile_add() now accepts directories + - ECORE_CON_REMOTE_CORK * ecore_x: - ecore_x_randr_output_backlight_available() diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h index 87a7ddf116..c91ad056a3 100644 --- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h +++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h @@ -639,6 +639,10 @@ typedef enum _Ecore_Con_Type ECORE_CON_REMOTE_BROADCAST = 6, /** Remote connection sending packets immediately */ ECORE_CON_REMOTE_NODELAY = 7, + /** Remote connection sending data in large chunks + * @since 1.2 + */ + ECORE_CON_REMOTE_CORK = 8, /** Use SSL2: UNSUPPORTED. **/ ECORE_CON_USE_SSL2 = (1 << 4), /** Use SSL3 */ diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c index 78c15e9c9b..fd22623b42 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c @@ -331,7 +331,8 @@ ecore_con_server_add(Ecore_Con_Type compl_type, #endif if ((type == ECORE_CON_REMOTE_TCP) || - (type == ECORE_CON_REMOTE_NODELAY)) + (type == ECORE_CON_REMOTE_NODELAY) || + (type == ECORE_CON_REMOTE_CORK)) { /* TCP */ if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen, @@ -431,6 +432,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, if (((type == ECORE_CON_REMOTE_TCP) || (type == ECORE_CON_REMOTE_NODELAY) || + (type == ECORE_CON_REMOTE_CORK) || (type == ECORE_CON_REMOTE_UDP) || (type == ECORE_CON_REMOTE_BROADCAST)) && (port < 0)) @@ -449,7 +451,8 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, #endif if ((type == ECORE_CON_REMOTE_TCP) || - (type == ECORE_CON_REMOTE_NODELAY)) + (type == ECORE_CON_REMOTE_NODELAY) || + (type == ECORE_CON_REMOTE_CORK)) { /* TCP */ if (!ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, @@ -636,6 +639,15 @@ ecore_con_server_send(Ecore_Con_Server *svr, { svr->buf = eina_binbuf_new(); EINA_SAFETY_ON_NULL_RETURN_VAL(svr->buf, 0); +#ifdef TCP_CORK + if ((svr->fd >= 0) && ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK)) + { + int state = 1; + if (setsockopt(svr->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) + /* realistically this isn't anything serious so we can just log and continue */ + ERR("corking failed! %s", strerror(errno)); + } +#endif } eina_binbuf_append_length(svr->buf, data, size); @@ -738,6 +750,15 @@ ecore_con_client_send(Ecore_Con_Client *cl, { cl->buf = eina_binbuf_new(); EINA_SAFETY_ON_NULL_RETURN_VAL(cl->buf, 0); +#ifdef TCP_CORK + if ((cl->fd >= 0) && ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK)) + { + int state = 1; + if (setsockopt(cl->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) + /* realistically this isn't anything serious so we can just log and continue */ + ERR("corking failed! %s", strerror(errno)); + } +#endif } eina_binbuf_append_length(cl->buf, data, size); @@ -2246,6 +2267,15 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) svr->write_buf_offset = 0; eina_binbuf_free(svr->buf); svr->buf = NULL; +#ifdef TCP_CORK + if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK) + { + int state = 0; + if (setsockopt(svr->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) + /* realistically this isn't anything serious so we can just log and continue */ + ERR("uncorking failed! %s", strerror(errno)); + } +#endif } if (svr->fd_handler) @@ -2307,6 +2337,15 @@ _ecore_con_client_flush(Ecore_Con_Client *cl) cl->buf_offset = 0; eina_binbuf_free(cl->buf); cl->buf = NULL; +#ifdef TCP_CORK + if ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK) + { + int state = 0; + if (setsockopt(cl->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) + /* realistically this isn't anything serious so we can just log and continue */ + ERR("uncorking failed! %s", strerror(errno)); + } +#endif if (cl->fd_handler) ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); }