1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 03:09:13 +00:00

Completely kill pnUtAddr and NetAddress.

This commit is contained in:
Darryl Pogue
2012-03-26 21:49:10 -07:00
parent 3ea3473d13
commit 3ba721711e
17 changed files with 56 additions and 117 deletions

View File

@ -191,7 +191,7 @@ void NtWaitForShutdown ();
void NtSleep (unsigned sleepMs);
void NtSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
@ -228,11 +228,11 @@ void NtSocketSetBacklogAlloc (
unsigned bufferSize
);
unsigned NtSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);
void NtSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);
void NtSocketEnableNagling (

View File

@ -77,7 +77,7 @@ static const unsigned kMinBacklogBytes = 4 * 1024;
struct NtListener {
LINK(NtListener) nextPort;
SOCKET hSocket;
NetAddress addr;
plNetAddress addr;
FAsyncNotifySocketProc notifyProc;
int listenCount;
@ -91,7 +91,7 @@ struct NtOpConnAttempt : Operation {
AsyncCancelId cancelId;
bool canceled;
unsigned localPort;
NetAddress remoteAddr;
plNetAddress remoteAddr;
FAsyncNotifySocketProc notifyProc;
void * param;
SOCKET hSocket;
@ -113,7 +113,7 @@ struct NtOpSocketRead : Operation {
struct NtSock : NtObject {
LINK(NtSock) link;
NetAddress addr;
plNetAddress addr;
unsigned closeTimeMs;
unsigned connType;
FAsyncNotifySocketProc notifyProc;
@ -171,7 +171,7 @@ NtSock::~NtSock () {
//===========================================================================
// must be called inside s_listenCrit
static bool ListenPortIncrement (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc,
int count
) {
@ -192,12 +192,11 @@ static bool ListenPortIncrement (
//===========================================================================
static void SocketGetAddresses (
NtSock * sock,
NetAddress * localAddr,
NetAddress * remoteAddr
plNetAddress* localAddr,
plNetAddress* remoteAddr
) {
// NetAddress may be bigger than sockaddr_in so start by zeroing the whole thing
memset(localAddr, 0, sizeof(*localAddr));
memset(remoteAddr, 0, sizeof(*remoteAddr));
localAddr->Clear();
remoteAddr->Clear();
// don't have to enter critsect or validate socket before referencing it
// because this routine is called before the user has a chance to close it
@ -470,7 +469,7 @@ static bool SocketInitConnect (
//===========================================================================
static void SocketInitListen (
NtSock * const sock,
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
for (;;) {
@ -509,7 +508,7 @@ static void SocketInitListen (
}
//===========================================================================
static SOCKET ListenSocket (NetAddress * listenAddr) {
static SOCKET ListenSocket(plNetAddress* listenAddr) {
// create a new socket to listen
SOCKET s;
if (INVALID_SOCKET == (s = socket(AF_INET, SOCK_STREAM, 0))) {
@ -612,7 +611,7 @@ static void ListenPrepareListeners (fd_set * readfds) {
}
//===========================================================================
static SOCKET ConnectSocket (unsigned localPort, const NetAddress & addr) {
static SOCKET ConnectSocket (unsigned localPort, const plNetAddress& addr) {
SOCKET s;
if (INVALID_SOCKET == (s = socket(AF_INET, SOCK_STREAM, 0))) {
LogMsg(kLogError, "socket create failed");
@ -1126,12 +1125,12 @@ bool INtSocketOpCompleteQueuedSocketWrite (
//===========================================================================
unsigned NtSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
s_listenCrit.Enter();
StartListenThread();
NetAddress addr = listenAddr;
plNetAddress addr = listenAddr;
for (;;) {
// if the port is already open then just increment the reference count
if (ListenPortIncrement(addr, notifyProc, 1))
@ -1160,7 +1159,7 @@ unsigned NtSocketStartListening (
//===========================================================================
void NtSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
s_listenCrit.Enter();
@ -1171,7 +1170,7 @@ void NtSocketStopListening (
//===========================================================================
void NtSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,

View File

@ -88,7 +88,7 @@ bool W9xThreadWaitId (
);
void W9xSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
@ -126,11 +126,11 @@ void W9xSocketSetBacklogAlloc (
unsigned bufferSize
);
unsigned W9xSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);
void W9xSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);
void W9xSocketEnableNagling (

View File

@ -999,7 +999,7 @@ static LRESULT CALLBACK WndProc (
//===========================================================================
void W9xSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
@ -1148,7 +1148,7 @@ void W9xSocketDisconnect (
//===========================================================================
unsigned W9xSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
return 0;
@ -1157,7 +1157,7 @@ unsigned W9xSocketStartListening (
//===========================================================================
void W9xSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
}

View File

@ -89,7 +89,7 @@ static unsigned s_nextLookupCancelId = 1;
//===========================================================================
static void LookupProcess (Lookup * lookup, unsigned error) {
unsigned count = 0;
NetAddress * addrs = nil;
plNetAddress* addrs = nil;
if (error)
return;
@ -109,8 +109,7 @@ static void LookupProcess (Lookup * lookup, unsigned error) {
++count;
// allocate a buffer large enough to hold all the addresses
addrs = (NetAddress *)malloc(sizeof(*addrs) * count);
memset(addrs, 0, sizeof(*addrs) * count);
addrs = new plNetAddress[count];
// fill in address data
const uint16_t port = htons((uint16_t) lookup->port);
@ -134,7 +133,7 @@ static void LookupProcess (Lookup * lookup, unsigned error) {
delete lookup;
PerfSubCounter(kAsyncPerfNameLookupAttemptsCurr, 1);
free(addrs);
delete[] addrs;
}
//===========================================================================
@ -326,7 +325,7 @@ void AsyncAddressLookupName (
void AsyncAddressLookupAddr (
AsyncCancelId * cancelId, // out
FAsyncLookupProc lookupProc,
const NetAddress & address,
const plNetAddress& address,
void * param
) {
ASSERT(lookupProc);

View File

@ -106,7 +106,7 @@ typedef void (* FSleep) (unsigned sleepMs);
// Sockets
typedef void (* FAsyncSocketConnect) (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
@ -151,12 +151,12 @@ typedef void (* FAsyncSocketSetBacklogAlloc) (
);
typedef unsigned (* FAsyncSocketStartListening) (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);
typedef void (* FAsyncSocketStopListening) (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
);

View File

@ -206,7 +206,7 @@ static unsigned GetConnHash (
//===========================================================================
void AsyncSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
@ -293,7 +293,7 @@ void AsyncSocketSetBacklogAlloc (
//===========================================================================
unsigned AsyncSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
ASSERT(g_api.socketStartListening);
@ -302,7 +302,7 @@ unsigned AsyncSocketStartListening (
//===========================================================================
void AsyncSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc
) {
ASSERT(g_api.socketStopListening);