aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_wayland
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2016-11-18 19:53:14 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-18 19:53:15 +0900
commit3a98ee3796d7fe4bc70be99fc928dd3d89eddc4a (patch)
treec32bf390a7ee9fdf2aff8f7d2aeefe0afef7755d /src/lib/ecore_wayland
parentevas map redraw update handling - dont trigger full redraw in e menus (diff)
downloadefl-3a98ee3796d7fe4bc70be99fc928dd3d89eddc4a.tar.gz
ecore_wayland: fix over writing file descriptor bug for reading
Summary: fix over writing file descriptor bug for reading. when we paste data to entry very fast, source->fd is over wrote by latest fd. It cause blocking of read function since the read function use invalid fd. so I make memorizing valid fd and using it in read function. @fix Reviewers: Hermet, jpeg, cedric, devilhorns, ManMower, raster Differential Revision: https://phab.enlightenment.org/D4410
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r--src/lib/ecore_wayland/ecore_wl_dnd.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_dnd.c b/src/lib/ecore_wayland/ecore_wl_dnd.c
index c286624d63..f40eaf7e68 100644
--- a/src/lib/ecore_wayland/ecore_wl_dnd.c
+++ b/src/lib/ecore_wayland/ecore_wl_dnd.c
@@ -31,6 +31,12 @@
#include "ecore_wl_private.h"
/* local structures */
+struct _dnd_source
+{
+ Ecore_Wl_Dnd_Source *source;
+ int read_fd;
+};
+
struct _dnd_task
{
void *data;
@@ -615,6 +621,7 @@ _ecore_wl_dnd_selection_data_receive(Ecore_Wl_Dnd_Source *source, const char *ty
struct epoll_event *ep = NULL;
struct _dnd_task *task = NULL;
struct _dnd_read_ctx *read_ctx = NULL;
+ struct _dnd_source *read_source = NULL;
int p[2];
LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -640,7 +647,12 @@ _ecore_wl_dnd_selection_data_receive(Ecore_Wl_Dnd_Source *source, const char *ty
epoll_fd = epoll_create1(0);
if (epoll_fd < 0) goto err;
- task->data = source;
+ read_source = calloc(1, sizeof(struct _dnd_source));
+ if (!read_source) goto err;
+
+ read_source = source;
+ read_source->read_fd = p[0];
+ task->data = read_source;
task->cb = _ecore_wl_dnd_selection_data_read;
ep->events = EPOLLIN;
ep->data.ptr = task;
@@ -653,7 +665,6 @@ _ecore_wl_dnd_selection_data_receive(Ecore_Wl_Dnd_Source *source, const char *ty
if (!ecore_idler_add(_ecore_wl_dnd_selection_cb_idle, read_ctx)) goto err;
source->refcount++;
- source->fd = p[0];
return;
@@ -661,6 +672,7 @@ err:
if (ep) free(ep);
if (task) free(task);
if (read_ctx) free(read_ctx);
+ if (read_source) free(read_source);
close(p[0]);
return;
}
@@ -671,21 +683,23 @@ _ecore_wl_dnd_selection_data_read(void *data, Ecore_Fd_Handler *fd_handler EINA_
int len;
char buffer[PATH_MAX];
Ecore_Wl_Dnd_Source *source;
+ struct _dnd_source *read_source;
Ecore_Wl_Event_Selection_Data_Ready *event;
Eina_Bool ret;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
- source = data;
+ read_source = data;
+ source = read_source->source;
- len = read(source->fd, buffer, sizeof buffer);
+ len = read(read_source->read_fd, buffer, sizeof buffer);
if (!(event = calloc(1, sizeof(Ecore_Wl_Event_Selection_Data_Ready))))
return ECORE_CALLBACK_CANCEL;
if (len <= 0)
{
- close(source->fd);
+ close(read_source->read_fd);
_ecore_wl_dnd_del(source);
event->done = EINA_TRUE;
event->data = NULL;
@@ -742,6 +756,7 @@ _ecore_wl_dnd_selection_cb_idle(void *data)
if (task->cb(task->data, NULL) == ECORE_CALLBACK_CANCEL)
{
free(ctx->ep);
+ free(task->data);
free(task);
free(ctx);
return ECORE_CALLBACK_CANCEL;