ecore_x_vsync - protect against silly clients asking for vsync lots

this allows a client to ask multiple times and have to release the
same number of times for vsync events to stop. covers possible misuse
This commit is contained in:
Carsten Haitzler 2014-07-31 23:16:40 +09:00
parent c7215e7653
commit 570c1f9692
1 changed files with 14 additions and 14 deletions

View File

@ -125,6 +125,7 @@ _tick_start(void)
static void
_tick_end(void)
{
if (tick <= 0) return;
tick--;
if (tick > 0) return;
_tick_send(0);
@ -135,7 +136,7 @@ _tick_end(void)
typedef struct
{
Ecore_Con_Client *client;
Eina_Bool enabled : 1;
int enabled;
} Clientdata;
static Ecore_Con_Server *svr = NULL;
@ -177,7 +178,11 @@ _svr_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
if (cdat)
{
clients = eina_list_remove(clients, cdat);
if (cdat->enabled) _tick_end();
while (cdat->enabled > 0)
{
_tick_end();
cdat->enabled--;
}
free(cdat);
}
return EINA_FALSE;
@ -192,24 +197,19 @@ _svr_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
if (cdat)
{
char *dat = ev->data;
int i;
if (ev->size > 0)
for (i = 0; i < ev->size; i++)
{
if (dat[ev->size - 1])
if (dat[i])
{
if (!cdat->enabled)
{
_tick_start();
cdat->enabled = EINA_TRUE;
}
cdat->enabled++;
_tick_start();
}
else
{
if (cdat->enabled)
{
_tick_end();
cdat->enabled = EINA_FALSE;
}
cdat->enabled--;
_tick_end();
}
}
}