ecore_main_fd_handler_fd_get can return -1 so we need to check for a

valid fd before calling read().

Reuse returned fd variable in the callback to save extra function call
to ecore_main_fd_handler_fd_get (since we already acquired the fd
above).

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2013-08-05 11:46:04 +01:00
parent 4c9c522337
commit 76766161d2
1 changed files with 7 additions and 2 deletions

View File

@ -48,10 +48,15 @@ _ecore_io_wrapper(void *data, Ecore_Fd_Handler *handler)
if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
{
int fd;
flags |= PA_IO_EVENT_INPUT;
fd = ecore_main_fd_handler_fd_get(handler);
if (fd < 0) return ECORE_CALLBACK_RENEW;
/* Check for HUP and report */
if (recv(ecore_main_fd_handler_fd_get(handler), buf, 64, MSG_PEEK))
if (recv(fd, buf, 64, MSG_PEEK))
{
if (errno == ESHUTDOWN || errno == ECONNRESET || errno == ECONNABORTED || errno == ENETRESET)
{
@ -66,7 +71,7 @@ _ecore_io_wrapper(void *data, Ecore_Fd_Handler *handler)
if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
flags |= PA_IO_EVENT_ERROR;
event->callback(event->mainloop, event, ecore_main_fd_handler_fd_get(handler), flags, event->userdata);
event->callback(event->mainloop, event, fd, flags, event->userdata);
return ECORE_CALLBACK_RENEW;
}