net: encapsulate fdwatch backend metadata
This commit is contained in:
@@ -37,6 +37,10 @@ bool CNetPoller::Create()
|
||||
return false;
|
||||
}
|
||||
|
||||
sys_log(0, "[STARTUP] fdwatch backend=%s descriptor_limit=%d",
|
||||
fdwatch_backend_name(fdwatch_get_backend(m_fdWatcher)),
|
||||
fdwatch_get_descriptor_limit(m_fdWatcher));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -602,6 +602,16 @@ int start(int argc, char **argv)
|
||||
|
||||
main_fdw = fdwatch_new(4096);
|
||||
|
||||
if (!main_fdw)
|
||||
{
|
||||
sys_err("fdwatch_new failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sys_log(0, "[STARTUP] fdwatch backend=%s descriptor_limit=%d",
|
||||
fdwatch_backend_name(fdwatch_get_backend(main_fdw)),
|
||||
fdwatch_get_descriptor_limit(main_fdw));
|
||||
|
||||
if ((tcp_socket = socket_tcp_bind(g_szPublicIP, mother_port)) == INVALID_SOCKET)
|
||||
{
|
||||
perror("socket_tcp_bind: tcp_socket");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,85 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __USE_SELECT__
|
||||
typedef struct fdwatch FDWATCH;
|
||||
typedef struct fdwatch * LPFDWATCH;
|
||||
|
||||
typedef struct fdwatch FDWATCH;
|
||||
typedef struct fdwatch * LPFDWATCH;
|
||||
enum EFdwatch
|
||||
{
|
||||
FDW_NONE = 0,
|
||||
FDW_READ = 1,
|
||||
FDW_WRITE = 2,
|
||||
FDW_WRITE_ONESHOT = 4,
|
||||
FDW_EOF = 8,
|
||||
};
|
||||
|
||||
enum EFdwatch
|
||||
{
|
||||
FDW_NONE = 0,
|
||||
FDW_READ = 1,
|
||||
FDW_WRITE = 2,
|
||||
FDW_WRITE_ONESHOT = 4,
|
||||
FDW_EOF = 8,
|
||||
};
|
||||
|
||||
typedef struct kevent KEVENT;
|
||||
typedef struct kevent * LPKEVENT;
|
||||
typedef int KQUEUE;
|
||||
|
||||
struct fdwatch
|
||||
{
|
||||
KQUEUE kq;
|
||||
|
||||
int nfiles;
|
||||
|
||||
LPKEVENT kqevents;
|
||||
int nkqevents;
|
||||
|
||||
LPKEVENT kqrevents;
|
||||
int * fd_event_idx;
|
||||
|
||||
void ** fd_data;
|
||||
int * fd_rw;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
typedef struct fdwatch FDWATCH;
|
||||
typedef struct fdwatch * LPFDWATCH;
|
||||
|
||||
enum EFdwatch
|
||||
{
|
||||
FDW_NONE = 0,
|
||||
FDW_READ = 1,
|
||||
FDW_WRITE = 2,
|
||||
FDW_WRITE_ONESHOT = 4,
|
||||
FDW_EOF = 8,
|
||||
};
|
||||
|
||||
struct fdwatch
|
||||
{
|
||||
fd_set rfd_set;
|
||||
fd_set wfd_set;
|
||||
|
||||
socket_t* select_fds;
|
||||
int* select_rfdidx;
|
||||
|
||||
int nselect_fds;
|
||||
|
||||
fd_set working_rfd_set;
|
||||
fd_set working_wfd_set;
|
||||
|
||||
int nfiles;
|
||||
|
||||
void** fd_data;
|
||||
int* fd_rw;
|
||||
};
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
LPFDWATCH fdwatch_new(int nfiles);
|
||||
void fdwatch_clear_fd(LPFDWATCH fdw, socket_t fd);
|
||||
void fdwatch_delete(LPFDWATCH fdw);
|
||||
int fdwatch_check_fd(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_check_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx);
|
||||
void fdwatch_clear_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx);
|
||||
void fdwatch_add_fd(LPFDWATCH fdw, socket_t fd, void* client_data, int rw, int oneshot);
|
||||
int fdwatch(LPFDWATCH fdw, struct timeval *timeout);
|
||||
void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx);
|
||||
void fdwatch_del_fd(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_get_buffer_size(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_get_ident(LPFDWATCH fdw, unsigned int event_idx);
|
||||
enum EFdwatchBackend
|
||||
{
|
||||
FDWATCH_BACKEND_KQUEUE = 0,
|
||||
FDWATCH_BACKEND_SELECT = 1,
|
||||
};
|
||||
|
||||
LPFDWATCH fdwatch_new(int nfiles);
|
||||
void fdwatch_clear_fd(LPFDWATCH fdw, socket_t fd);
|
||||
void fdwatch_delete(LPFDWATCH fdw);
|
||||
int fdwatch_check_fd(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_check_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx);
|
||||
void fdwatch_clear_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx);
|
||||
void fdwatch_add_fd(LPFDWATCH fdw, socket_t fd, void* client_data, int rw, int oneshot);
|
||||
int fdwatch(LPFDWATCH fdw, struct timeval *timeout);
|
||||
void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx);
|
||||
void fdwatch_del_fd(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_get_buffer_size(LPFDWATCH fdw, socket_t fd);
|
||||
int fdwatch_get_ident(LPFDWATCH fdw, unsigned int event_idx);
|
||||
EFdwatchBackend fdwatch_get_backend(LPFDWATCH fdw);
|
||||
const char * fdwatch_backend_name(EFdwatchBackend backend);
|
||||
int fdwatch_get_descriptor_limit(LPFDWATCH fdw);
|
||||
|
||||
Reference in New Issue
Block a user