added new wait_obj functions
This commit is contained in:
parent
604a743d7d
commit
fee6f82bf7
43
xup/xup.c
43
xup/xup.c
@ -156,6 +156,7 @@ lib_mod_connect(struct mod* mod)
|
|||||||
make_stream(s);
|
make_stream(s);
|
||||||
g_sprintf(con_port, "%s", mod->port);
|
g_sprintf(con_port, "%s", mod->port);
|
||||||
mod->sck = g_tcp_socket();
|
mod->sck = g_tcp_socket();
|
||||||
|
mod->sck_obj = g_create_wait_obj_from_socket(mod->sck, 0);
|
||||||
mod->sck_closed = 0;
|
mod->sck_closed = 0;
|
||||||
error = g_tcp_connect(mod->sck, mod->ip, con_port);
|
error = g_tcp_connect(mod->sck, mod->ip, con_port);
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
@ -398,6 +399,47 @@ lib_mod_set_param(struct mod* mod, char* name, char* value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* return error */
|
||||||
|
int DEFAULT_CC
|
||||||
|
lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||||
|
tbus* write_objs, int* wcount, int* timeout)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = *rcount;
|
||||||
|
if (mod != 0)
|
||||||
|
{
|
||||||
|
if (mod->sck_obj != 0)
|
||||||
|
{
|
||||||
|
read_objs[i++] = mod->sck_obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*rcount = i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* return error */
|
||||||
|
int DEFAULT_CC
|
||||||
|
lib_mod_check_wait_objs(struct mod* mod)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = 0;
|
||||||
|
if (mod != 0)
|
||||||
|
{
|
||||||
|
if (mod->sck_obj != 0)
|
||||||
|
{
|
||||||
|
if (g_is_wait_obj_set(mod->sck_obj))
|
||||||
|
{
|
||||||
|
rv = lib_mod_signal(mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
struct mod* EXPORT_CC
|
struct mod* EXPORT_CC
|
||||||
mod_init(void)
|
mod_init(void)
|
||||||
@ -424,6 +466,7 @@ mod_exit(struct mod* mod)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
g_delete_wait_obj_from_socket(mod->sck_obj);
|
||||||
g_tcp_close(mod->sck);
|
g_tcp_close(mod->sck);
|
||||||
g_free(mod);
|
g_free(mod);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user