summaryrefslogtreecommitdiff
path: root/legacy/eio
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-08-28 06:28:56 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-08-28 06:28:56 +0000
commit68b40793ab01ab5208d75e659fa902cda28ae00c (patch)
tree56a0f5f6d61342878dec2c21e99eccee9442ed1d /legacy/eio
parentd6385af5433be98fa48c9f38d99151c11d6cd03c (diff)
Eio: add log debugging macros
SVN revision: 75751
Diffstat (limited to 'legacy/eio')
-rw-r--r--legacy/eio/ChangeLog1
-rw-r--r--legacy/eio/NEWS1
-rw-r--r--legacy/eio/src/lib/eio_main.c49
-rw-r--r--legacy/eio/src/lib/eio_monitor_win32.c13
-rw-r--r--legacy/eio/src/lib/eio_private.h27
5 files changed, 77 insertions, 14 deletions
diff --git a/legacy/eio/ChangeLog b/legacy/eio/ChangeLog
index 894d602c46..90cccb3724 100644
--- a/legacy/eio/ChangeLog
+++ b/legacy/eio/ChangeLog
@@ -26,3 +26,4 @@
262012-08-07 Vincent Torri 262012-08-07 Vincent Torri
27 27
28 * Do not free Windows stuff when it is not used. Fix seg fault 28 * Do not free Windows stuff when it is not used. Fix seg fault
29 * Add log debugging macros
diff --git a/legacy/eio/NEWS b/legacy/eio/NEWS
index 1478343f5f..81e59189d8 100644
--- a/legacy/eio/NEWS
+++ b/legacy/eio/NEWS
@@ -13,5 +13,6 @@ Fixes:
13 - Fix segfault when shutting down the Windows monitor. 13 - Fix segfault when shutting down the Windows monitor.
14 14
15Improvements: 15Improvements:
16 - Add log debuggong macros
16 17
17Removal: 18Removal:
diff --git a/legacy/eio/src/lib/eio_main.c b/legacy/eio/src/lib/eio_main.c
index 591dcca5f1..e65f75b0da 100644
--- a/legacy/eio/src/lib/eio_main.c
+++ b/legacy/eio/src/lib/eio_main.c
@@ -59,7 +59,8 @@ struct _Eio_Alloc_Pool
59 EIO_MUTEX_TYPE lock; 59 EIO_MUTEX_TYPE lock;
60}; 60};
61 61
62static int _eio_count = 0; 62static int _eio_init_count = 0;
63int _eio_log_dom_global = -1;
63 64
64static Eio_Alloc_Pool progress_pool = { 0, NULL, EIO_MUTEX_INITIALIZER }; 65static Eio_Alloc_Pool progress_pool = { 0, NULL, EIO_MUTEX_INITIALIZER };
65static Eio_Alloc_Pool direct_info_pool = { 0, NULL, EIO_MUTEX_INITIALIZER }; 66static Eio_Alloc_Pool direct_info_pool = { 0, NULL, EIO_MUTEX_INITIALIZER };
@@ -211,12 +212,27 @@ eio_associate_free(void *data)
211EAPI int 212EAPI int
212eio_init(void) 213eio_init(void)
213{ 214{
214 _eio_count++; 215 if (++_eio_init_count != 1)
216 return _eio_init_count;
215 217
216 if (_eio_count > 1) return _eio_count; 218 if (!eina_init())
219 {
220 fprintf(stderr, "Eio can not initialize Eina\n");
221 return --_eio_init_count;
222 }
217 223
218 eina_init(); 224 _eio_log_dom_global = eina_log_domain_register("eio", EIO_DEFAULT_LOG_COLOR);
219 ecore_init(); 225 if (_eio_log_dom_global < 0)
226 {
227 EINA_LOG_ERR("Eio can not create a general log domain.");
228 goto shutdown_eina;
229 }
230
231 if (!ecore_init())
232 {
233 ERR("Can not initialize Eina\n");
234 goto unregister_log_domain;
235 }
220 236
221 EIO_MUTEX_INIT(progress_pool); 237 EIO_MUTEX_INIT(progress_pool);
222 EIO_MUTEX_INIT(direct_info_pool); 238 EIO_MUTEX_INIT(direct_info_pool);
@@ -225,7 +241,14 @@ eio_init(void)
225 241
226 eio_monitor_init(); 242 eio_monitor_init();
227 243
228 return _eio_count; 244 return _eio_init_count;
245
246unregister_log_domain:
247 eina_log_domain_unregister(_eio_log_dom_global);
248 _eio_log_dom_global = -1;
249shutdown_eina:
250 eina_shutdown();
251 return --_eio_init_count;
229} 252}
230 253
231EAPI int 254EAPI int
@@ -236,14 +259,13 @@ eio_shutdown(void)
236 Eio_Progress *pg; 259 Eio_Progress *pg;
237 Eio_File_Associate *asso; 260 Eio_File_Associate *asso;
238 261
239 if (_eio_count <= 0) 262 if (_eio_init_count <= 0)
240 { 263 {
241 EINA_LOG_ERR("Init count not greater than 0 in shutdown."); 264 ERR("Init count not greater than 0 in shutdown.");
242 return 0; 265 return 0;
243 } 266 }
244 _eio_count--; 267 if (--_eio_init_count != 0)
245 268 return _eio_init_count;
246 if (_eio_count > 0) return _eio_count;
247 269
248 eio_monitor_shutdown(); 270 eio_monitor_shutdown();
249 271
@@ -270,6 +292,9 @@ eio_shutdown(void)
270 associate_pool.count = 0; 292 associate_pool.count = 0;
271 293
272 ecore_shutdown(); 294 ecore_shutdown();
295 eina_log_domain_unregister(_eio_log_dom_global);
296 _eio_log_dom_global = -1;
273 eina_shutdown(); 297 eina_shutdown();
274 return _eio_count; 298
299 return _eio_init_count;
275} 300}
diff --git a/legacy/eio/src/lib/eio_monitor_win32.c b/legacy/eio/src/lib/eio_monitor_win32.c
index 33556b5947..910a59a19b 100644
--- a/legacy/eio/src/lib/eio_monitor_win32.c
+++ b/legacy/eio/src/lib/eio_monitor_win32.c
@@ -210,8 +210,15 @@ _eio_monitor_win32_watcher_new(Eio_Monitor *monitor, unsigned char is_dir)
210 &w->overlapped, 210 &w->overlapped,
211 NULL)) 211 NULL))
212 { 212 {
213 printf("error : %s\n", evil_last_error_get()); 213 char *msg;
214 goto close_event; 214
215 msg = evil_last_error_get();
216 if (msg)
217 {
218 ERR("%s\n", msg);
219 free(msg);
220 }
221 goto close_event;
215 } 222 }
216 223
217 w->h = ecore_main_win32_handler_add(w->event, 224 w->h = ecore_main_win32_handler_add(w->event,
@@ -280,6 +287,7 @@ void eio_monitor_backend_add(Eio_Monitor *monitor)
280 backend->file = _eio_monitor_win32_watcher_new(monitor, 0); 287 backend->file = _eio_monitor_win32_watcher_new(monitor, 0);
281 if (!backend->file) 288 if (!backend->file)
282 { 289 {
290 INF("falling back to poll monitoring");
283 free(backend); 291 free(backend);
284 eio_monitor_fallback_add(monitor); 292 eio_monitor_fallback_add(monitor);
285 return; 293 return;
@@ -288,6 +296,7 @@ void eio_monitor_backend_add(Eio_Monitor *monitor)
288 backend->dir = _eio_monitor_win32_watcher_new(monitor, 1); 296 backend->dir = _eio_monitor_win32_watcher_new(monitor, 1);
289 if (!backend->dir) 297 if (!backend->dir)
290 { 298 {
299 INF("falling back to poll monitoring");
291 _eio_monitor_win32_watcher_free(backend->file); 300 _eio_monitor_win32_watcher_free(backend->file);
292 free(backend); 301 free(backend);
293 eio_monitor_fallback_add(monitor); 302 eio_monitor_fallback_add(monitor);
diff --git a/legacy/eio/src/lib/eio_private.h b/legacy/eio/src/lib/eio_private.h
index 0802aba2df..aab69dc2f2 100644
--- a/legacy/eio/src/lib/eio_private.h
+++ b/legacy/eio/src/lib/eio_private.h
@@ -91,6 +91,33 @@ typedef struct stat _eio_stat_t;
91 91
92#define EIO_PACKED_TIME 0.003 92#define EIO_PACKED_TIME 0.003
93 93
94extern int _eio_log_dom_global;
95
96#ifdef EIO_DEFAULT_LOG_COLOR
97# undef EIO_DEFAULT_LOG_COLOR
98#endif /* ifdef EIO_DEFAULT_LOG_COLOR */
99#define EIO_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
100#ifdef ERR
101# undef ERR
102#endif /* ifdef ERR */
103#define ERR(...) EINA_LOG_DOM_ERR(_eio_log_dom_global, __VA_ARGS__)
104#ifdef DBG
105# undef DBG
106#endif /* ifdef DBG */
107#define DBG(...) EINA_LOG_DOM_DBG(_eio_log_dom_global, __VA_ARGS__)
108#ifdef INF
109# undef INF
110#endif /* ifdef INF */
111#define INF(...) EINA_LOG_DOM_INFO(_eio_log_dom_global, __VA_ARGS__)
112#ifdef WRN
113# undef WRN
114#endif /* ifdef WRN */
115#define WRN(...) EINA_LOG_DOM_WARN(_eio_log_dom_global, __VA_ARGS__)
116#ifdef CRIT
117# undef CRIT
118#endif /* ifdef CRIT */
119#define CRIT(...) EINA_LOG_DOM_CRIT(_eio_log_dom_global, __VA_ARGS__)
120
94typedef struct _Eio_Eet_Open Eio_Eet_Open; 121typedef struct _Eio_Eet_Open Eio_Eet_Open;
95typedef struct _Eio_Eet_Simple Eio_Eet_Simple; 122typedef struct _Eio_Eet_Simple Eio_Eet_Simple;
96typedef struct _Eio_Eet_Write Eio_Eet_Write; 123typedef struct _Eio_Eet_Write Eio_Eet_Write;