Skip to content

Commit

Permalink
Added IOCP integration for Nsock, engine IOCP is the default engine o…
Browse files Browse the repository at this point in the history
…n Windows
  • Loading branch information
tudor committed Aug 22, 2016
1 parent 2fb52b4 commit 1e1f744
Show file tree
Hide file tree
Showing 12 changed files with 894 additions and 58 deletions.
2 changes: 1 addition & 1 deletion nbase/nbase_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int inheritable_socket(int af, int style, int protocol) {
/* WSASocket is just like socket, except that the sockets it creates are
inheritable by subprocesses (such as are created by CreateProcess), while
those created by socket are not. */
return WSASocket(af, style, protocol, NULL, 0, 0);
return WSASocket(af, style, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
#else
return socket(af, style, protocol);
#endif
Expand Down
1 change: 1 addition & 0 deletions nsock/include/nsock_winconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
/* WSAPoll() isn't available before Vista */
#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
#define HAVE_POLL 1
#define HAVE_IOCP 1
#endif

#endif /* NSOCK_WINCONFIG_H */
1 change: 1 addition & 0 deletions nsock/nsock.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\engine_epoll.c" />
<ClCompile Include="src\engine_iocp.c" />
<ClCompile Include="src\engine_kqueue.c" />
<ClCompile Include="src\engine_poll.c" />
<ClCompile Include="src\engine_select.c" />
Expand Down
12 changes: 7 additions & 5 deletions nsock/src/engine_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@
/* --- ENGINE INTERFACE PROTOTYPES --- */
static int epoll_init(struct npool *nsp);
static void epoll_destroy(struct npool *nsp);
static int epoll_iod_register(struct npool *nsp, struct niod *iod, int ev);
static int epoll_iod_register(struct npool *nsp, struct niod *iod, struct nevent *nse, int ev);
static int epoll_iod_unregister(struct npool *nsp, struct niod *iod);
static int epoll_iod_modify(struct npool *nsp, struct niod *iod, int ev_set, int ev_clr);
static int epoll_iod_modify(struct npool *nsp, struct niod *iod, struct nevent *nse, int ev_set, int ev_clr);
static int epoll_loop(struct npool *nsp, int msec_timeout);

extern struct io_operations posix_io_operations;

/* ---- ENGINE DEFINITION ---- */
struct io_engine engine_epoll = {
Expand All @@ -99,7 +100,8 @@ struct io_engine engine_epoll = {
epoll_iod_register,
epoll_iod_unregister,
epoll_iod_modify,
epoll_loop
epoll_loop,
&posix_io_operations
};


Expand Down Expand Up @@ -159,7 +161,7 @@ void epoll_destroy(struct npool *nsp) {
free(einfo);
}

int epoll_iod_register(struct npool *nsp, struct niod *iod, int ev) {
int epoll_iod_register(struct npool *nsp, struct niod *iod, struct nevent *nse, int ev) {
int sd;
struct epoll_event epev;
struct epoll_engine_info *einfo = (struct epoll_engine_info *)nsp->engine_data;
Expand Down Expand Up @@ -204,7 +206,7 @@ int epoll_iod_unregister(struct npool *nsp, struct niod *iod) {
return 1;
}

int epoll_iod_modify(struct npool *nsp, struct niod *iod, int ev_set, int ev_clr) {
int epoll_iod_modify(struct npool *nsp, struct niod *iod, struct nevent *nse, int ev_set, int ev_clr) {
int sd;
struct epoll_event epev;
int new_events;
Expand Down
Loading

0 comments on commit 1e1f744

Please sign in to comment.