From: Enlightenment S. <no-...@en...> - 2011-09-13 23:03:39
|
Log: add ECORE_CON_EVENT_SERVER_WRITE ECORE_CON_EVENT_CLIENT_WRITE Author: discomfitor Date: 2011-09-13 16:03:26 -0700 (Tue, 13 Sep 2011) New Revision: 63364 Trac: http://trac.enlightenment.org/e/changeset/63364 Modified: trunk/ecore/ChangeLog trunk/ecore/src/lib/ecore_con/Ecore_Con.h trunk/ecore/src/lib/ecore_con/ecore_con.c Modified: trunk/ecore/ChangeLog =================================================================== --- trunk/ecore/ChangeLog 2011-09-13 22:46:46 UTC (rev 63363) +++ trunk/ecore/ChangeLog 2011-09-13 23:03:26 UTC (rev 63364) @@ -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 Modified: trunk/ecore/src/lib/ecore_con/Ecore_Con.h =================================================================== --- trunk/ecore/src/lib/ecore_con/Ecore_Con.h 2011-09-13 22:46:46 UTC (rev 63363) +++ trunk/ecore/src/lib/ecore_con/Ecore_Con.h 2011-09-13 23:03:26 UTC (rev 63364) @@ -311,6 +311,20 @@ 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 * @ingroup Ecore_Con_Url_Group @@ -430,6 +444,26 @@ }; /** + * @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 * @ingroup Ecore_Con_Url_Group @@ -492,6 +526,14 @@ * @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 */ Modified: trunk/ecore/src/lib/ecore_con/ecore_con.c =================================================================== --- trunk/ecore/src/lib/ecore_con/ecore_con.c 2011-09-13 22:46:46 UTC (rev 63363) +++ trunk/ecore/src/lib/ecore_con/ecore_con.c 2011-09-13 23:03:26 UTC (rev 63364) @@ -94,6 +94,10 @@ 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_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_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(); @@ -949,6 +957,22 @@ } 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) { Ecore_Con_Event_Server_Data *e; @@ -1016,6 +1040,21 @@ } 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) { Ecore_Con_Event_Client_Data *e; @@ -2198,6 +2237,7 @@ 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 @@ return; } + if (count) ecore_con_event_client_write(cl, count); cl->buf_offset += count; if (cl->buf_offset >= eina_binbuf_length_get(cl->buf)) { @@ -2312,6 +2353,24 @@ } 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) { @@ -2363,6 +2422,18 @@ } 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) { |