summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-12-16 07:43:48 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-12-16 07:43:48 +0000
commit5af90813421ea6171217af98ca575dc5caf11f15 (patch)
treef977dff17c27a78c13d30d4aa4f4a0d6e5cb6703 /legacy
parent913852ba3428df845aec6a15a7d486b89590eb92 (diff)
finally fix stupid ssl read bug for long transfers! also added a couple more error checks and reordered things to read a little better
SVN revision: 55577
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con.c97
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con_ssl.c4
2 files changed, 48 insertions, 53 deletions
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c
index 3b9ea1befe..756beb560c 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con.c
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c
@@ -1813,14 +1813,11 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
1813 else 1813 else
1814 { 1814 {
1815 num = ecore_con_ssl_server_read(svr, buf, sizeof(buf)); 1815 num = ecore_con_ssl_server_read(svr, buf, sizeof(buf));
1816 if (num > 0) 1816 if (num >= 0)
1817 lost_server = EINA_FALSE; 1817 lost_server = EINA_FALSE;
1818 } 1818 }
1819 1819
1820 if (lost_server) 1820 if ((!svr->delete_me) && (num > 0))
1821 _ecore_con_server_kill(svr);
1822
1823 if ((num > 0) && (!svr->delete_me))
1824 { 1821 {
1825 Ecore_Con_Event_Server_Data *e; 1822 Ecore_Con_Event_Server_Data *e;
1826 1823
@@ -1842,7 +1839,8 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
1842 _ecore_con_event_server_data_free, NULL); 1839 _ecore_con_event_server_data_free, NULL);
1843 } 1840 }
1844 1841
1845 1842 if (lost_server)
1843 _ecore_con_server_kill(svr);
1846} 1844}
1847 1845
1848static Eina_Bool 1846static Eina_Bool
@@ -1944,27 +1942,26 @@ _ecore_con_cl_udp_handler(void *data,
1944 errno = 0; 1942 errno = 0;
1945 num = read(svr->fd, buf, READBUFSIZ); 1943 num = read(svr->fd, buf, READBUFSIZ);
1946 1944
1947 if ((errno != EAGAIN) && (errno != EINTR)) 1945 if ((!svr->delete_me) && (num > 0))
1948 _ecore_con_server_kill(svr); 1946 {
1949 1947 inbuf = malloc(num);
1950 if ((num < 1) || (svr->delete_me)) 1948 EINA_SAFETY_ON_NULL_RETURN_VAL(inbuf, ECORE_CALLBACK_RENEW);
1951 return ECORE_CALLBACK_RENEW;
1952 1949
1953 inbuf = malloc(num); 1950 memcpy(inbuf, buf, num);
1954 if (!inbuf)
1955 return ECORE_CALLBACK_RENEW;
1956 1951
1957 memcpy(inbuf, buf, num); 1952 e = malloc(sizeof(Ecore_Con_Event_Server_Data));
1953 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
1958 1954
1959 e = calloc(1, sizeof(Ecore_Con_Event_Server_Data)); 1955 svr->event_count++;
1960 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW); 1956 e->server = svr;
1957 e->data = inbuf;
1958 e->size = num;
1959 ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
1960 _ecore_con_event_server_data_free, NULL);
1961 }
1961 1962
1962 svr->event_count++; 1963 if ((errno != EAGAIN) && (errno != EINTR))
1963 e->server = svr; 1964 _ecore_con_server_kill(svr);
1964 e->data = inbuf;
1965 e->size = num;
1966 ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
1967 _ecore_con_event_server_data_free, NULL);
1968 1965
1969 return ECORE_CALLBACK_RENEW; 1966 return ECORE_CALLBACK_RENEW;
1970} 1967}
@@ -2052,7 +2049,7 @@ _ecore_con_svr_udp_handler(void *data,
2052 { /* indent to keep it all nicely separated */ 2049 { /* indent to keep it all nicely separated */
2053 Ecore_Con_Event_Client_Add *add; 2050 Ecore_Con_Event_Client_Add *add;
2054 2051
2055 add = calloc(1, sizeof(Ecore_Con_Event_Client_Add)); 2052 add = malloc(sizeof(Ecore_Con_Event_Client_Add));
2056 EINA_SAFETY_ON_NULL_RETURN_VAL(add, ECORE_CALLBACK_RENEW); 2053 EINA_SAFETY_ON_NULL_RETURN_VAL(add, ECORE_CALLBACK_RENEW);
2057 2054
2058 /*cl->event_count++;*/ 2055 /*cl->event_count++;*/
@@ -2065,7 +2062,7 @@ _ecore_con_svr_udp_handler(void *data,
2065 2062
2066 { 2063 {
2067 Ecore_Con_Event_Client_Data *e; 2064 Ecore_Con_Event_Client_Data *e;
2068 e = calloc(1, sizeof(Ecore_Con_Event_Client_Data)); 2065 e = malloc(sizeof(Ecore_Con_Event_Client_Data));
2069 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW); 2066 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
2070 2067
2071 svr->event_count++; 2068 svr->event_count++;
@@ -2117,10 +2114,33 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
2117 else 2114 else
2118 { 2115 {
2119 num = ecore_con_ssl_client_read(cl, buf, sizeof(buf)); 2116 num = ecore_con_ssl_client_read(cl, buf, sizeof(buf));
2120 if (num > 0) 2117 if (num >= 0)
2121 lost_client = EINA_FALSE; 2118 lost_client = EINA_FALSE;
2122 } 2119 }
2123 2120
2121 if ((!cl->delete_me) && (num > 0))
2122 {
2123 Ecore_Con_Event_Client_Data *e;
2124
2125 e = malloc(sizeof(Ecore_Con_Event_Client_Data));
2126 EINA_SAFETY_ON_NULL_RETURN(e);
2127
2128 cl->event_count++;
2129 _ecore_con_cl_timer_update(cl);
2130 e->client = cl;
2131 e->data = malloc(num);
2132 if (!e->data)
2133 {
2134 ERR("alloc!");
2135 free(e);
2136 return;
2137 }
2138 memcpy(e->data, buf, num);
2139 e->size = num;
2140 ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
2141 _ecore_con_event_client_data_free, NULL);
2142 }
2143
2124 if (lost_client) 2144 if (lost_client)
2125 { 2145 {
2126 if (!cl->delete_me) 2146 if (!cl->delete_me)
@@ -2145,31 +2165,6 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
2145 cl->fd_handler = NULL; 2165 cl->fd_handler = NULL;
2146 return; 2166 return;
2147 } 2167 }
2148
2149 if ((num > 0) && (!cl->delete_me))
2150 {
2151 Ecore_Con_Event_Client_Data *e;
2152
2153 e = malloc(sizeof(Ecore_Con_Event_Client_Data));
2154 EINA_SAFETY_ON_NULL_RETURN(e);
2155
2156 cl->event_count++;
2157 _ecore_con_cl_timer_update(cl);
2158 e->client = cl;
2159 e->data = malloc(num);
2160 if (!e->data)
2161 {
2162 ERR("alloc!");
2163 free(e);
2164 return;
2165 }
2166 memcpy(e->data, buf, num);
2167 e->size = num;
2168 ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
2169 _ecore_con_event_client_data_free, NULL);
2170 }
2171
2172
2173} 2168}
2174 2169
2175static Eina_Bool 2170static Eina_Bool
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_ssl.c b/legacy/ecore/src/lib/ecore_con/ecore_con_ssl.c
index cf90ec4df4..c411312587 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con_ssl.c
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con_ssl.c
@@ -741,7 +741,7 @@ _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
741 if (!_ecore_con_ssl_server_init_gnutls(svr)) 741 if (!_ecore_con_ssl_server_init_gnutls(svr))
742 return 0; 742 return 0;
743 } 743 }
744 else if (!gnutls_error_is_fatal(num)) 744 else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS))
745 return 0; 745 return 0;
746 746
747 return -1; 747 return -1;
@@ -963,7 +963,7 @@ _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
963 WRN("Rehandshake request ignored"); 963 WRN("Rehandshake request ignored");
964 return 0; 964 return 0;
965 } 965 }
966 else if (!gnutls_error_is_fatal(num)) 966 else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS))
967 return 0; 967 return 0;
968 968
969 return -1; 969 return -1;