summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-22 14:55:55 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-22 14:57:15 -0700
commit17507bab43e18b3a29fb045302de6c4f88fef594 (patch)
treea160705cc8f5366d32d099fbe00d16eb4a7c72fd
parent6232fa2a9bad08cdd5ec249b2a5624e0051c9480 (diff)
downloadefl-17507bab43e18b3a29fb045302de6c4f88fef594.tar.gz
ecore: force initialization of Efl.Io.Closer.Fd.
This will prevent closing magically fd 0 when the object is not initialized yet.
-rw-r--r--src/lib/ecore/efl_io_closer_fd.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib/ecore/efl_io_closer_fd.c b/src/lib/ecore/efl_io_closer_fd.c
index 42724e0646..e55de422af 100644
--- a/src/lib/ecore/efl_io_closer_fd.c
+++ b/src/lib/ecore/efl_io_closer_fd.c
@@ -13,28 +13,43 @@
typedef struct _Efl_Io_Closer_Fd_Data
{
int fd;
+
Eina_Bool close_on_exec;
Eina_Bool close_on_destructor;
+ Eina_Bool initialized;
} Efl_Io_Closer_Fd_Data;
+static void
+_efl_io_closer_initialize(Efl_Io_Closer_Fd_Data *pd)
+{
+ if (pd->initialized) return ;
+ pd->fd = -1;
+ pd->initialized = EINA_TRUE;
+}
+
EOLIAN static void
_efl_io_closer_fd_closer_fd_set(Eo *o EINA_UNUSED, Efl_Io_Closer_Fd_Data *pd, int fd)
{
+ _efl_io_closer_initialize(pd);
pd->fd = fd;
}
EOLIAN static int
_efl_io_closer_fd_closer_fd_get(Eo *o EINA_UNUSED, Efl_Io_Closer_Fd_Data *pd)
{
+ _efl_io_closer_initialize(pd);
return pd->fd;
}
EOLIAN static Eina_Error
_efl_io_closer_fd_efl_io_closer_close(Eo *o, Efl_Io_Closer_Fd_Data *pd EINA_UNUSED)
{
- int fd = efl_io_closer_fd_get(o);
+ int fd;
Eina_Error err = 0;
+ _efl_io_closer_initialize(pd);
+ fd = efl_io_closer_fd_get(o);
+
EINA_SAFETY_ON_TRUE_RETURN_VAL(fd < 0, EBADF);
efl_io_closer_fd_set(o, -1);
@@ -46,12 +61,15 @@ _efl_io_closer_fd_efl_io_closer_close(Eo *o, Efl_Io_Closer_Fd_Data *pd EINA_UNUS
EOLIAN static Eina_Bool
_efl_io_closer_fd_efl_io_closer_closed_get(Eo *o, Efl_Io_Closer_Fd_Data *pd EINA_UNUSED)
{
+ _efl_io_closer_initialize(pd);
return efl_io_closer_fd_get(o) < 0;
}
EOLIAN static Eina_Bool
_efl_io_closer_fd_efl_io_closer_close_on_exec_set(Eo *o, Efl_Io_Closer_Fd_Data *pd, Eina_Bool close_on_exec)
{
+ _efl_io_closer_initialize(pd);
+
#ifdef _WIN32
DBG("close on exec is not supported on windows");
pd->close_on_exec = close_on_exec;
@@ -83,6 +101,8 @@ _efl_io_closer_fd_efl_io_closer_close_on_exec_set(Eo *o, Efl_Io_Closer_Fd_Data *
EOLIAN static Eina_Bool
_efl_io_closer_fd_efl_io_closer_close_on_exec_get(Eo *o, Efl_Io_Closer_Fd_Data *pd)
{
+ _efl_io_closer_initialize(pd);
+
#ifdef _WIN32
return pd->close_on_exec;
(void)o;
@@ -110,12 +130,14 @@ _efl_io_closer_fd_efl_io_closer_close_on_exec_get(Eo *o, Efl_Io_Closer_Fd_Data *
EOLIAN static void
_efl_io_closer_fd_efl_io_closer_close_on_destructor_set(Eo *o EINA_UNUSED, Efl_Io_Closer_Fd_Data *pd, Eina_Bool close_on_destructor)
{
+ _efl_io_closer_initialize(pd);
pd->close_on_destructor = close_on_destructor;
}
EOLIAN static Eina_Bool
_efl_io_closer_fd_efl_io_closer_close_on_destructor_get(Eo *o EINA_UNUSED, Efl_Io_Closer_Fd_Data *pd)
{
+ _efl_io_closer_initialize(pd);
return pd->close_on_destructor;
}