eina - fix eina_strndup test passing

This commit is contained in:
Carsten Haitzler 2020-01-15 19:23:44 +00:00
parent eb72593bbc
commit ee6cc91a03
3 changed files with 31 additions and 6 deletions

View File

@ -18,6 +18,7 @@ static Ecore_Event_Handler *hnd_add = NULL;
static Ecore_Event_Handler *hnd_del = NULL;
static Ecore_Event_Handler *hnd_data = NULL;
static int clients = 0;
static Ecore_Timer *quit_timer_start = NULL;
static Ecore_Timer *quit_timer = NULL;
static Eina_Bool
@ -28,6 +29,15 @@ _cb_quit_timer(void *data EINA_UNUSED)
return EINA_FALSE;
}
static Eina_Bool
_cb_quit_timer_start(void *data EINA_UNUSED)
{
quit_timer_start = NULL;
if (quit_timer) ecore_timer_del(quit_timer);
quit_timer = ecore_timer_add(10.0, _cb_quit_timer, NULL);
return EINA_FALSE;
}
static void
_broadcast(Ecore_Ipc_Server *svr, int major, int minor, void *data, int size)
{
@ -101,6 +111,11 @@ _cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
ecore_timer_del(quit_timer);
quit_timer = NULL;
}
if (quit_timer_start)
{
ecore_timer_del(quit_timer_start);
quit_timer_start = NULL;
}
clients++;
return ECORE_CALLBACK_DONE;
}
@ -211,7 +226,7 @@ ipc_init(void)
ecore_ipc_shutdown();
return EINA_FALSE;
}
quit_timer = ecore_timer_add(2.0, _cb_quit_timer, NULL);
quit_timer_start = ecore_timer_add(10.0, _cb_quit_timer_start, NULL);
hnd_add = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
_cb_client_add, NULL);
hnd_del = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
@ -228,6 +243,10 @@ ipc_shutdown(void)
if (init <= 0) return EINA_TRUE;
init--;
if (init > 0) return EINA_TRUE;
if (quit_timer) ecore_timer_del(quit_timer);
if (quit_timer_start) ecore_timer_del(quit_timer_start);
quit_timer = NULL;
quit_timer_start = NULL;
ecore_ipc_server_del(ipc);
ecore_event_handler_del(hnd_add);
ecore_event_handler_del(hnd_del);

View File

@ -117,7 +117,7 @@ _ipc_launch(void)
char buf[PATH_MAX];
int num;
int try_gap = 10000; // 10ms
int tries = 200; // 200 * 10ms == 2sec
int tries = 1000; // 1000 * 10ms == 10sec
const char *s;
s = getenv("EFREETD_CONNECT_TRIES");

View File

@ -96,13 +96,19 @@ eina_strndup(const char *str, size_t n)
{
char *ret;
const char *p;
size_t slen;
size_t slen = 0;
if (!str)
return NULL;
for (p = str; (*p) && ((size_t)(p - str) < n); p++)
slen = (size_t)(p - str);
for (p = str; *p; p++)
{
slen = (size_t)(p - str) + 1;
if (slen > n)
{
slen = n;
break;
}
}
ret = (char *)malloc(slen + 1); /* cast for C++ code */
if (!ret)
return NULL;