-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb0fab6
commit 73301ca
Showing
10 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2003-2021 Ke Hengzhong <[email protected]> | ||
* All rights reserved. See MIT LICENSE for redistribution. | ||
*/ | ||
|
||
#ifdef HAVE_IOCP | ||
|
||
#ifndef _EPIOCP_H_ | ||
#define _EPIOCP_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef BOOL WINAPI AcceptExPtr(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED); | ||
typedef BOOL WINAPI ConnectExPtr(SOCKET, const struct sockaddr *, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED); | ||
typedef void WINAPI GetAcceptExSockaddrsPtr(PVOID, DWORD, DWORD, DWORD, LPSOCKADDR *, LPINT, LPSOCKADDR *, LPINT); | ||
|
||
|
||
#define IOCP_NONE 0 | ||
#define IOCP_READ_IN_PROGRESS 1 | ||
#define IOCP_WRITE_IN_PROGRESS 2 | ||
#define IOCP_ACCEPT_IN_PROGRESS 3 | ||
#define IOCP_CONNECT_IN_PROGRESS 4 | ||
|
||
#define IOCP_BUF_CNT 16 | ||
|
||
|
||
typedef struct iocp_event_st { | ||
|
||
OVERLAPPED ovlap; | ||
int evtype; | ||
|
||
SOCKET fd; | ||
SOCKET clifd; | ||
|
||
ulong devid; | ||
DWORD flags; | ||
|
||
WSABUF bufs[IOCP_BUF_CNT]; | ||
uint16 bufcnt; | ||
int64 ionum; | ||
|
||
int64 mapsize; | ||
HANDLE hmap; | ||
void * pmap; | ||
|
||
uint16 state; | ||
|
||
int len; | ||
uint8 buf[1]; | ||
} iocp_event_t; | ||
|
||
void * iocp_event_alloc (int extsize); | ||
void iocp_event_free (void * vcpe); | ||
|
||
void * iocp_event_accept_post (void * vdev); | ||
void * iocp_event_recv_post (void * vdev, void * pbuf, int len); | ||
void * iocp_event_recvfrom_post (void * vdev, void * pbuf, int len); | ||
void * iocp_event_send_post (void * vdev, void * chunk, int64 pos, int httpchunk); | ||
void * iocp_event_connect_post (void * vdev, char * host, int port, char * lip, int lport, int * retval); | ||
void * iocp_event_ep_connect_post (void * vdev, ep_sockaddr_t * host, char * lip, int lport, int * retval); | ||
|
||
|
||
int epcore_iocp_init (epcore_t * pcore); | ||
int epcore_iocp_clean (epcore_t * pcore); | ||
|
||
int epump_iocp_init (epump_t * epump, int maxfd); | ||
int epump_iocp_clean (epump_t * epump); | ||
|
||
int epump_iocp_setpoll (void * vepump, void * vpdev); | ||
int epump_iocp_clearpoll (void * vepump, void * vpdev); | ||
|
||
int epump_iocp_dispatch (void * veps, btime_t * delay); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/* | ||
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]> | ||
* Copyright (c) 2003-2021 Ke Hengzhong <[email protected]> | ||
* All rights reserved. See MIT LICENSE for redistribution. | ||
*/ | ||
|
||
#ifndef _EPRAWSOCK_H_ | ||
#define _EPRAWSOCK_H_ | ||
|
||
|
||
#ifdef _WIN32 | ||
#if defined(_WIN32) || defined(_WIN64) | ||
|
||
#if _MSC_VER > 1000 | ||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]> | ||
* Copyright (c) 2003-2021 Ke Hengzhong <[email protected]> | ||
* All rights reserved. See MIT LICENSE for redistribution. | ||
*/ | ||
|
||
|
@@ -10,21 +10,26 @@ | |
extern "C" { | ||
#endif | ||
|
||
void * epudp_listen_create (void * vpcore, char * localip, int port, | ||
void * para, int * retval, IOHandler * cb, void * cbpara); | ||
void * epudp_listen_create (void * vpcore, char * localip, int port, void * para, | ||
int * retval, IOHandler * cb, void * cbpara, | ||
iodev_t ** devlist, int * devnum); | ||
|
||
void * epudp_listen (void * vpcore, char * localip, int port, | ||
void * para, int * retval, IOHandler * cb, void * cbpara); | ||
void * epudp_listen (void * vpcore, char * localip, int port, void * para, int * pret, | ||
IOHandler * cb, void * cbpara, int bindtype, void ** plist, int * listnum); | ||
|
||
void * epudp_mlisten (void * vpcore, char * localip, int port, void * para, | ||
IOHandler * cb, void * cbpara); | ||
|
||
void * epudp_client (void * veps, struct in_addr * localip, int port, | ||
void * para, int * retval, IOHandler * cb, void * cbpara); | ||
void * epudp_client (void * vpcore, char * localip, int port, | ||
void * para, int * retval, IOHandler * cb, void * cbpara, | ||
iodev_t ** devlist, int * devnum); | ||
|
||
int epudp_recvfrom (void * vdev, void * vfrm, void * addr, int * pnum); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]> | ||
* Copyright (c) 2003-2021 Ke Hengzhong <[email protected]> | ||
* All rights reserved. See MIT LICENSE for redistribution. | ||
*/ | ||
|
||
|
@@ -29,7 +29,7 @@ typedef struct Worker_s { | |
|
||
/* current threads management */ | ||
ulong threadid; | ||
#ifdef _WIN32 | ||
#if defined(_WIN32) || defined(_WIN64) | ||
HANDLE hworker; | ||
#endif | ||
|
||
|