summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-07-29 13:08:36 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:13 +0900
commit47be3a2b819ed6319a65018195b31b622b547aab (patch)
treeda38402d574af89bfe4ce36667598cb8a260d108 /src/bin
parentc0bb73c775787ae1221efacc8d5d7a01a28320af (diff)
evas/cserve2: Prepare shared indexes in clients
- Move required struct definitions to common evas_cs2.h - Open/close shm and map arrays to memory Pretty stupid for now as it will close & reopen the shm files even when unchanged. - Check shm size and array header consistency - Implement message send - Send messages from server when calling repack()
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/evas/evas_cserve2.h1
-rw-r--r--src/bin/evas/evas_cserve2_cache.c49
-rw-r--r--src/bin/evas/evas_cserve2_index.c13
-rw-r--r--src/bin/evas/evas_cserve2_main.c29
4 files changed, 40 insertions, 52 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 1e1a055e21..c91e822b6b 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -233,6 +233,7 @@ void cserve2_client_del(Client *client);
233void cserve2_client_deliver(Client *client); 233void cserve2_client_deliver(Client *client);
234void cserve2_client_error_send(Client *client, unsigned int rid, int error_code); 234void cserve2_client_error_send(Client *client, unsigned int rid, int error_code);
235ssize_t cserve2_client_send(Client *client, const void *data, size_t size); 235ssize_t cserve2_client_send(Client *client, const void *data, size_t size);
236void cserve2_index_list_send(const char *files_index_path, const char *images_index_path, const char *fonts_index_path);
236 237
237Eina_Bool cserve2_fd_watch_add(int fd, Fd_Flags flags, Fd_Watch_Cb cb, const void *data); 238Eina_Bool cserve2_fd_watch_add(int fd, Fd_Flags flags, Fd_Watch_Cb cb, const void *data);
238Eina_Bool cserve2_fd_watch_del(int fd); 239Eina_Bool cserve2_fd_watch_del(int fd);
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index b1fc2ee8dd..777d35c337 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -14,19 +14,14 @@
14 14
15#include <Evas_Loader.h> 15#include <Evas_Loader.h>
16 16
17typedef int string_t;
18#define ENTRY Entry base 17#define ENTRY Entry base
19#define ASENTRY(a) (&(a->base)) 18#define ASENTRY(a) (&(a->base))
20#define ENTRYID(a) ((a)->base.id) 19#define ENTRYID(a) ((a)->base.id)
21#define SHMOBJECT unsigned int id; unsigned int refcount
22 20
23typedef struct _Entry Entry; 21typedef struct _Entry Entry;
24typedef struct _Shm_Object Shm_Object;
25typedef struct _Reference Reference; 22typedef struct _Reference Reference;
26typedef struct _File_Entry File_Entry; 23typedef struct _File_Entry File_Entry;
27typedef struct _File_Data File_Data;
28typedef struct _Image_Entry Image_Entry; 24typedef struct _Image_Entry Image_Entry;
29typedef struct _Image_Data Image_Data;
30typedef struct _File_Watch File_Watch; 25typedef struct _File_Watch File_Watch;
31 26
32typedef struct _Font_Source Font_Source; 27typedef struct _Font_Source Font_Source;
@@ -52,46 +47,17 @@ struct _Entry {
52#endif 47#endif
53}; 48};
54 49
55struct _Shm_Object
56{
57 SHMOBJECT;
58};
59
60struct _File_Entry { 50struct _File_Entry {
61 ENTRY; 51 ENTRY;
62 File_Watch *watcher; 52 File_Watch *watcher;
63 Eina_List *images; 53 Eina_List *images;
64}; 54};
65 55
66struct _File_Data {
67 SHMOBJECT;
68 string_t path;
69 string_t key;
70 string_t loader_data;
71 int w, h;
72 int frame_count;
73 int loop_count;
74 int loop_hint;
75 Eina_Bool alpha : 1;
76 Eina_Bool invalid : 1;
77};
78
79
80struct _Image_Entry { 56struct _Image_Entry {
81 ENTRY; 57 ENTRY;
82 Shm_Handle *shm; 58 Shm_Handle *shm;
83}; 59};
84 60
85struct _Image_Data {
86 SHMOBJECT;
87 unsigned int file_id;
88 string_t shm_id;
89 Evas_Image_Load_Opts opts;
90 Eina_Bool alpha_sparse : 1;
91 Eina_Bool unused : 1;
92 Eina_Bool doload : 1;
93};
94
95struct _Font_Source { 61struct _Font_Source {
96 string_t key; 62 string_t key;
97 string_t name; 63 string_t name;
@@ -350,12 +316,11 @@ _repack()
350 Shared_Array *sa; 316 Shared_Array *sa;
351 int count; 317 int count;
352 318
353 count = cserve2_shared_array_size_get(_file_data_array);
354 if (count <= 0) return;
355
356 // Repack when we have 10% fragmentation over the whole shm buffer 319 // Repack when we have 10% fragmentation over the whole shm buffer
357 if (_freed_entry_count > 100 || 320
358 ((_freed_entry_count * 100) / count >= 10)) 321 count = cserve2_shared_array_size_get(_file_data_array);
322 if ((count > 0) && (_freed_entry_count > 100 ||
323 ((_freed_entry_count * 100) / count >= 10)))
359 { 324 {
360 DBG("Repacking file data array: %s", 325 DBG("Repacking file data array: %s",
361 cserve2_shared_array_name_get(_file_data_array)); 326 cserve2_shared_array_name_get(_file_data_array));
@@ -373,6 +338,12 @@ _repack()
373 _freed_entry_count = 0; 338 _freed_entry_count = 0;
374 _file_data_array = sa; 339 _file_data_array = sa;
375 } 340 }
341
342 // FIXME TODO: Repack image data array as well
343
344 cserve2_index_list_send(cserve2_shared_array_name_get(_file_data_array),
345 cserve2_shared_array_name_get(_image_data_array),
346 NULL);
376} 347}
377 348
378 349
diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c
index debaedce53..329ceeb4e2 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -14,7 +14,6 @@
14typedef struct _Data_Shm Data_Shm; 14typedef struct _Data_Shm Data_Shm;
15typedef struct _Index_Entry Index_Entry; 15typedef struct _Index_Entry Index_Entry;
16typedef struct _Block Block; 16typedef struct _Block Block;
17typedef struct _Shared_Array_Header Shared_Array_Header;
18typedef struct _Shared_Index Shared_Index; 17typedef struct _Shared_Index Shared_Index;
19 18
20static int _instances = 0; 19static int _instances = 0;
@@ -31,18 +30,6 @@ struct _Data_Shm
31 char *data; 30 char *data;
32}; 31};
33 32
34struct _Shared_Array_Header
35{
36 int32_t tag;
37 int32_t elemsize;
38 int32_t count;
39 int32_t generation_id;
40 int32_t emptyidx;
41 int32_t sortedidx;
42 int32_t _reserved1;
43 int32_t _reserved2;
44};
45
46struct _Shared_Array 33struct _Shared_Array
47{ 34{
48 Data_Shm *ds; 35 Data_Shm *ds;
diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c
index e77eba2f14..5982c0d297 100644
--- a/src/bin/evas/evas_cserve2_main.c
+++ b/src/bin/evas/evas_cserve2_main.c
@@ -35,6 +35,35 @@ cserve2_client_error_send(Client *client, unsigned int rid, int error_code)
35 cserve2_client_send(client, &msg, sizeof(msg)); 35 cserve2_client_send(client, &msg, sizeof(msg));
36} 36}
37 37
38void
39cserve2_index_list_send(const char *files_index_path,
40 const char *images_index_path,
41 const char *fonts_index_path)
42{
43 Eina_Iterator *iter;
44 Client *client;
45 Msg_Index_List msg;
46 const int size = sizeof(msg);
47
48 memset(&msg, 0, size);
49 msg.base.type = CSERVE2_INDEX_LIST;
50 if (files_index_path)
51 eina_strlcpy(msg.files_index_path, files_index_path, 64);
52 if (images_index_path)
53 eina_strlcpy(msg.images_index_path, images_index_path, 64);
54 if (fonts_index_path)
55 eina_strlcpy(msg.fonts_index_path, fonts_index_path, 64);
56
57 iter = eina_hash_iterator_data_new(client_list);
58 EINA_ITERATOR_FOREACH(iter, client)
59 {
60 DBG("Sending updated list of indexes to client %d", client->id);
61 cserve2_client_send(client, &size, sizeof(size));
62 cserve2_client_send(client, &msg, sizeof(msg));
63 }
64 eina_iterator_free(iter);
65}
66
38static void 67static void
39_cserve2_client_close(Client *client) 68_cserve2_client_close(Client *client)
40{ 69{