2008-10-09 05:30:19 -07:00
|
|
|
/*
|
|
|
|
* getaddrinfo with callback
|
|
|
|
*
|
|
|
|
* man getaddrinfo
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2009-12-04 00:55:46 -08:00
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
#elif defined __GNUC__
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
#elif defined _AIX
|
|
|
|
# define alloca __alloca
|
|
|
|
#elif defined _MSC_VER
|
|
|
|
# include <malloc.h>
|
|
|
|
# define alloca _alloca
|
|
|
|
#else
|
|
|
|
# include <stddef.h>
|
|
|
|
# ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
# endif
|
2010-11-03 10:58:37 -07:00
|
|
|
void *alloca(size_t);
|
2009-12-04 00:55:46 -08:00
|
|
|
#endif
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <string.h>
|
2010-01-03 13:55:50 -08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2008-10-09 05:30:19 -07:00
|
|
|
#include <ctype.h>
|
2009-03-22 06:30:52 -07:00
|
|
|
#ifdef __OpenBSD__
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
2010-02-24 09:52:54 -08:00
|
|
|
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
# include <arpa/inet.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_ARPA_NAMESER_H
|
|
|
|
# include <arpa/nameser.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2011-02-10 00:49:23 -08:00
|
|
|
#include <errno.h>
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#include "Ecore.h"
|
2009-12-22 13:15:12 -08:00
|
|
|
#include "ecore_private.h"
|
2009-01-31 10:33:39 -08:00
|
|
|
#include "ecore_con_private.h"
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
typedef struct _CB_Data CB_Data;
|
|
|
|
|
|
|
|
struct _CB_Data
|
|
|
|
{
|
2010-11-03 10:58:37 -07:00
|
|
|
EINA_INLIST;
|
|
|
|
Ecore_Con_Info_Cb cb_done;
|
|
|
|
void *data;
|
|
|
|
Ecore_Fd_Handler *fdh;
|
|
|
|
pid_t pid;
|
2008-10-09 05:30:19 -07:00
|
|
|
Ecore_Event_Handler *handler;
|
2010-11-03 10:58:37 -07:00
|
|
|
int fd2;
|
2008-10-09 05:30:19 -07:00
|
|
|
};
|
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
static void _ecore_con_info_readdata(CB_Data *cbdata);
|
|
|
|
static void _ecore_con_info_slave_free(CB_Data *cbdata);
|
2010-11-03 10:58:37 -07:00
|
|
|
static Eina_Bool _ecore_con_info_data_handler(void *data,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Fd_Handler *fd_handler);
|
2010-11-03 10:58:37 -07:00
|
|
|
static Eina_Bool _ecore_con_info_exit_handler(void *data,
|
|
|
|
int type __UNUSED__,
|
|
|
|
void *event);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
|
|
|
static int info_init = 0;
|
2009-06-17 04:40:30 -07:00
|
|
|
static CB_Data *info_slaves = NULL;
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2010-01-04 11:35:21 -08:00
|
|
|
int
|
2008-10-09 05:30:19 -07:00
|
|
|
ecore_con_info_init(void)
|
|
|
|
{
|
|
|
|
info_init++;
|
|
|
|
return info_init;
|
|
|
|
}
|
|
|
|
|
2010-01-04 11:35:21 -08:00
|
|
|
int
|
2008-10-09 05:30:19 -07:00
|
|
|
ecore_con_info_shutdown(void)
|
|
|
|
{
|
|
|
|
info_init--;
|
|
|
|
if (info_init == 0)
|
2010-11-03 10:58:37 -07:00
|
|
|
while (info_slaves) _ecore_con_info_slave_free(info_slaves);
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
return info_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
struct addrinfo hints;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_flags = AI_CANONNAME;
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
|
|
hints.ai_canonname = NULL;
|
|
|
|
hints.ai_next = NULL;
|
|
|
|
hints.ai_addr = NULL;
|
|
|
|
|
|
|
|
return ecore_con_info_get(svr, done_cb, data, &hints);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
struct addrinfo hints;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
|
|
hints.ai_canonname = NULL;
|
|
|
|
hints.ai_next = NULL;
|
|
|
|
hints.ai_addr = NULL;
|
|
|
|
|
|
|
|
return ecore_con_info_get(svr, done_cb, data, &hints);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
struct addrinfo hints;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
hints.ai_flags = AI_CANONNAME;
|
|
|
|
hints.ai_protocol = IPPROTO_UDP;
|
|
|
|
hints.ai_canonname = NULL;
|
|
|
|
hints.ai_next = NULL;
|
|
|
|
hints.ai_addr = NULL;
|
|
|
|
|
|
|
|
return ecore_con_info_get(svr, done_cb, data, &hints);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
struct addrinfo hints;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_protocol = IPPROTO_UDP;
|
|
|
|
hints.ai_canonname = NULL;
|
|
|
|
hints.ai_next = NULL;
|
|
|
|
hints.ai_addr = NULL;
|
|
|
|
|
|
|
|
return ecore_con_info_get(svr, done_cb, data, &hints);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
struct addrinfo hints;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
hints.ai_flags = 0;
|
|
|
|
hints.ai_protocol = IPPROTO_UDP;
|
|
|
|
hints.ai_canonname = NULL;
|
|
|
|
hints.ai_next = NULL;
|
|
|
|
hints.ai_addr = NULL;
|
|
|
|
|
|
|
|
return ecore_con_info_get(svr, done_cb, data, &hints);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
ecore_con_info_get(Ecore_Con_Server *svr,
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Info_Cb done_cb,
|
2010-11-03 10:58:37 -07:00
|
|
|
void *data,
|
|
|
|
struct addrinfo *hints)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
CB_Data *cbdata;
|
|
|
|
int fd[2];
|
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
if (pipe(fd) < 0)
|
2011-02-10 00:49:23 -08:00
|
|
|
{
|
|
|
|
ecore_con_event_server_error(svr, strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
cbdata = calloc(1, sizeof(CB_Data));
|
|
|
|
if (!cbdata)
|
|
|
|
{
|
2010-07-26 23:30:27 -07:00
|
|
|
close(fd[0]);
|
|
|
|
close(fd[1]);
|
|
|
|
return 0;
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
cbdata->cb_done = done_cb;
|
|
|
|
cbdata->data = data;
|
|
|
|
cbdata->fd2 = fd[1];
|
|
|
|
if (!(cbdata->fdh = ecore_main_fd_handler_add(fd[0], ECORE_FD_READ,
|
2010-07-26 23:30:27 -07:00
|
|
|
_ecore_con_info_data_handler,
|
|
|
|
cbdata,
|
|
|
|
NULL, NULL)))
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
2011-02-10 00:49:23 -08:00
|
|
|
ecore_con_event_server_error(svr, "Memory allocation failure");
|
2010-07-26 23:30:27 -07:00
|
|
|
free(cbdata);
|
|
|
|
close(fd[0]);
|
|
|
|
close(fd[1]);
|
|
|
|
return 0;
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((cbdata->pid = fork()) == 0)
|
|
|
|
{
|
2008-10-13 04:24:52 -07:00
|
|
|
Ecore_Con_Info *container;
|
2010-07-26 23:30:27 -07:00
|
|
|
struct addrinfo *result = NULL;
|
2010-07-29 17:27:02 -07:00
|
|
|
char service[NI_MAXSERV] = {0};
|
|
|
|
char hbuf[NI_MAXHOST] = {0};
|
|
|
|
char sbuf[NI_MAXSERV] = {0};
|
|
|
|
unsigned char *tosend = NULL;
|
2010-07-26 23:30:27 -07:00
|
|
|
int tosend_len;
|
|
|
|
int canonname_len = 0;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
eina_convert_itoa(svr->port, service);
|
|
|
|
/* CHILD */
|
|
|
|
if (!getaddrinfo(svr->name, service, hints, &result) && result)
|
|
|
|
{
|
|
|
|
if (result->ai_canonname)
|
2010-11-03 10:58:37 -07:00
|
|
|
canonname_len = strlen(result->ai_canonname) + 1;
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen +
|
2010-11-03 10:58:37 -07:00
|
|
|
canonname_len;
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2011-01-13 18:32:45 -08:00
|
|
|
tosend = alloca(tosend_len);
|
2010-07-29 17:27:02 -07:00
|
|
|
memset(tosend, 0, tosend_len);
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
container = (Ecore_Con_Info *)tosend;
|
|
|
|
container->size = tosend_len;
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-29 17:27:02 -07:00
|
|
|
memcpy(&container->info,
|
2010-07-26 23:30:27 -07:00
|
|
|
result,
|
|
|
|
sizeof(struct addrinfo));
|
2010-07-29 17:27:02 -07:00
|
|
|
memcpy(tosend + sizeof(Ecore_Con_Info),
|
2010-07-26 23:30:27 -07:00
|
|
|
result->ai_addr,
|
|
|
|
result->ai_addrlen);
|
2011-01-13 18:35:59 -08:00
|
|
|
if (result->ai_canonname) /* FIXME: else... */
|
|
|
|
memcpy(tosend + sizeof(Ecore_Con_Info) + result->ai_addrlen,
|
|
|
|
result->ai_canonname,
|
|
|
|
canonname_len);
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
if (!getnameinfo(result->ai_addr, result->ai_addrlen,
|
|
|
|
hbuf, sizeof(hbuf), sbuf, sizeof(sbuf),
|
|
|
|
NI_NUMERICHOST | NI_NUMERICSERV))
|
|
|
|
{
|
2010-11-03 10:58:37 -07:00
|
|
|
memcpy(container->ip, hbuf, sizeof(container->ip));
|
2010-07-26 23:30:27 -07:00
|
|
|
memcpy(container->service, sbuf, sizeof(container->service));
|
|
|
|
}
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
err = write(fd[1], tosend, tosend_len);
|
|
|
|
}
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
if (result)
|
2010-11-03 10:58:37 -07:00
|
|
|
freeaddrinfo(result);
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
err = write(fd[1], "", 1);
|
|
|
|
close(fd[1]);
|
2011-10-29 00:03:20 -07:00
|
|
|
#if defined(__USE_ISOC99) && !defined(__UCLIBC__)
|
2010-07-26 23:30:27 -07:00
|
|
|
_Exit(0);
|
2010-07-29 17:27:02 -07:00
|
|
|
#else
|
2010-07-26 23:30:27 -07:00
|
|
|
_exit(0);
|
2010-07-29 17:27:02 -07:00
|
|
|
#endif
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
/* PARENT */
|
2010-07-26 23:30:27 -07:00
|
|
|
cbdata->handler =
|
2010-11-03 10:58:37 -07:00
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_con_info_exit_handler,
|
|
|
|
cbdata);
|
2008-10-09 05:30:19 -07:00
|
|
|
close(fd[1]);
|
|
|
|
if (!cbdata->handler)
|
|
|
|
{
|
2010-07-26 23:30:27 -07:00
|
|
|
ecore_main_fd_handler_del(cbdata->fdh);
|
|
|
|
free(cbdata);
|
|
|
|
close(fd[0]);
|
|
|
|
return 0;
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
info_slaves = (CB_Data *)eina_inlist_append(EINA_INLIST_GET(
|
2010-11-03 10:58:37 -07:00
|
|
|
info_slaves),
|
2010-07-26 23:30:27 -07:00
|
|
|
EINA_INLIST_GET(cbdata));
|
2011-01-21 02:01:04 -08:00
|
|
|
svr->infos = eina_list_append(svr->infos, cbdata);
|
2008-10-09 05:30:19 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-01-21 02:01:04 -08:00
|
|
|
void
|
|
|
|
ecore_con_info_data_clear(void *info)
|
|
|
|
{
|
|
|
|
CB_Data *cbdata = info;
|
|
|
|
cbdata->data = NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
static void
|
|
|
|
_ecore_con_info_readdata(CB_Data *cbdata)
|
|
|
|
{
|
|
|
|
Ecore_Con_Info container;
|
2011-04-29 00:39:28 -07:00
|
|
|
Ecore_Con_Info *recv_info;
|
2010-07-29 17:35:57 -07:00
|
|
|
unsigned char *torecv;
|
2008-10-13 04:24:52 -07:00
|
|
|
int torecv_len;
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
ssize_t size;
|
|
|
|
|
|
|
|
size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), &container,
|
2010-07-26 23:30:27 -07:00
|
|
|
sizeof(Ecore_Con_Info));
|
2008-10-09 05:30:19 -07:00
|
|
|
if (size == sizeof(Ecore_Con_Info))
|
|
|
|
{
|
2008-10-13 04:24:52 -07:00
|
|
|
torecv_len = container.size;
|
2010-07-26 23:30:27 -07:00
|
|
|
torecv = malloc(torecv_len);
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
memcpy(torecv, &container, sizeof(Ecore_Con_Info));
|
2010-09-22 01:03:38 -07:00
|
|
|
|
|
|
|
size = read(ecore_main_fd_handler_fd_get(cbdata->fdh),
|
2010-07-29 17:35:57 -07:00
|
|
|
torecv + sizeof(Ecore_Con_Info),
|
2010-07-26 23:30:27 -07:00
|
|
|
torecv_len - sizeof(Ecore_Con_Info));
|
2010-09-22 01:03:38 -07:00
|
|
|
if ((size > 0) &&
|
2010-07-29 17:35:57 -07:00
|
|
|
((size_t)size == torecv_len - sizeof(Ecore_Con_Info)))
|
2010-07-26 23:30:27 -07:00
|
|
|
{
|
2011-04-29 00:39:28 -07:00
|
|
|
recv_info = (Ecore_Con_Info *)torecv;
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2011-04-29 00:39:28 -07:00
|
|
|
recv_info->info.ai_addr =
|
2010-11-03 10:58:37 -07:00
|
|
|
(struct sockaddr *)(torecv + sizeof(Ecore_Con_Info));
|
2010-07-26 23:30:27 -07:00
|
|
|
if ((size_t)torecv_len !=
|
2011-04-29 00:39:28 -07:00
|
|
|
(sizeof(Ecore_Con_Info) + recv_info->info.ai_addrlen))
|
|
|
|
recv_info->info.ai_canonname = (char *)
|
|
|
|
(torecv + sizeof(Ecore_Con_Info) + recv_info->info.ai_addrlen);
|
2010-07-26 23:30:27 -07:00
|
|
|
else
|
2011-04-29 00:39:28 -07:00
|
|
|
recv_info->info.ai_canonname = NULL;
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2011-04-29 00:39:28 -07:00
|
|
|
recv_info->info.ai_next = NULL;
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2011-01-21 02:01:04 -08:00
|
|
|
if (cbdata->data)
|
|
|
|
{
|
2011-04-29 00:39:28 -07:00
|
|
|
cbdata->cb_done(cbdata->data, recv_info);
|
2011-01-21 02:01:04 -08:00
|
|
|
ecore_con_server_infos_del(cbdata->data, cbdata);
|
|
|
|
}
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
free(torecv);
|
|
|
|
}
|
|
|
|
else
|
2011-01-21 02:01:04 -08:00
|
|
|
{
|
|
|
|
if (cbdata->data)
|
|
|
|
{
|
|
|
|
cbdata->cb_done(cbdata->data, NULL);
|
|
|
|
ecore_con_server_infos_del(cbdata->data, cbdata);
|
|
|
|
}
|
|
|
|
}
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
|
|
|
else
|
2011-01-21 02:01:04 -08:00
|
|
|
{
|
|
|
|
if (cbdata->data)
|
|
|
|
{
|
2011-02-10 00:49:23 -08:00
|
|
|
ecore_con_event_server_error(cbdata->data, strerror(errno));
|
2011-01-21 02:01:04 -08:00
|
|
|
cbdata->cb_done(cbdata->data, NULL);
|
|
|
|
ecore_con_server_infos_del(cbdata->data, cbdata);
|
|
|
|
}
|
|
|
|
}
|
2010-09-22 01:03:38 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
cbdata->cb_done = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_con_info_slave_free(CB_Data *cbdata)
|
|
|
|
{
|
2010-07-29 17:35:57 -07:00
|
|
|
info_slaves = (CB_Data *)eina_inlist_remove(EINA_INLIST_GET(info_slaves),
|
2010-07-26 23:30:27 -07:00
|
|
|
EINA_INLIST_GET(cbdata));
|
2008-10-09 05:30:19 -07:00
|
|
|
ecore_main_fd_handler_del(cbdata->fdh);
|
|
|
|
ecore_event_handler_del(cbdata->handler);
|
2010-12-15 20:39:38 -08:00
|
|
|
close(ecore_main_fd_handler_fd_get(cbdata->fdh));
|
2011-01-21 02:01:04 -08:00
|
|
|
if (cbdata->data) ecore_con_server_infos_del(cbdata->data, cbdata);
|
2008-10-09 05:30:19 -07:00
|
|
|
free(cbdata);
|
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2010-11-03 10:58:37 -07:00
|
|
|
_ecore_con_info_data_handler(void *data,
|
|
|
|
Ecore_Fd_Handler *fd_handler)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
CB_Data *cbdata;
|
|
|
|
|
|
|
|
cbdata = data;
|
|
|
|
if (cbdata->cb_done)
|
|
|
|
{
|
2010-07-26 23:30:27 -07:00
|
|
|
if (ecore_main_fd_handler_active_get(fd_handler,
|
|
|
|
ECORE_FD_READ))
|
2010-11-03 10:58:37 -07:00
|
|
|
_ecore_con_info_readdata(cbdata);
|
2010-07-26 23:30:27 -07:00
|
|
|
else
|
|
|
|
{
|
2011-01-21 02:01:04 -08:00
|
|
|
if (cbdata->data)
|
|
|
|
{
|
|
|
|
cbdata->cb_done(cbdata->data, NULL);
|
|
|
|
cbdata->cb_done = NULL;
|
|
|
|
ecore_con_server_infos_del(cbdata->data, cbdata);
|
|
|
|
}
|
2010-07-26 23:30:27 -07:00
|
|
|
}
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
_ecore_con_info_slave_free(cbdata);
|
2010-06-24 09:15:56 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2010-11-03 10:58:37 -07:00
|
|
|
_ecore_con_info_exit_handler(void *data,
|
|
|
|
int type __UNUSED__,
|
|
|
|
void *event)
|
2008-10-09 05:30:19 -07:00
|
|
|
{
|
|
|
|
CB_Data *cbdata;
|
|
|
|
Ecore_Exe_Event_Del *ev;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
cbdata = data;
|
2010-07-26 23:30:27 -07:00
|
|
|
if (cbdata->pid != ev->pid)
|
2010-11-03 10:58:37 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL; /* FIXME: Woot ??? */
|
2008-10-09 05:30:19 -07:00
|
|
|
_ecore_con_info_slave_free(cbdata);
|
2010-06-24 09:15:56 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2008-10-09 05:30:19 -07:00
|
|
|
}
|
2010-11-03 10:58:37 -07:00
|
|
|
|