mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Cleaned up error handling in SPInit and updated changelog.
This commit is contained in:
parent
406b4710bc
commit
4266b85cc9
@ -10,6 +10,13 @@ Version 0.3.2:
|
|||||||
with extended addresses.
|
with extended addresses.
|
||||||
|
|
||||||
Bugfix: Don't choke on rpacket_header in ioctlsocket/FIONREAD.
|
Bugfix: Don't choke on rpacket_header in ioctlsocket/FIONREAD.
|
||||||
|
|
||||||
|
Feature: Log sent/received/relayed packets when call logging is enabled.
|
||||||
|
|
||||||
|
Feature: Log version/revision number and compile time during ipxwrapper.dll
|
||||||
|
initialisation.
|
||||||
|
|
||||||
|
Cleanup: Cleaned up error handling in SPInit.
|
||||||
|
|
||||||
Version 0.3.1:
|
Version 0.3.1:
|
||||||
Bugfix: Fixed deadlock in DirectPlay service provider.
|
Bugfix: Fixed deadlock in DirectPlay service provider.
|
||||||
|
@ -492,56 +492,38 @@ HRESULT WINAPI SPInit(LPSPINITDATA data) {
|
|||||||
|
|
||||||
struct sp_data *sp_data = malloc(sizeof(struct sp_data));
|
struct sp_data *sp_data = malloc(sizeof(struct sp_data));
|
||||||
if(!sp_data) {
|
if(!sp_data) {
|
||||||
return DPERR_UNAVAILABLE;
|
goto FAIL1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!InitializeCriticalSectionAndSpinCount(&(sp_data->lock), 0x80000000)) {
|
if(!InitializeCriticalSectionAndSpinCount(&(sp_data->lock), 0x80000000)) {
|
||||||
log_printf("Error creating critical section: %s", w32_error(GetLastError()));
|
log_printf("Error initialising critical section: %s", w32_error(GetLastError()));
|
||||||
|
goto FAIL2;
|
||||||
free(sp_data);
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((sp_data->event = WSACreateEvent()) == WSA_INVALID_EVENT) {
|
if((sp_data->event = WSACreateEvent()) == WSA_INVALID_EVENT) {
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
log_printf("Error creating WSA event object: %s", w32_error(WSAGetLastError()));
|
||||||
free(sp_data);
|
goto FAIL3;
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((sp_data->sock = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == -1) {
|
if((sp_data->sock = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == -1) {
|
||||||
WSACloseEvent(sp_data->event);
|
log_printf("Error creating IPX socket: %s", w32_error(WSAGetLastError()));
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
goto FAIL4;
|
||||||
free(sp_data);
|
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_ipx addr;
|
struct sockaddr_ipx addr;
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sa_family = AF_IPX;
|
addr.sa_family = AF_IPX;
|
||||||
addr.sa_socket = 0;
|
|
||||||
|
|
||||||
if(bind(sp_data->sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
if(bind(sp_data->sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||||
closesocket(sp_data->sock);
|
log_printf("Error binding IPX socket: %s", w32_error(WSAGetLastError()));
|
||||||
WSACloseEvent(sp_data->event);
|
goto FAIL5;
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
|
||||||
free(sp_data);
|
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int addrlen = sizeof(sp_data->addr);
|
int addrlen = sizeof(sp_data->addr);
|
||||||
|
|
||||||
if(getsockname(sp_data->sock, (struct sockaddr*)&(sp_data->addr), &addrlen) == -1) {
|
if(getsockname(sp_data->sock, (struct sockaddr*)&(sp_data->addr), &addrlen) == -1) {
|
||||||
log_printf("getsockname failed: %s", w32_error(WSAGetLastError()));
|
log_printf("getsockname failed: %s", w32_error(WSAGetLastError()));
|
||||||
|
goto FAIL5;
|
||||||
closesocket(sp_data->sock);
|
|
||||||
WSACloseEvent(sp_data->event);
|
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
|
||||||
free(sp_data);
|
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sp_data->ns_sock = -1;
|
sp_data->ns_sock = -1;
|
||||||
@ -554,25 +536,13 @@ HRESULT WINAPI SPInit(LPSPINITDATA data) {
|
|||||||
|
|
||||||
if(WSAEventSelect(sp_data->sock, sp_data->event, FD_READ) == -1) {
|
if(WSAEventSelect(sp_data->sock, sp_data->event, FD_READ) == -1) {
|
||||||
log_printf("WSAEventSelect failed: %s", w32_error(WSAGetLastError()));
|
log_printf("WSAEventSelect failed: %s", w32_error(WSAGetLastError()));
|
||||||
|
goto FAIL5;
|
||||||
closesocket(sp_data->sock);
|
|
||||||
WSACloseEvent(sp_data->event);
|
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
|
||||||
free(sp_data);
|
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT r = IDirectPlaySP_SetSPData(data->lpISP, sp_data, sizeof(*sp_data), DPSET_LOCAL);
|
HRESULT r = IDirectPlaySP_SetSPData(data->lpISP, sp_data, sizeof(*sp_data), DPSET_LOCAL);
|
||||||
if(r != DP_OK) {
|
if(r != DP_OK) {
|
||||||
log_printf("SetSPData: %d", (int)r);
|
log_printf("SetSPData: %d", (int)r);
|
||||||
|
goto FAIL5;
|
||||||
closesocket(sp_data->sock);
|
|
||||||
WSACloseEvent(sp_data->event);
|
|
||||||
DeleteCriticalSection(&(sp_data->lock));
|
|
||||||
free(sp_data);
|
|
||||||
|
|
||||||
return DPERR_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data->lpCB->EnumSessions = &IPX_EnumSessions;
|
data->lpCB->EnumSessions = &IPX_EnumSessions;
|
||||||
@ -589,6 +559,21 @@ HRESULT WINAPI SPInit(LPSPINITDATA data) {
|
|||||||
data->dwSPVersion = DPSP_MAJORVERSIONMASK & DPSP_MAJORVERSION;
|
data->dwSPVersion = DPSP_MAJORVERSIONMASK & DPSP_MAJORVERSION;
|
||||||
|
|
||||||
return DP_OK;
|
return DP_OK;
|
||||||
|
|
||||||
|
FAIL5:
|
||||||
|
closesocket(sp_data->sock);
|
||||||
|
|
||||||
|
FAIL4:
|
||||||
|
WSACloseEvent(sp_data->event);
|
||||||
|
|
||||||
|
FAIL3:
|
||||||
|
DeleteCriticalSection(&(sp_data->lock));
|
||||||
|
|
||||||
|
FAIL2:
|
||||||
|
free(sp_data);
|
||||||
|
|
||||||
|
FAIL1:
|
||||||
|
return DPERR_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user