Skip to content

Commit 2b502cf

Browse files
committed
[Change] Rolled back "Workaround for getpeername() issue".
The workaround microsoftarchive@0f79d72 is not anymore required since the root problem has been fixed (in another commit).
1 parent 8746390 commit 2b502cf

File tree

5 files changed

+2
-36
lines changed

5 files changed

+2
-36
lines changed

src/Win32_Interop/win32_wsiocp.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
#include "win32_wsiocp.h"
3030
#include "Win32_FDAPI.h"
3131
#include <errno.h>
32-
#include <assert.h>
3332

3433
static void *iocpState;
3534
static HANDLE iocph;
3635
static fnGetSockState * aeGetSockState;
37-
static fnGetSockState * aeGetExistingSockState;
3836
static fnDelSockState * aeDelSockState;
3937

4038
#define SUCCEEDED_WITH_IOCP(result) \
@@ -131,7 +129,6 @@ int aeWinAccept(int fd, struct sockaddr *sa, socklen_t *len) {
131129
SOCKADDR *premotesa;
132130
int locallen, remotelen;
133131
aacceptreq * areq;
134-
aeSockState *acceptsockstate;
135132

136133
if ((sockstate = aeGetSockState(iocpState, fd)) == NULL) {
137134
errno = WSAEINVAL;
@@ -170,13 +167,6 @@ int aeWinAccept(int fd, struct sockaddr *sa, socklen_t *len) {
170167

171168
aeWinSocketAttach(acceptfd);
172169

173-
// Save remote address to support aeWinGetPeerName()
174-
if ((acceptsockstate = aeGetExistingSockState(iocpState, acceptfd)) == NULL) {
175-
errno = WSAEINVAL;
176-
return SOCKET_ERROR;
177-
}
178-
memcpy(&acceptsockstate->remoteAddress, premotesa, remotelen);
179-
180170
zfree(areq->buf);
181171
zfree(areq);
182172

@@ -188,21 +178,6 @@ int aeWinAccept(int fd, struct sockaddr *sa, socklen_t *len) {
188178
return acceptfd;
189179
}
190180

191-
int aeWinGetPeerName(int fd, struct sockaddr *addr, socklen_t * addrlen) {
192-
aeSockState *sockState = aeGetExistingSockState(iocpState, fd);
193-
if (sockState == NULL) {
194-
errno = EBADF;
195-
return -1;
196-
} else {
197-
if (sockState->remoteAddress.ss_family) {
198-
memcpy(addr, &sockState->remoteAddress, *addrlen);
199-
return 0;
200-
} else {
201-
return getpeername(fd, addr, addrlen);
202-
}
203-
}
204-
}
205-
206181
/* after doing read caller needs to call done
207182
* so that we can continue to check for read events.
208183
* This is not necessary if caller will delete read events */
@@ -515,12 +490,10 @@ int aeWinCloseSocket(int fd) {
515490
void aeWinInit(void *state,
516491
HANDLE iocp,
517492
fnGetSockState *getSockState,
518-
fnGetSockState *getExistingSockState,
519493
fnDelSockState *delSockState) {
520494
iocpState = state;
521495
iocph = iocp;
522496
aeGetSockState = getSockState;
523-
aeGetExistingSockState = getExistingSockState;
524497
aeDelSockState = delSockState;
525498
}
526499

src/Win32_Interop/win32_wsiocp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ typedef struct aeSockState {
5656
int wreqs;
5757
OVERLAPPED ov_read;
5858
list wreqlist;
59-
SOCKADDR_STORAGE remoteAddress;
6059
} aeSockState;
6160

6261
typedef aeSockState * fnGetSockState(void *apistate, int fd);
@@ -69,7 +68,7 @@ typedef void fnDelSockState(void *apistate, aeSockState *sockState);
6968
#define CONNECT_PENDING 0x002000
7069
#define CLOSE_PENDING 0x004000
7170

72-
void aeWinInit(void *state, HANDLE iocp, fnGetSockState *getSockState, fnGetSockState *getExistingSockState, fnDelSockState *delSockState);
71+
void aeWinInit(void *state, HANDLE iocp, fnGetSockState *getSockState, fnDelSockState *delSockState);
7372
void aeWinCleanup();
7473

7574
#endif

src/Win32_Interop/win32fixes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ int aeWinSocketSend(int fd, char *buf, int len,
298298
void *eventLoop, void *client, void *data, void *proc);
299299
int aeWinListen(int rfd, int backlog);
300300
int aeWinAccept(int fd, struct sockaddr *sa, socklen_t *len);
301-
int aeWinGetPeerName(int fd, struct sockaddr *addr, socklen_t * addrlen);
302301
int aeWinSocketConnect(int fd, const SOCKADDR_STORAGE *ss);
303302
int aeWinSocketConnectBind(int fd, const SOCKADDR_STORAGE *ss, const char* source_addr);
304303

src/ae_wsiocp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ aeSockState *aeGetSockState(void *apistate, int fd) {
9090
sockState->wreqs = 0;
9191
sockState->reqs = NULL;
9292
memset(&sockState->wreqlist, 0, sizeof(sockState->wreqlist));
93-
memset(&sockState->remoteAddress, 0, sizeof(sockState->remoteAddress));
9493

9594
if (listAddNodeHead(socklist, sockState) != NULL) {
9695
return sockState;
@@ -203,7 +202,7 @@ static int aeApiCreate(aeEventLoop *eventLoop) {
203202
state->setsize = eventLoop->setsize;
204203
eventLoop->apidata = state;
205204
/* initialize the IOCP socket code with state reference */
206-
aeWinInit(state, state->iocp, aeGetSockState, aeGetExistingSockState, aeDelSockState);
205+
aeWinInit(state, state->iocp, aeGetSockState, aeDelSockState);
207206
return 0;
208207
}
209208

src/anet.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,7 @@ int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
647647
struct sockaddr_storage sa;
648648
socklen_t salen = sizeof(sa);
649649

650-
#ifdef WIN32_IOCP
651-
if (aeWinGetPeerName(fd,(struct sockaddr*)&sa,&salen) == -1) {
652-
#else
653650
if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) {
654-
#endif
655651
if (port) *port = 0;
656652
ip[0] = '?';
657653
ip[1] = '\0';

0 commit comments

Comments
 (0)