wait objs function changes
This commit is contained in:
parent
d061537be9
commit
11c5d72c55
@ -619,15 +619,17 @@ g_tcp_select(int sck1, int sck2)
|
||||
tbus APP_CC
|
||||
g_create_wait_obj(char* name)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
tbus obj;
|
||||
|
||||
#ifdef _WIN32
|
||||
obj = (tbus)CreateEvent(0, 1, 0, name);
|
||||
return obj;
|
||||
#else
|
||||
tbus obj;
|
||||
struct sockaddr_un sa;
|
||||
int len;
|
||||
int sck;
|
||||
int i;
|
||||
|
||||
sck = socket(PF_UNIX, SOCK_DGRAM, 0);
|
||||
if (sck < 0)
|
||||
@ -636,7 +638,20 @@ g_create_wait_obj(char* name)
|
||||
}
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sun_family = AF_UNIX;
|
||||
if ((name == 0) || (strlen(name) == 0))
|
||||
{
|
||||
g_random((char*)&i, sizeof(i));
|
||||
sprintf(sa.sun_path, "/tmp/auto%8.8x", i);
|
||||
while (g_file_exist(sa.sun_path))
|
||||
{
|
||||
g_random((char*)&i, sizeof(i));
|
||||
sprintf(sa.sun_path, "/tmp/auto%8.8x", i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(sa.sun_path, "/tmp/%s", name);
|
||||
}
|
||||
unlink(sa.sun_path);
|
||||
len = sizeof(sa);
|
||||
if (bind(sck, (struct sockaddr*)&sa, len) < 0)
|
||||
@ -650,6 +665,7 @@ g_create_wait_obj(char* name)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns 0 on error */
|
||||
tbus APP_CC
|
||||
g_create_wait_obj_from_socket(tbus socket, int write)
|
||||
{
|
||||
@ -673,6 +689,20 @@ g_create_wait_obj_from_socket(tbus socket, int write)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
g_delete_wait_obj_from_socket(tbus wait_obj)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (wait_obj == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WSACloseEvent((HANDLE)wait_obj);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
@ -769,7 +799,7 @@ g_is_wait_obj_set(tbus obj)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
g_destroy_wait_obj(tbus obj)
|
||||
g_delete_wait_obj(tbus obj)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (obj == 0)
|
||||
@ -777,7 +807,7 @@ g_destroy_wait_obj(tbus obj)
|
||||
return 0;
|
||||
}
|
||||
/* Close event handle */
|
||||
WSACloseEvent((HANDLE)obj);
|
||||
CloseHandle((HANDLE)obj);
|
||||
return 0;
|
||||
#else
|
||||
socklen_t sa_size;
|
||||
|
@ -97,6 +97,8 @@ tbus APP_CC
|
||||
g_create_wait_obj(char* name);
|
||||
tbus APP_CC
|
||||
g_create_wait_obj_from_socket(tbus socket, int write);
|
||||
void APP_CC
|
||||
g_delete_wait_obj_from_socket(tbus wait_obj);
|
||||
int APP_CC
|
||||
g_set_wait_obj(tbus obj);
|
||||
int APP_CC
|
||||
@ -104,7 +106,7 @@ g_reset_wait_obj(tbus obj);
|
||||
int APP_CC
|
||||
g_is_wait_obj_set(tbus obj);
|
||||
int APP_CC
|
||||
g_destroy_wait_obj(tbus obj);
|
||||
g_delete_wait_obj(tbus obj);
|
||||
int APP_CC
|
||||
g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
|
||||
int mstimeout);
|
||||
|
Loading…
Reference in New Issue
Block a user