finally fix stupid ssl read bug for long transfers! also added a couple more error...
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 16 Dec 2010 07:43:48 +0000 (07:43 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 16 Dec 2010 07:43:48 +0000 (07:43 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@55577 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_con/ecore_con.c
src/lib/ecore_con/ecore_con_ssl.c

index 3b9ea1b..756beb5 100644 (file)
@@ -1813,14 +1813,11 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
    else
      {
        num = ecore_con_ssl_server_read(svr, buf, sizeof(buf));
-         if (num > 0)
+         if (num >= 0)
            lost_server = EINA_FALSE;
      }
 
-   if (lost_server)
-     _ecore_con_server_kill(svr);
-
-   if ((num > 0) && (!svr->delete_me))
+   if ((!svr->delete_me) && (num > 0))
    {
       Ecore_Con_Event_Server_Data *e;
 
@@ -1842,7 +1839,8 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
                       _ecore_con_event_server_data_free, NULL);
    }
 
-
+   if (lost_server)
+     _ecore_con_server_kill(svr);
 }
 
 static Eina_Bool
@@ -1944,27 +1942,26 @@ _ecore_con_cl_udp_handler(void             *data,
    errno = 0;
    num = read(svr->fd, buf, READBUFSIZ);
 
-   if ((errno != EAGAIN) && (errno != EINTR))
-     _ecore_con_server_kill(svr);
-
-   if ((num < 1) || (svr->delete_me))
-     return ECORE_CALLBACK_RENEW;
+   if ((!svr->delete_me) && (num > 0))
+     {
+        inbuf = malloc(num);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(inbuf, ECORE_CALLBACK_RENEW);
 
-   inbuf = malloc(num);
-   if (!inbuf)
-     return ECORE_CALLBACK_RENEW;
+        memcpy(inbuf, buf, num);
 
-   memcpy(inbuf, buf, num);
+        e = malloc(sizeof(Ecore_Con_Event_Server_Data));
+        EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
 
-   e = calloc(1, sizeof(Ecore_Con_Event_Server_Data));
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
+        svr->event_count++;
+        e->server = svr;
+        e->data = inbuf;
+        e->size = num;
+        ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
+                        _ecore_con_event_server_data_free, NULL);
+     }
 
-   svr->event_count++;
-   e->server = svr;
-   e->data = inbuf;
-   e->size = num;
-   ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
-                   _ecore_con_event_server_data_free, NULL);
+   if ((errno != EAGAIN) && (errno != EINTR))
+     _ecore_con_server_kill(svr);
 
    return ECORE_CALLBACK_RENEW;
 }
@@ -2052,7 +2049,7 @@ _ecore_con_svr_udp_handler(void             *data,
    { /* indent to keep it all nicely separated */
       Ecore_Con_Event_Client_Add *add;
 
-      add = calloc(1, sizeof(Ecore_Con_Event_Client_Add));
+      add = malloc(sizeof(Ecore_Con_Event_Client_Add));
       EINA_SAFETY_ON_NULL_RETURN_VAL(add, ECORE_CALLBACK_RENEW);
 
       /*cl->event_count++;*/
@@ -2065,7 +2062,7 @@ _ecore_con_svr_udp_handler(void             *data,
 
    {
       Ecore_Con_Event_Client_Data *e;
-      e = calloc(1, sizeof(Ecore_Con_Event_Client_Data));
+      e = malloc(sizeof(Ecore_Con_Event_Client_Data));
       EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
 
       svr->event_count++;
@@ -2117,10 +2114,33 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
    else
      {
         num = ecore_con_ssl_client_read(cl, buf, sizeof(buf));
-        if (num > 0)
+        if (num >= 0)
           lost_client = EINA_FALSE;
      }
 
+   if ((!cl->delete_me) && (num > 0))
+     {
+        Ecore_Con_Event_Client_Data *e;
+
+        e = malloc(sizeof(Ecore_Con_Event_Client_Data));
+        EINA_SAFETY_ON_NULL_RETURN(e);
+
+        cl->event_count++;
+        _ecore_con_cl_timer_update(cl);
+        e->client = cl;
+        e->data = malloc(num);
+        if (!e->data)
+          {
+             ERR("alloc!");
+             free(e);
+             return;
+          }
+        memcpy(e->data, buf, num);
+        e->size = num;
+        ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
+                        _ecore_con_event_client_data_free, NULL);
+     }
+
    if (lost_client)
      {
         if (!cl->delete_me)
@@ -2145,31 +2165,6 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
         cl->fd_handler = NULL;
         return;
      }
-
-   if ((num > 0) && (!cl->delete_me))
-     {
-        Ecore_Con_Event_Client_Data *e;
-
-        e = malloc(sizeof(Ecore_Con_Event_Client_Data));
-        EINA_SAFETY_ON_NULL_RETURN(e);
-
-        cl->event_count++;
-        _ecore_con_cl_timer_update(cl);
-        e->client = cl;
-        e->data = malloc(num);
-        if (!e->data)
-          {
-             ERR("alloc!");
-             free(e);
-             return;
-          }
-        memcpy(e->data, buf, num);
-        e->size = num;
-        ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
-                        _ecore_con_event_client_data_free, NULL);
-     }
-
-
 }
 
 static Eina_Bool
index cf90ec4..c411312 100644 (file)
@@ -741,7 +741,7 @@ _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
         if (!_ecore_con_ssl_server_init_gnutls(svr))
           return 0;
      }
-   else if (!gnutls_error_is_fatal(num))
+   else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS))
      return 0;
 
    return -1;
@@ -963,7 +963,7 @@ _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
         WRN("Rehandshake request ignored");
         return 0;
      }
-   else if (!gnutls_error_is_fatal(num))
+   else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS))
      return 0;
 
    return -1;