forked from enlightenment/efl
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
This commit is contained in:
parent
913852ba34
commit
5af9081342
|
@ -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,19 +1942,14 @@ _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);
|
||||
if (!inbuf)
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(inbuf, ECORE_CALLBACK_RENEW);
|
||||
|
||||
memcpy(inbuf, buf, num);
|
||||
|
||||
e = calloc(1, sizeof(Ecore_Con_Event_Server_Data));
|
||||
e = malloc(sizeof(Ecore_Con_Event_Server_Data));
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
|
||||
|
||||
svr->event_count++;
|
||||
|
@ -1965,6 +1958,10 @@ _ecore_con_cl_udp_handler(void *data,
|
|||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue