summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-09-13 23:03:26 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-09-13 23:03:26 +0000
commit20eed93ea3b00928094351a12a5b6478fb32b361 (patch)
tree9a8b72c967535f1da095789f0539dccfe4cc5c17
parent31908c69f9142af66e1ae93f8f1edc6e2afbd6c1 (diff)
add ECORE_CON_EVENT_SERVER_WRITE ECORE_CON_EVENT_CLIENT_WRITE
SVN revision: 63364
-rw-r--r--legacy/ecore/ChangeLog5
-rw-r--r--legacy/ecore/src/lib/ecore_con/Ecore_Con.h42
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con.c71
3 files changed, 118 insertions, 0 deletions
diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog
index 87d5b96c1e..c6be25d1e1 100644
--- a/legacy/ecore/ChangeLog
+++ b/legacy/ecore/ChangeLog
@@ -291,3 +291,8 @@
291 291
292 * Add ecore_con_server_fd_get, ecore_con_client_fd_get for manipulating 292 * Add ecore_con_server_fd_get, ecore_con_client_fd_get for manipulating
293 server file descriptors. 293 server file descriptors.
294
2952011-09-13 Mike Blumenkrantz
296
297 * Add ECORE_CON_EVENT_CLIENT_WRITE, ECORE_CON_EVENT_SERVER_WRITE for
298 obtaining progress of socket writes
diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
index 2dff134c92..eb30f96e56 100644
--- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
+++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
@@ -311,6 +311,20 @@ typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
311typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data; 311typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
312 312
313/** 313/**
314 * @typedef Ecore_Con_Event_Client_Write
315 * Used as the @p data param for the corresponding event
316 * @since 1.1
317 */
318typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write;
319
320/**
321 * @typedef Ecore_Con_Event_Server_Write
322 * Used as the @p data param for the corresponding event
323 * @since 1.1
324 */
325typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write;
326
327/**
314 * @typedef Ecore_Con_Event_Url_Data 328 * @typedef Ecore_Con_Event_Url_Data
315 * Used as the @p data param for the corresponding event 329 * Used as the @p data param for the corresponding event
316 * @ingroup Ecore_Con_Url_Group 330 * @ingroup Ecore_Con_Url_Group
@@ -430,6 +444,26 @@ struct _Ecore_Con_Event_Server_Data
430}; 444};
431 445
432/** 446/**
447 * @struct _Ecore_Con_Event_Client_Write
448 * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event
449 */
450struct _Ecore_Con_Event_Client_Write
451{
452 Ecore_Con_Client *client; /**< the client that connected */
453 int size; /**< the length of the data sent */
454};
455
456/**
457 * @struct _Ecore_Con_Event_Server_Write
458 * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event
459 */
460struct _Ecore_Con_Event_Server_Write
461{
462 Ecore_Con_Server *server; /**< the server that was connected to */
463 int size; /**< the length of the data sent */
464};
465
466/**
433 * @struct _Ecore_Con_Event_Url_Data 467 * @struct _Ecore_Con_Event_Url_Data
434 * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event 468 * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event
435 * @ingroup Ecore_Con_Url_Group 469 * @ingroup Ecore_Con_Url_Group
@@ -492,6 +526,14 @@ EAPI extern int ECORE_CON_EVENT_SERVER_ERROR;
492 * @since 1.1 526 * @since 1.1
493 */ 527 */
494EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE; 528EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE;
529/** A server connection has sent data to its client
530 * @since 1.1
531 */
532EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE;
533/** A server connection object has sent data
534 * @since 1.1
535 */
536EAPI extern int ECORE_CON_EVENT_SERVER_WRITE;
495/** A client connected to the server has sent data */ 537/** A client connected to the server has sent data */
496EAPI extern int ECORE_CON_EVENT_CLIENT_DATA; 538EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
497/** A server connection object has data */ 539/** A server connection object has data */
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c
index 0d2657e620..221368e5e9 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con.c
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c
@@ -94,6 +94,10 @@ static void _ecore_con_event_server_error_free(void *data,
94 Ecore_Con_Event_Server_Error *e); 94 Ecore_Con_Event_Server_Error *e);
95static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr, 95static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
96 Ecore_Con_Event_Client_Error *e); 96 Ecore_Con_Event_Client_Error *e);
97static void _ecore_con_event_server_write_free(void *data,
98 Ecore_Con_Event_Server_Write *e);
99static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
100 Ecore_Con_Event_Client_Write *e);
97 101
98static void _ecore_con_lookup_done(void *data, 102static void _ecore_con_lookup_done(void *data,
99 Ecore_Con_Info *infos); 103 Ecore_Con_Info *infos);
@@ -108,6 +112,8 @@ EAPI int ECORE_CON_EVENT_SERVER_ADD = 0;
108EAPI int ECORE_CON_EVENT_SERVER_DEL = 0; 112EAPI int ECORE_CON_EVENT_SERVER_DEL = 0;
109EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0; 113EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0;
110EAPI int ECORE_CON_EVENT_SERVER_DATA = 0; 114EAPI int ECORE_CON_EVENT_SERVER_DATA = 0;
115EAPI int ECORE_CON_EVENT_CLIENT_WRITE = 0;
116EAPI int ECORE_CON_EVENT_SERVER_WRITE = 0;
111EAPI int ECORE_CON_EVENT_CLIENT_ERROR = 0; 117EAPI int ECORE_CON_EVENT_CLIENT_ERROR = 0;
112EAPI int ECORE_CON_EVENT_SERVER_ERROR = 0; 118EAPI int ECORE_CON_EVENT_SERVER_ERROR = 0;
113 119
@@ -145,6 +151,8 @@ ecore_con_init(void)
145 ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new(); 151 ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new();
146 ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new(); 152 ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new();
147 ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new(); 153 ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new();
154 ECORE_CON_EVENT_CLIENT_WRITE = ecore_event_type_new();
155 ECORE_CON_EVENT_SERVER_WRITE = ecore_event_type_new();
148 ECORE_CON_EVENT_CLIENT_ERROR = ecore_event_type_new(); 156 ECORE_CON_EVENT_CLIENT_ERROR = ecore_event_type_new();
149 ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new(); 157 ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
150 158
@@ -949,6 +957,22 @@ ecore_con_event_server_del(Ecore_Con_Server *svr)
949} 957}
950 958
951void 959void
960ecore_con_event_server_write(Ecore_Con_Server *svr, int num)
961{
962 Ecore_Con_Event_Server_Write *e;
963
964 e = malloc(sizeof(Ecore_Con_Event_Server_Write));
965 EINA_SAFETY_ON_NULL_RETURN(e);
966
967 svr->event_count++;
968 e->server = svr;
969 e->size = num;
970 ecore_event_add(ECORE_CON_EVENT_SERVER_WRITE, e,
971 (Ecore_End_Cb)_ecore_con_event_server_write_free, NULL);
972
973}
974
975void
952ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate) 976ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate)
953{ 977{
954 Ecore_Con_Event_Server_Data *e; 978 Ecore_Con_Event_Server_Data *e;
@@ -1016,6 +1040,21 @@ ecore_con_event_client_del(Ecore_Con_Client *cl)
1016} 1040}
1017 1041
1018void 1042void
1043ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
1044{
1045 Ecore_Con_Event_Client_Write *e;
1046 e = malloc(sizeof(Ecore_Con_Event_Client_Write));
1047 EINA_SAFETY_ON_NULL_RETURN(e);
1048
1049 cl->host_server->event_count++;
1050 cl->event_count++;
1051 e->client = cl;
1052 e->size = num;
1053 ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
1054 (Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
1055}
1056
1057void
1019ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate) 1058ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate)
1020{ 1059{
1021 Ecore_Con_Event_Client_Data *e; 1060 Ecore_Con_Event_Client_Data *e;
@@ -2198,6 +2237,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
2198 return; 2237 return;
2199 } 2238 }
2200 2239
2240 if (count) ecore_con_event_server_write(svr, count);
2201 svr->write_buf_offset += count; 2241 svr->write_buf_offset += count;
2202 if (svr->write_buf_offset >= eina_binbuf_length_get(svr->buf)) 2242 if (svr->write_buf_offset >= eina_binbuf_length_get(svr->buf))
2203 { 2243 {
@@ -2262,6 +2302,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
2262 return; 2302 return;
2263 } 2303 }
2264 2304
2305 if (count) ecore_con_event_client_write(cl, count);
2265 cl->buf_offset += count; 2306 cl->buf_offset += count;
2266 if (cl->buf_offset >= eina_binbuf_length_get(cl->buf)) 2307 if (cl->buf_offset >= eina_binbuf_length_get(cl->buf))
2267 { 2308 {
@@ -2312,6 +2353,24 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
2312} 2353}
2313 2354
2314static void 2355static void
2356_ecore_con_event_client_write_free(Ecore_Con_Server *svr,
2357 Ecore_Con_Event_Client_Write *e)
2358{
2359 e->client->event_count--;
2360 e->client->host_server->event_count--;
2361
2362 if (((e->client->event_count <= 0) && (e->client->delete_me)) ||
2363 ((e->client->host_server &&
2364 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2365 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2366 ecore_con_client_del(e->client);
2367 if ((svr->event_count <= 0) && (svr->delete_me))
2368 _ecore_con_server_free(svr);
2369
2370 free(e);
2371}
2372
2373static void
2315_ecore_con_event_client_data_free(Ecore_Con_Server *svr, 2374_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2316 void *ev) 2375 void *ev)
2317{ 2376{
@@ -2363,6 +2422,18 @@ _ecore_con_event_server_del_free(void *data __UNUSED__,
2363} 2422}
2364 2423
2365static void 2424static void
2425_ecore_con_event_server_write_free(void *data __UNUSED__,
2426 Ecore_Con_Event_Server_Write *e)
2427{
2428 e->server->event_count--;
2429
2430 if ((e->server->event_count <= 0) && (e->server->delete_me))
2431 _ecore_con_server_free(e->server);
2432
2433 free(e);
2434}
2435
2436static void
2366_ecore_con_event_server_data_free(void *data __UNUSED__, 2437_ecore_con_event_server_data_free(void *data __UNUSED__,
2367 void *ev) 2438 void *ev)
2368{ 2439{