add ECORE_CON_EVENT_SERVER_WRITE ECORE_CON_EVENT_CLIENT_WRITE

SVN revision: 63364
This commit is contained in:
Mike Blumenkrantz 2011-09-13 23:03:26 +00:00
parent 31908c69f9
commit 20eed93ea3
3 changed files with 118 additions and 0 deletions

View File

@ -291,3 +291,8 @@
* Add ecore_con_server_fd_get, ecore_con_client_fd_get for manipulating
server file descriptors.
2011-09-13 Mike Blumenkrantz
* Add ECORE_CON_EVENT_CLIENT_WRITE, ECORE_CON_EVENT_SERVER_WRITE for
obtaining progress of socket writes

View File

@ -310,6 +310,20 @@ typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
*/
typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
/**
* @typedef Ecore_Con_Event_Client_Write
* Used as the @p data param for the corresponding event
* @since 1.1
*/
typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write;
/**
* @typedef Ecore_Con_Event_Server_Write
* Used as the @p data param for the corresponding event
* @since 1.1
*/
typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write;
/**
* @typedef Ecore_Con_Event_Url_Data
* Used as the @p data param for the corresponding event
@ -429,6 +443,26 @@ struct _Ecore_Con_Event_Server_Data
int size; /**< the length of the data sent */
};
/**
* @struct _Ecore_Con_Event_Client_Write
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event
*/
struct _Ecore_Con_Event_Client_Write
{
Ecore_Con_Client *client; /**< the client that connected */
int size; /**< the length of the data sent */
};
/**
* @struct _Ecore_Con_Event_Server_Write
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event
*/
struct _Ecore_Con_Event_Server_Write
{
Ecore_Con_Server *server; /**< the server that was connected to */
int size; /**< the length of the data sent */
};
/**
* @struct _Ecore_Con_Event_Url_Data
* Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event
@ -492,6 +526,14 @@ EAPI extern int ECORE_CON_EVENT_SERVER_ERROR;
* @since 1.1
*/
EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE;
/** A server connection has sent data to its client
* @since 1.1
*/
EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE;
/** A server connection object has sent data
* @since 1.1
*/
EAPI extern int ECORE_CON_EVENT_SERVER_WRITE;
/** A client connected to the server has sent data */
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
/** A server connection object has data */

View File

@ -94,6 +94,10 @@ static void _ecore_con_event_server_error_free(void *data,
Ecore_Con_Event_Server_Error *e);
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
Ecore_Con_Event_Client_Error *e);
static void _ecore_con_event_server_write_free(void *data,
Ecore_Con_Event_Server_Write *e);
static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
Ecore_Con_Event_Client_Write *e);
static void _ecore_con_lookup_done(void *data,
Ecore_Con_Info *infos);
@ -108,6 +112,8 @@ EAPI int ECORE_CON_EVENT_SERVER_ADD = 0;
EAPI int ECORE_CON_EVENT_SERVER_DEL = 0;
EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0;
EAPI int ECORE_CON_EVENT_SERVER_DATA = 0;
EAPI int ECORE_CON_EVENT_CLIENT_WRITE = 0;
EAPI int ECORE_CON_EVENT_SERVER_WRITE = 0;
EAPI int ECORE_CON_EVENT_CLIENT_ERROR = 0;
EAPI int ECORE_CON_EVENT_SERVER_ERROR = 0;
@ -145,6 +151,8 @@ ecore_con_init(void)
ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_WRITE = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_WRITE = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_ERROR = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
@ -948,6 +956,22 @@ ecore_con_event_server_del(Ecore_Con_Server *svr)
_ecore_con_event_server_del_free, NULL);
}
void
ecore_con_event_server_write(Ecore_Con_Server *svr, int num)
{
Ecore_Con_Event_Server_Write *e;
e = malloc(sizeof(Ecore_Con_Event_Server_Write));
EINA_SAFETY_ON_NULL_RETURN(e);
svr->event_count++;
e->server = svr;
e->size = num;
ecore_event_add(ECORE_CON_EVENT_SERVER_WRITE, e,
(Ecore_End_Cb)_ecore_con_event_server_write_free, NULL);
}
void
ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate)
{
@ -1015,6 +1039,21 @@ ecore_con_event_client_del(Ecore_Con_Client *cl)
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
}
void
ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
{
Ecore_Con_Event_Client_Write *e;
e = malloc(sizeof(Ecore_Con_Event_Client_Write));
EINA_SAFETY_ON_NULL_RETURN(e);
cl->host_server->event_count++;
cl->event_count++;
e->client = cl;
e->size = num;
ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
(Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
}
void
ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate)
{
@ -2198,6 +2237,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
return;
}
if (count) ecore_con_event_server_write(svr, count);
svr->write_buf_offset += count;
if (svr->write_buf_offset >= eina_binbuf_length_get(svr->buf))
{
@ -2262,6 +2302,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
return;
}
if (count) ecore_con_event_client_write(cl, count);
cl->buf_offset += count;
if (cl->buf_offset >= eina_binbuf_length_get(cl->buf))
{
@ -2311,6 +2352,24 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
free(e);
}
static void
_ecore_con_event_client_write_free(Ecore_Con_Server *svr,
Ecore_Con_Event_Client_Write *e)
{
e->client->event_count--;
e->client->host_server->event_count--;
if (((e->client->event_count <= 0) && (e->client->delete_me)) ||
((e->client->host_server &&
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
ecore_con_client_del(e->client);
if ((svr->event_count <= 0) && (svr->delete_me))
_ecore_con_server_free(svr);
free(e);
}
static void
_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
void *ev)
@ -2362,6 +2421,18 @@ _ecore_con_event_server_del_free(void *data __UNUSED__,
free(e);
}
static void
_ecore_con_event_server_write_free(void *data __UNUSED__,
Ecore_Con_Event_Server_Write *e)
{
e->server->event_count--;
if ((e->server->event_count <= 0) && (e->server->delete_me))
_ecore_con_server_free(e->server);
free(e);
}
static void
_ecore_con_event_server_data_free(void *data __UNUSED__,
void *ev)