const void *data;
Ecore_Pipe_Cb handler;
unsigned int len;
+ int handling;
size_t already_read;
void *passed_data;
+ Eina_Bool delete_me : 1;
};
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del");
return NULL;
}
+ p->delete_me = EINA_TRUE;
+ if (p->handling > 0) return (void *)p->data;
if (p->fd_handler) ecore_main_fd_handler_del(p->fd_handler);
if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read);
if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write);
}
/* Private function */
+static void
+_ecore_pipe_unhandle(Ecore_Pipe *p)
+{
+ p->handling--;
+ if (p->delete_me)
+ {
+ ecore_pipe_del(p);
+ }
+}
static Eina_Bool
_ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
{
Ecore_Pipe *p;
double start_time;
+ int i;
p = (Ecore_Pipe *)data;
start_time = ecore_time_get();
-
- do
+
+ p->handling++;
+ for (i = 0; i < 16; i++)
{
ssize_t ret;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
#ifndef _WIN32
ERR("An unhandled error (ret: %zd errno: %d [%s])"
"occurred while reading from the pipe the length",
ret, errno, strerror(errno));
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
#else
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
}
else if (ret >= 0)
{
p->already_read += ret;
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else if (ret == 0)
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
#ifndef _WIN32
ERR("An unhandled error (ret: %zd errno: %d)"
"occurred while reading from the pipe the data",
ret, errno);
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
#else
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else
}
#endif
}
- while (ecore_time_get() - start_time < ecore_animator_frametime_get());
+ _ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}