summaryrefslogtreecommitdiff
path: root/src/bin/ethumb_client/ethumbd.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-28 11:07:30 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-28 11:07:30 +0900
commitb4411c90bf4ce72f589d3614238132cddf12702c (patch)
tree78d7d42defd8c4bdaa469eb076f0ca519d43c184 /src/bin/ethumb_client/ethumbd.c
parent332a54d1c6fdbf77e56bc45a69ced91c36f6af1a (diff)
ethumbd - if thumb gen takes too long don't just quit ethumbd, but skip thumb
Diffstat (limited to '')
-rw-r--r--src/bin/ethumb_client/ethumbd.c64
1 files changed, 54 insertions, 10 deletions
diff --git a/src/bin/ethumb_client/ethumbd.c b/src/bin/ethumb_client/ethumbd.c
index a57ee3dabf..e99225278e 100644
--- a/src/bin/ethumb_client/ethumbd.c
+++ b/src/bin/ethumb_client/ethumbd.c
@@ -166,6 +166,7 @@ struct _Ethumbd
166 Ethumbd_Queue queue; 166 Ethumbd_Queue queue;
167 double timeout; 167 double timeout;
168 Ecore_Timer *timeout_timer; 168 Ecore_Timer *timeout_timer;
169 Ecore_Timer *hang_timer;
169 Ethumbd_Slave slave; 170 Ethumbd_Slave slave;
170 171
171 Ecore_Event_Handler *data_cb; 172 Ecore_Event_Handler *data_cb;
@@ -248,19 +249,16 @@ static Eina_Bool
248_ethumbd_timeout_cb(void *data) 249_ethumbd_timeout_cb(void *data)
249{ 250{
250 Ethumbd *ed = data; 251 Ethumbd *ed = data;
251 252
252 ecore_main_loop_quit(); 253 ecore_main_loop_quit();
253 ed->timeout_timer = NULL; 254 ed->timeout_timer = NULL;
254 255 return EINA_FALSE;
255 return 0;
256} 256}
257 257
258static void 258static void
259_ethumbd_timeout_start(Ethumbd *ed) 259_ethumbd_timeout_start(Ethumbd *ed)
260{ 260{
261 if (ed->timeout < 0) 261 if (ed->timeout < 0) return;
262 return;
263
264 if (!ed->timeout_timer) 262 if (!ed->timeout_timer)
265 ed->timeout_timer = ecore_timer_add(ed->timeout, _ethumbd_timeout_cb, ed); 263 ed->timeout_timer = ecore_timer_add(ed->timeout, _ethumbd_timeout_cb, ed);
266} 264}
@@ -268,9 +266,7 @@ _ethumbd_timeout_start(Ethumbd *ed)
268static void 266static void
269_ethumbd_timeout_stop(Ethumbd *ed) 267_ethumbd_timeout_stop(Ethumbd *ed)
270{ 268{
271 if (!ed->timeout_timer) 269 if (!ed->timeout_timer) return;
272 return;
273
274 ecore_timer_del(ed->timeout_timer); 270 ecore_timer_del(ed->timeout_timer);
275 ed->timeout_timer = NULL; 271 ed->timeout_timer = NULL;
276} 272}
@@ -278,11 +274,54 @@ _ethumbd_timeout_stop(Ethumbd *ed)
278static void 274static void
279_ethumbd_timeout_redo(Ethumbd *ed) 275_ethumbd_timeout_redo(Ethumbd *ed)
280{ 276{
281 //if (!ed->queue.count)
282 _ethumbd_timeout_stop(ed); 277 _ethumbd_timeout_stop(ed);
283 _ethumbd_timeout_start(ed); 278 _ethumbd_timeout_start(ed);
284} 279}
285 280
281static Eina_Bool
282_ethumbd_hang_cb(void *data)
283{
284 Ethumbd *ed = data;
285
286 ed->hang_timer = NULL;
287 if (ed->processing)
288 {
289 ERR("timout while processing thumb");
290 if (ed->slave.exe) ecore_exe_kill(ed->slave.exe);
291 }
292 return EINA_FALSE;
293}
294
295static void
296_ethumbd_hang_start(Ethumbd *ed)
297{
298 double tim = ed->timeout;
299
300 if (tim < 0) tim = 10.0;
301 else
302 {
303 tim = tim / 3.0;
304 if (tim > 10.0) tim = 10.0;
305 }
306 if (!ed->hang_timer)
307 ed->hang_timer = ecore_timer_add(tim, _ethumbd_hang_cb, ed);
308}
309
310static void
311_ethumbd_hang_stop(Ethumbd *ed)
312{
313 if (!ed->hang_timer) return;
314 ecore_timer_del(ed->hang_timer);
315 ed->hang_timer = NULL;
316}
317
318static void
319_ethumbd_hang_redo(Ethumbd *ed)
320{
321 _ethumbd_hang_stop(ed);
322 _ethumbd_hang_start(ed);
323}
324
286static int 325static int
287_ethumb_dbus_check_id(Ethumbd_Object *eobject, int id) 326_ethumb_dbus_check_id(Ethumbd_Object *eobject, int id)
288{ 327{
@@ -408,6 +447,7 @@ _generated_cb(Ethumbd *ed, Eina_Bool success, const char *thumb_path, const char
408 free(ed->processing); 447 free(ed->processing);
409 ed->processing = NULL; 448 ed->processing = NULL;
410 _ethumbd_timeout_redo(ed); 449 _ethumbd_timeout_redo(ed);
450 _ethumbd_hang_stop(ed);
411} 451}
412 452
413static void 453static void
@@ -525,6 +565,8 @@ _ethumbd_slave_del_cb(void *data, int type EINA_UNUSED, void *event)
525 if (ev->exe != ed->slave.exe) 565 if (ev->exe != ed->slave.exe)
526 return 1; 566 return 1;
527 567
568 _ethumbd_hang_stop(ed);
569
528 if (ev->exited) 570 if (ev->exited)
529 ERR("slave exited with code: %d", ev->exit_code); 571 ERR("slave exited with code: %d", ev->exit_code);
530 else if (ev->signalled) 572 else if (ev->signalled)
@@ -682,6 +724,7 @@ _process_setup(Ethumbd *ed)
682static void 724static void
683_process_file(Ethumbd *ed) 725_process_file(Ethumbd *ed)
684{ 726{
727 _ethumbd_hang_redo(ed);
685 _ethumbd_child_write_op_generate 728 _ethumbd_child_write_op_generate
686 (&ed->slave, ed->queue.current, ed->processing->file, 729 (&ed->slave, ed->queue.current, ed->processing->file,
687 ed->processing->key, ed->processing->thumb, ed->processing->thumb_key); 730 ed->processing->key, ed->processing->thumb, ed->processing->thumb_key);
@@ -961,6 +1004,7 @@ _ethumb_dbus_ethumb_new_cb(const Eldbus_Service_Interface *interface, const Eldb
961 EINA_TRUE); 1004 EINA_TRUE);
962 _ethumbd_child_write_op_new(&ed->slave, i); 1005 _ethumbd_child_write_op_new(&ed->slave, i);
963 _ethumbd_timeout_redo(ed); 1006 _ethumbd_timeout_redo(ed);
1007 _ethumbd_hang_redo(ed);
964 1008
965 end_new: 1009 end_new:
966 reply = eldbus_message_method_return_new(msg); 1010 reply = eldbus_message_method_return_new(msg);