we've got NODELAY, may as well add CORK
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 10 Dec 2011 08:14:50 +0000 (08:14 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 10 Dec 2011 08:14:50 +0000 (08:14 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@66082 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/ecore_con/Ecore_Con.h
src/lib/ecore_con/ecore_con.c

index f58daa7..aac6655 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 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/NEWS b/NEWS
index 61a13d0..1da17af 100644 (file)
--- a/NEWS
+++ b/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()
 
index 87a7ddf..c91ad05 100644 (file)
@@ -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 */
index 78c15e9..fd22623 100644 (file)
@@ -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);
      }