summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_ipc
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-03-13 08:50:26 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-03-13 08:50:26 +0000
commit6e54d73898fb9dd60429dc20b11f06d8a59858f4 (patch)
tree61e67193c156cf5e2db2221b24c6cc1f8e6b87a5 /legacy/ecore/src/lib/ecore_ipc
parent8206af707abeea83e759241564d1ca07d6fb49c5 (diff)
add max data payload settings to ipc
SVN revision: 21249
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h4
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c141
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h2
3 files changed, 113 insertions, 34 deletions
diff --git a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
index 9071cacc2c..65bf3a7ab2 100644
--- a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
+++ b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
@@ -297,6 +297,8 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v);
297 /* FIXME: this needs to become an ipc message */ 297 /* FIXME: this needs to become an ipc message */
298 EAPI int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, void *data, int size); 298 EAPI int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, void *data, int size);
299 EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients); 299 EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients);
300 EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size);
301 EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv);
300 302
301 /* FIXME: this needs to become an ipc message */ 303 /* FIXME: this needs to become an ipc message */
302 EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size); 304 EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size);
@@ -304,6 +306,8 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v);
304 EAPI void *ecore_ipc_client_del(Ecore_Ipc_Client *cl); 306 EAPI void *ecore_ipc_client_del(Ecore_Ipc_Client *cl);
305 EAPI void ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data); 307 EAPI void ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data);
306 EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl); 308 EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl);
309 EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size);
310 EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl);
307 311
308 EAPI int ecore_ipc_ssl_available_get(void); 312 EAPI int ecore_ipc_ssl_available_get(void);
309 /* FIXME: need to add a callback to "ok" large ipc messages greater than */ 313 /* FIXME: need to add a callback to "ok" large ipc messages greater than */
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
index 47da681761..93f8f7e92e 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
@@ -349,6 +349,7 @@ ecore_ipc_server_add(Ecore_Ipc_Type compl_type, const char *name, int port, cons
349 free(svr); 349 free(svr);
350 return NULL; 350 return NULL;
351 } 351 }
352 svr->max_buf_size = 32 * 1024;
352 svr->data = (void *)data; 353 svr->data = (void *)data;
353 servers = _ecore_list2_append(servers, svr); 354 servers = _ecore_list2_append(servers, svr);
354 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER); 355 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER);
@@ -404,6 +405,7 @@ ecore_ipc_server_connect(Ecore_Ipc_Type compl_type, char *name, int port, const
404 free(svr); 405 free(svr);
405 return NULL; 406 return NULL;
406 } 407 }
408 svr->max_buf_size = -1;
407 svr->data = (void *)data; 409 svr->data = (void *)data;
408 servers = _ecore_list2_append(servers, svr); 410 servers = _ecore_list2_append(servers, svr);
409 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER); 411 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER);
@@ -600,6 +602,31 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char
600 ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients); 602 ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients);
601} 603}
602 604
605EAPI void
606ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size)
607{
608 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
609 {
610 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
611 "ecore_ipc_server_data_size_max_set");
612 return;
613 }
614 svr->max_buf_size = size;
615}
616
617EAPI int
618ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr)
619{
620 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
621 {
622 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
623 "ecore_ipc_server_data_size_max_get");
624 return -1;
625 }
626 return svr->max_buf_size;
627}
628
629
603#define CLENC(_member) \ 630#define CLENC(_member) \
604 d = _ecore_ipc_dlt_int(msg._member, cl->prev.o._member, &md); \ 631 d = _ecore_ipc_dlt_int(msg._member, cl->prev.o._member, &md); \
605 if (md >= DLT_SET) \ 632 if (md >= DLT_SET) \
@@ -779,6 +806,30 @@ ecore_ipc_client_data_get(Ecore_Ipc_Client *cl)
779 return cl->data; 806 return cl->data;
780} 807}
781 808
809EAPI void
810ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size)
811{
812 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
813 {
814 ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
815 "ecore_ipc_client_data_size_max_set");
816 return;
817 }
818 cl->max_buf_size = size;
819}
820
821EAPI int
822ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl)
823{
824 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
825 {
826 ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
827 "ecore_ipc_client_data_size_max_get");
828 return -1;
829 }
830 return cl->max_buf_size;
831}
832
782/** 833/**
783 * Returns if SSL support is available 834 * Returns if SSL support is available
784 * @return 1 if SSL is available, 0 if it is not. 835 * @return 1 if SSL is available, 0 if it is not.
@@ -808,6 +859,7 @@ _ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void
808 svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); 859 svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
809 ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT); 860 ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT);
810 cl->client = e->client; 861 cl->client = e->client;
862 cl->max_buf_size = 32 * 1024;
811 ecore_con_client_data_set(cl->client, (void *)cl); 863 ecore_con_client_data_set(cl->client, (void *)cl);
812 svr->clients = _ecore_list2_append(svr->clients, cl); 864 svr->clients = _ecore_list2_append(svr->clients, cl);
813 { 865 {
@@ -1020,27 +1072,43 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1020 if ((cl->buf_size - offset) >= (s + msg.size)) 1072 if ((cl->buf_size - offset) >= (s + msg.size))
1021 { 1073 {
1022 Ecore_Ipc_Event_Client_Data *e2; 1074 Ecore_Ipc_Event_Client_Data *e2;
1075 Ecore_Ipc_Server *svr;
1076 int max, max2;
1023 1077
1024 buf = NULL; 1078 buf = NULL;
1025 if (msg.size > 0) 1079 svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
1080 max = svr->max_buf_size;
1081 max2 = cl->max_buf_size;
1082 if ((max >= 0) && (max2 >= 0))
1026 { 1083 {
1027 buf = malloc(msg.size); 1084 if (max2 < max) max = max2;
1028 if (!buf) return 0;
1029 memcpy(buf, cl->buf + offset + s, msg.size);
1030 } 1085 }
1031 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data)); 1086 else
1032 if (e2)
1033 { 1087 {
1034 e2->client = cl; 1088 if (max < 0) max = max2;
1035 e2->major = msg.major; 1089 }
1036 e2->minor = msg.minor; 1090 if ((max < 0) || (msg.size <= max))
1037 e2->ref = msg.ref; 1091 {
1038 e2->ref_to = msg.ref_to; 1092 if (msg.size > 0)
1039 e2->response = msg.response; 1093 {
1040 e2->size = msg.size; 1094 buf = malloc(msg.size);
1041 e2->data = buf; 1095 if (!buf) return 0;
1042 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2, 1096 memcpy(buf, cl->buf + offset + s, msg.size);
1043 _ecore_ipc_event_client_data_free, NULL); 1097 }
1098 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data));
1099 if (e2)
1100 {
1101 e2->client = cl;
1102 e2->major = msg.major;
1103 e2->minor = msg.minor;
1104 e2->ref = msg.ref;
1105 e2->ref_to = msg.ref_to;
1106 e2->response = msg.response;
1107 e2->size = msg.size;
1108 e2->data = buf;
1109 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2,
1110 _ecore_ipc_event_client_data_free, NULL);
1111 }
1044 } 1112 }
1045 cl->prev.i = msg; 1113 cl->prev.i = msg;
1046 offset += (s + msg.size); 1114 offset += (s + msg.size);
@@ -1193,27 +1261,32 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1193 if ((svr->buf_size - offset) >= (s + msg.size)) 1261 if ((svr->buf_size - offset) >= (s + msg.size))
1194 { 1262 {
1195 Ecore_Ipc_Event_Server_Data *e2; 1263 Ecore_Ipc_Event_Server_Data *e2;
1264 int max;
1196 1265
1197 buf = NULL; 1266 buf = NULL;
1198 if (msg.size > 0) 1267 max = svr->max_buf_size;
1199 { 1268 if ((max < 0) || (msg.size <= max))
1200 buf = malloc(msg.size);
1201 if (!buf) return 0;
1202 memcpy(buf, svr->buf + offset + s, msg.size);
1203 }
1204 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data));
1205 if (e2)
1206 { 1269 {
1207 e2->server = svr; 1270 if (msg.size > 0)
1208 e2->major = msg.major; 1271 {
1209 e2->minor = msg.minor; 1272 buf = malloc(msg.size);
1210 e2->ref = msg.ref; 1273 if (!buf) return 0;
1211 e2->ref_to = msg.ref_to; 1274 memcpy(buf, svr->buf + offset + s, msg.size);
1212 e2->response = msg.response; 1275 }
1213 e2->size = msg.size; 1276 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data));
1214 e2->data = buf; 1277 if (e2)
1215 ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2, 1278 {
1216 _ecore_ipc_event_server_data_free, NULL); 1279 e2->server = svr;
1280 e2->major = msg.major;
1281 e2->minor = msg.minor;
1282 e2->ref = msg.ref;
1283 e2->ref_to = msg.ref_to;
1284 e2->response = msg.response;
1285 e2->size = msg.size;
1286 e2->data = buf;
1287 ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2,
1288 _ecore_ipc_event_server_data_free, NULL);
1289 }
1217 } 1290 }
1218 svr->prev.i = msg; 1291 svr->prev.i = msg;
1219 offset += (s + msg.size); 1292 offset += (s + msg.size);
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
index 7f1ea41824..23584c2adc 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
@@ -43,6 +43,7 @@ struct _Ecore_Ipc_Client
43 void *data; 43 void *data;
44 unsigned char *buf; 44 unsigned char *buf;
45 int buf_size; 45 int buf_size;
46 int max_buf_size;
46 47
47 struct { 48 struct {
48 Ecore_Ipc_Msg_Head i, o; 49 Ecore_Ipc_Msg_Head i, o;
@@ -58,6 +59,7 @@ struct _Ecore_Ipc_Server
58 void *data; 59 void *data;
59 unsigned char *buf; 60 unsigned char *buf;
60 int buf_size; 61 int buf_size;
62 int max_buf_size;
61 63
62 struct { 64 struct {
63 Ecore_Ipc_Msg_Head i, o; 65 Ecore_Ipc_Msg_Head i, o;