parent
4a514076ad
commit
26d8a50642
|
@ -59,15 +59,14 @@ struct _Ecore_Pipe
|
||||||
int fd_write;
|
int fd_write;
|
||||||
Ecore_Fd_Handler *fd_handler;
|
Ecore_Fd_Handler *fd_handler;
|
||||||
const void *data;
|
const void *data;
|
||||||
void (*handler) (void *data, void *buffer, unsigned int nbyte);
|
void (*handler) (void *data, void *buffer, unsigned int nbyte);
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
size_t already_read;
|
size_t already_read;
|
||||||
void *passed_data;
|
void *passed_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int _ecore_pipe_read(void *data,
|
static int _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler);
|
||||||
Ecore_Fd_Handler *fd_handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup Ecore_Pipe_Group Pipe wrapper
|
* @defgroup Ecore_Pipe_Group Pipe wrapper
|
||||||
|
@ -289,12 +288,10 @@ ecore_pipe_add(void (*handler) (void *data, void *buffer, unsigned int nbyte),
|
||||||
Ecore_Pipe *p;
|
Ecore_Pipe *p;
|
||||||
int fds[2];
|
int fds[2];
|
||||||
|
|
||||||
if(!handler)
|
if (!handler) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
p = (Ecore_Pipe *)calloc(1, sizeof(Ecore_Pipe));
|
p = (Ecore_Pipe *)calloc(1, sizeof(Ecore_Pipe));
|
||||||
if (!p)
|
if (!p) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (pipe(fds))
|
if (pipe(fds))
|
||||||
{
|
{
|
||||||
|
@ -316,7 +313,6 @@ ecore_pipe_add(void (*handler) (void *data, void *buffer, unsigned int nbyte),
|
||||||
_ecore_pipe_read,
|
_ecore_pipe_read,
|
||||||
p,
|
p,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,18 +330,14 @@ ecore_pipe_del(Ecore_Pipe *p)
|
||||||
|
|
||||||
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
||||||
{
|
{
|
||||||
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
|
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del");
|
||||||
"ecore_pipe_del");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(p->fd_handler != NULL)
|
if (p->fd_handler != NULL) ecore_main_fd_handler_del(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_read != PIPE_FD_INVALID)
|
if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write);
|
||||||
pipe_close(p->fd_read);
|
|
||||||
if(p->fd_write != PIPE_FD_INVALID)
|
|
||||||
pipe_close(p->fd_write);
|
|
||||||
data = (void *)p->data;
|
data = (void *)p->data;
|
||||||
free (p);
|
free(p);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +352,7 @@ ecore_pipe_read_close(Ecore_Pipe *p)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
||||||
{
|
{
|
||||||
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
|
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close");
|
||||||
"ecore_pipe_read_close");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ecore_main_fd_handler_del(p->fd_handler);
|
ecore_main_fd_handler_del(p->fd_handler);
|
||||||
|
@ -381,8 +372,7 @@ ecore_pipe_write_close(Ecore_Pipe *p)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
||||||
{
|
{
|
||||||
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
|
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close");
|
||||||
"ecore_pipe_write_close");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pipe_close(p->fd_write);
|
pipe_close(p->fd_write);
|
||||||
|
@ -407,13 +397,11 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
|
||||||
|
|
||||||
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
|
||||||
{
|
{
|
||||||
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
|
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write");
|
||||||
"ecore_pipe_write");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p->fd_write == PIPE_FD_INVALID)
|
if (p->fd_write == PIPE_FD_INVALID) return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* First write the len into the pipe */
|
/* First write the len into the pipe */
|
||||||
do
|
do
|
||||||
|
@ -428,7 +416,7 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
|
||||||
{
|
{
|
||||||
/* XXX What should we do here? */
|
/* XXX What should we do here? */
|
||||||
fprintf(stderr, "The length of the data was not written complete"
|
fprintf(stderr, "The length of the data was not written complete"
|
||||||
" to the pipe\n");
|
" to the pipe\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else if (ret == PIPE_FD_ERROR && errno == EPIPE)
|
else if (ret == PIPE_FD_ERROR && errno == EPIPE)
|
||||||
|
@ -443,22 +431,21 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
||||||
"occured while writing to the pipe the length\n",
|
"occured while writing to the pipe the length\n",
|
||||||
ret, errno);
|
ret, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (retry--);
|
while (retry--);
|
||||||
|
|
||||||
if (retry != ECORE_PIPE_WRITE_RETRY)
|
if (retry != ECORE_PIPE_WRITE_RETRY) return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* and now pass the data to the pipe */
|
/* and now pass the data to the pipe */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = pipe_write(p->fd_write,
|
ret = pipe_write(p->fd_write,
|
||||||
((unsigned char *)buffer) + already_written,
|
((unsigned char *)buffer) + already_written,
|
||||||
nbytes - already_written);
|
nbytes - already_written);
|
||||||
|
|
||||||
if (ret == (ssize_t)(nbytes - already_written))
|
if (ret == (ssize_t)(nbytes - already_written))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else if (ret >= 0)
|
else if (ret >= 0)
|
||||||
|
@ -478,8 +465,8 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
||||||
"occured while writing to the pipe the length\n",
|
"occured while writing to the pipe the length\n",
|
||||||
ret, errno);
|
ret, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (retry--);
|
while (retry--);
|
||||||
|
@ -517,7 +504,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
||||||
{
|
{
|
||||||
/* XXX What should we do here? */
|
/* XXX What should we do here? */
|
||||||
fprintf(stderr, "Only read %d bytes from the pipe, although"
|
fprintf(stderr, "Only read %d bytes from the pipe, although"
|
||||||
" we need to read %d bytes.\n", ret, sizeof(p->len));
|
" we need to read %d bytes.\n", ret, sizeof(p->len));
|
||||||
}
|
}
|
||||||
else if (ret == 0)
|
else if (ret == 0)
|
||||||
{
|
{
|
||||||
|
@ -532,8 +519,8 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
||||||
"occured while reading from the pipe the length\n",
|
"occured while reading from the pipe the length\n",
|
||||||
ret, errno);
|
ret, errno);
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,9 +530,9 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
||||||
|
|
||||||
/* and read the passed data */
|
/* and read the passed data */
|
||||||
ret = pipe_read(p->fd_read,
|
ret = pipe_read(p->fd_read,
|
||||||
((unsigned char *)p->passed_data) + p->already_read,
|
((unsigned char *)p->passed_data) + p->already_read,
|
||||||
p->len - p->already_read);
|
p->len - p->already_read);
|
||||||
|
|
||||||
/* catch the non error case first */
|
/* catch the non error case first */
|
||||||
if (ret == (ssize_t)(p->len - p->already_read))
|
if (ret == (ssize_t)(p->len - p->already_read))
|
||||||
{
|
{
|
||||||
|
@ -574,12 +561,12 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
fprintf(stderr, "An unhandled error (ret: %d errno: %d)"
|
||||||
"occured while reading from the pipe the data\n",
|
"occured while reading from the pipe the data\n",
|
||||||
ret, errno);
|
ret, errno);
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ecore_time_get() - start_time < ecore_animator_frametime_get());
|
while (ecore_time_get() - start_time < ecore_animator_frametime_get());
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue