ecore_evas_extn: Fix socket & plug windows

Socket & Plug were broken after 38e6780262.
Multiple problems here:
 - The invalid path was used for the lock file.
 - The invalid buffer ID was used for unlock in render_post. That's
   because the buffer was switched during output_flush which happens
   before render_post. So the buffer would remain locked forever on the
   server side (unless maybe some animation was happening there).

@fix
This commit is contained in:
Jean-Philippe Andre 2017-08-18 14:53:20 +09:00
parent a21f25b0eb
commit a43740c074
2 changed files with 11 additions and 9 deletions

View File

@ -56,6 +56,7 @@ struct _Extn
Eina_Bool alpha : 1; Eina_Bool alpha : 1;
} b[NBUF]; } b[NBUF];
int cur_b; // current buffer (b) being displayed or rendered to int cur_b; // current buffer (b) being displayed or rendered to
int prev_b; // the last buffer (b) that was rendered
struct { struct {
Eina_Bool done : 1; /* need to send change done event to the client(plug) */ Eina_Bool done : 1; /* need to send change done event to the client(plug) */
} profile; } profile;
@ -1499,6 +1500,7 @@ _ecore_evas_socket_switch(void *data, void *dest_buf EINA_UNUSED)
Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data; Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
Extn *extn = bdata->data; Extn *extn = bdata->data;
extn->prev_b = extn->cur_b;
extn->cur_b++; extn->cur_b++;
if (extn->cur_b >= NBUF) extn->cur_b = 0; if (extn->cur_b >= NBUF) extn->cur_b = 0;
bdata->pixels = _extnbuf_data_get(extn->b[extn->cur_b].buf, bdata->pixels = _extnbuf_data_get(extn->b[extn->cur_b].buf,
@ -1535,10 +1537,10 @@ _ecore_evas_ews_update_image(void *data, Evas *e EINA_UNUSED, void *event_info)
Ecore_Ipc_Client *client; Ecore_Ipc_Client *client;
Eina_Rectangle *r; Eina_Rectangle *r;
Eina_List *l; Eina_List *l;
int cur_b; int prev_b;
cur_b = extn->cur_b; prev_b = extn->prev_b;
_extnbuf_unlock(extn->b[cur_b].buf); _extnbuf_unlock(extn->b[prev_b].buf);
EINA_LIST_FOREACH(post->updated_area, l, r) EINA_LIST_FOREACH(post->updated_area, l, r)
{ {
@ -1556,7 +1558,7 @@ _ecore_evas_ews_update_image(void *data, Evas *e EINA_UNUSED, void *event_info)
EINA_LIST_FOREACH(extn->ipc.clients, l, client) EINA_LIST_FOREACH(extn->ipc.clients, l, client)
ecore_ipc_client_send(client, MAJOR, OP_UPDATE_DONE, 0, 0, ecore_ipc_client_send(client, MAJOR, OP_UPDATE_DONE, 0, 0,
cur_b, NULL, 0); prev_b, NULL, 0);
if (extn->profile.done) if (extn->profile.done)
{ {
_ecore_evas_extn_socket_window_profile_change_done_send(ee); _ecore_evas_extn_socket_window_profile_change_done_send(ee);
@ -1606,8 +1608,7 @@ _ipc_client_add(void *data, int type EINA_UNUSED, void *event)
ipc2.x = 0; ipc2.y = 0; ipc2.w = ee->w; ipc2.h = ee->h; ipc2.x = 0; ipc2.y = 0; ipc2.w = ee->w; ipc2.h = ee->h;
ecore_ipc_client_send(e->client, MAJOR, OP_UPDATE, 0, 0, 0, &ipc2, ecore_ipc_client_send(e->client, MAJOR, OP_UPDATE, 0, 0, 0, &ipc2,
sizeof(ipc2)); sizeof(ipc2));
prev_b = extn->cur_b - 1; prev_b = extn->prev_b;
if (prev_b < 0) prev_b = NBUF - 1;
ecore_ipc_client_send(e->client, MAJOR, OP_UPDATE_DONE, 0, 0, ecore_ipc_client_send(e->client, MAJOR, OP_UPDATE_DONE, 0, 0,
prev_b, NULL, 0); prev_b, NULL, 0);
_ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_ADD); _ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_ADD);

View File

@ -55,7 +55,7 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
{ {
b->lockfd = eina_file_mkstemp("ee-lock-XXXXXX", &tmp); b->lockfd = eina_file_mkstemp("ee-lock-XXXXXX", &tmp);
if (b->lockfd < 0) goto err; if (b->lockfd < 0) goto err;
b->lock = eina_stringshare_add(file); b->lock = eina_stringshare_add(tmp);
if (!b->lock) goto err; if (!b->lock) goto err;
b->fd = shm_open(b->file, O_RDWR | O_CREAT | O_EXCL, mode); b->fd = shm_open(b->file, O_RDWR | O_CREAT | O_EXCL, mode);
if (b->fd < 0) goto err; if (b->fd < 0) goto err;
@ -68,9 +68,10 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
} }
b->addr = mmap(NULL, b->size, prot, MAP_SHARED, b->fd, 0); b->addr = mmap(NULL, b->size, prot, MAP_SHARED, b->fd, 0);
if (b->addr == MAP_FAILED) goto err; if (b->addr == MAP_FAILED) goto err;
eina_tmpstr_del(tmp);
return b; return b;
err: err:
if (tmp) eina_tmpstr_del(tmp); eina_tmpstr_del(tmp);
_extnbuf_free(b); _extnbuf_free(b);
return NULL; return NULL;
} }
@ -129,7 +130,7 @@ _extnbuf_lock(Extnbuf *b, int *w, int *h, int *stride)
filelock.l_whence = SEEK_SET; filelock.l_whence = SEEK_SET;
filelock.l_start = 0; filelock.l_start = 0;
filelock.l_len = 0; filelock.l_len = 0;
if (fcntl(b->lockfd, F_SETLKW, &filelock) == -1) if (fcntl(b->lockfd, F_SETLK, &filelock) == -1)
{ {
ERR("lock take fail"); ERR("lock take fail");
return NULL; return NULL;