summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-08-17 12:14:32 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-08-17 12:14:32 +0000
commit392d5d039bf2ec343c50db8f7660f30640ccd7a1 (patch)
tree36ce2e994414b31a0942f6025d663b2545993feb
parent7b24900c4ae17f899f53300b2162cdeca3962101 (diff)
add 1.0s delay between database reconnect attempts
SVN revision: 75389
-rw-r--r--src/lib/esql_events.c11
-rw-r--r--src/lib/esql_private.h3
2 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/esql_events.c b/src/lib/esql_events.c
index 52d7675..bd2ffde 100644
--- a/src/lib/esql_events.c
+++ b/src/lib/esql_events.c
@@ -183,13 +183,14 @@ out:
183 esql_next(e); 183 esql_next(e);
184} 184}
185 185
186void 186Eina_Bool
187esql_reconnect_handler(Esql *e) 187esql_reconnect_handler(Esql *e)
188{ 188{
189 Esql *ev; 189 Esql *ev;
190 int ret, fd; 190 int ret, fd;
191 191
192 ev = e->pool_member ? (Esql *)e->pool_struct : e; /* use pool struct for events */ 192 ev = e->pool_member ? (Esql *)e->pool_struct : e; /* use pool struct for events */
193 e->reconnect_timer = NULL;
193 ret = e->backend.connect(e); 194 ret = e->backend.connect(e);
194 EINA_SAFETY_ON_NULL_GOTO(e->backend.db, error); 195 EINA_SAFETY_ON_NULL_GOTO(e->backend.db, error);
195 if (ret == ECORE_FD_ERROR) 196 if (ret == ECORE_FD_ERROR)
@@ -205,10 +206,11 @@ esql_reconnect_handler(Esql *e)
205 e->current = ESQL_CONNECT_TYPE_INIT; 206 e->current = ESQL_CONNECT_TYPE_INIT;
206 if (ev->database) esql_database_set(e, ev->database); 207 if (ev->database) esql_database_set(e, ev->database);
207 } 208 }
208 return; 209 return EINA_FALSE;
209error: 210error:
210 ecore_event_add(ESQL_EVENT_DISCONNECT, ev, (Ecore_End_Cb)esql_fake_free, NULL); 211 ecore_event_add(ESQL_EVENT_DISCONNECT, ev, (Ecore_End_Cb)esql_fake_free, NULL);
211 e->event_count++; 212 e->event_count++;
213 return EINA_FALSE;
212} 214}
213 215
214void 216void
@@ -274,8 +276,7 @@ esql_event_error(Esql *e)
274 e->event_count++; 276 e->event_count++;
275 277
276 esql_disconnect(e); 278 esql_disconnect(e);
277 if (e->reconnect) esql_reconnect_handler(e); 279 if (e->reconnect) e->reconnect_timer = ecore_timer_add(1.0, (Ecore_Task_Cb)esql_reconnect_handler, e);
278 return;
279} 280}
280 281
281Eina_Bool 282Eina_Bool
@@ -325,6 +326,6 @@ esql_timeout_cb(Esql *e)
325{ 326{
326 e->timeout_timer = NULL; 327 e->timeout_timer = NULL;
327 esql_disconnect(e); 328 esql_disconnect(e);
328 if (e->reconnect) esql_reconnect_handler(e); 329 if (e->reconnect) e->reconnect_timer = ecore_timer_add(1.0, (Ecore_Task_Cb)esql_reconnect_handler, e);
329 return EINA_FALSE; 330 return EINA_FALSE;
330} 331}
diff --git a/src/lib/esql_private.h b/src/lib/esql_private.h
index 2e7a703..ce9e44a 100644
--- a/src/lib/esql_private.h
+++ b/src/lib/esql_private.h
@@ -164,6 +164,7 @@ struct Esql
164 Ecore_Fd_Handler *fdh; 164 Ecore_Fd_Handler *fdh;
165 Esql_Res *res; /* current working result */ 165 Esql_Res *res; /* current working result */
166 Ecore_Timer *timeout_timer; 166 Ecore_Timer *timeout_timer;
167 Ecore_Timer *reconnect_timer;
167 168
168 Esql_Connect_Type current; 169 Esql_Connect_Type current;
169 double query_start; 170 double query_start;
@@ -231,7 +232,7 @@ Eina_Bool esql_pool_type_set(Esql_Pool *ep, Esql_Type type);
231void esql_pool_connect_timeout_set(Esql_Pool *ep, double timeout); 232void esql_pool_connect_timeout_set(Esql_Pool *ep, double timeout);
232void esql_pool_reconnect_set(Esql_Pool *ep, Eina_Bool enable); 233void esql_pool_reconnect_set(Esql_Pool *ep, Eina_Bool enable);
233void esql_pool_free(Esql_Pool *ep); 234void esql_pool_free(Esql_Pool *ep);
234void esql_reconnect_handler(Esql *e); 235Eina_Bool esql_reconnect_handler(Esql *e);
235 236
236EAPI void esql_event_error(Esql *e); 237EAPI void esql_event_error(Esql *e);
237EAPI void esql_call_complete(Esql *e); 238EAPI void esql_call_complete(Esql *e);