Commit 4c387227 authored by Mike Gabriel's avatar Mike Gabriel

nxcomp/src/Loop.cpp: Avoid duplicate usage of proxyFD (global variable) and…

nxcomp/src/Loop.cpp: Avoid duplicate usage of proxyFD (global variable) and *proxyFD (function parameter).
parent 5a7b589b
...@@ -450,8 +450,8 @@ static int AcceptConnection(int fd, int domain, const char *label); ...@@ -450,8 +450,8 @@ static int AcceptConnection(int fd, int domain, const char *label);
// Other convenience functions. // Other convenience functions.
// //
static int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, int* proxyFD, int* reason); static int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, int* proxyFileDescriptor, int* reason);
static int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* reason); static int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFileDescriptor, int* reason);
static int WaitForRemote(ChannelEndPoint &socketAddress); static int WaitForRemote(ChannelEndPoint &socketAddress);
static int ConnectToRemote(ChannelEndPoint &socketAddress); static int ConnectToRemote(ChannelEndPoint &socketAddress);
...@@ -6914,18 +6914,18 @@ WaitForRemoteError: ...@@ -6914,18 +6914,18 @@ WaitForRemoteError:
HandleCleanup(); HandleCleanup();
} }
int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, int* proxyFD, int* reason) int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, int* proxyFileDescriptor, int* reason)
{ {
if (!proxyFD) if (!proxyFileDescriptor)
{ {
#ifdef PANIC #ifdef PANIC
*logofs << "Loop: PANIC! Implementation error (PrepareProxyConnectionTCP). " *logofs << "Loop: PANIC! Implementation error (PrepareProxyConnectionTCP). "
<< "'proxyFD' must not be a NULL pointer.\n" << logofs_flush; << "'proxyFileDescriptor' must not be a NULL pointer.\n" << logofs_flush;
#endif #endif
cerr << "Error" << ": Implementation error (PrepareProxyConnectionTCP). " cerr << "Error" << ": Implementation error (PrepareProxyConnectionTCP). "
<< "'proxyFD' must not be a NULL pointer.\n"; << "'proxyFileDescriptor' must not be a NULL pointer.\n";
return -1; return -1;
} }
...@@ -6966,7 +6966,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, ...@@ -6966,7 +6966,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout,
<< *hostName << ":" << *portNum << "'.\n" << *hostName << ":" << *portNum << "'.\n"
<< logofs_flush; << logofs_flush;
*proxyFD = -1; *proxyFileDescriptor = -1;
*reason = -1; *reason = -1;
sockaddr_in addr; sockaddr_in addr;
...@@ -6974,10 +6974,10 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, ...@@ -6974,10 +6974,10 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout,
addr.sin_port = htons(*portNum); addr.sin_port = htons(*portNum);
addr.sin_addr.s_addr = remoteIPAddr; addr.sin_addr.s_addr = remoteIPAddr;
*proxyFD = socket(AF_INET, SOCK_STREAM, PF_UNSPEC); *proxyFileDescriptor = socket(AF_INET, SOCK_STREAM, PF_UNSPEC);
*reason = EGET(); *reason = EGET();
if (*proxyFD == -1) if (*proxyFileDescriptor == -1)
{ {
#ifdef PANIC #ifdef PANIC
*logofs << "Loop: PANIC! Call to socket failed. " *logofs << "Loop: PANIC! Call to socket failed. "
...@@ -6991,7 +6991,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, ...@@ -6991,7 +6991,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout,
return -1; return -1;
} }
else if (SetReuseAddress(*proxyFD) < 0) else if (SetReuseAddress(*proxyFileDescriptor) < 0)
{ {
return -1; return -1;
} }
...@@ -7006,7 +7006,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, ...@@ -7006,7 +7006,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout,
else else
SetTimer(20000); SetTimer(20000);
int result = connect(*proxyFD, (sockaddr *) &addr, sizeof(sockaddr_in)); int result = connect(*proxyFileDescriptor, (sockaddr *) &addr, sizeof(sockaddr_in));
*reason = EGET(); *reason = EGET();
...@@ -7016,18 +7016,18 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, ...@@ -7016,18 +7016,18 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout,
} }
int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* reason) int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFileDescriptor, int* reason)
{ {
if (!proxyFD) if (!proxyFileDescriptor)
{ {
#ifdef PANIC #ifdef PANIC
*logofs << "Loop: PANIC! Implementation error (PrepareProxyConnectionUnix). " *logofs << "Loop: PANIC! Implementation error (PrepareProxyConnectionUnix). "
<< "proxyFD must not be a NULL pointer.\n" << logofs_flush; << "proxyFileDescriptor must not be a NULL pointer.\n" << logofs_flush;
#endif #endif
cerr << "Error" << ": Implementation error (PrepareProxyConnectionUnix). " cerr << "Error" << ": Implementation error (PrepareProxyConnectionUnix). "
<< "proxyFD must not be a NULL pointer.\n"; << "proxyFileDescriptor must not be a NULL pointer.\n";
return -1; return -1;
} }
...@@ -7047,17 +7047,17 @@ int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* rea ...@@ -7047,17 +7047,17 @@ int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* rea
/* FIXME: Add socket file existence and permission checks */ /* FIXME: Add socket file existence and permission checks */
*proxyFD = -1; *proxyFileDescriptor = -1;
*reason = -1; *reason = -1;
sockaddr_un addr; sockaddr_un addr;
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, *path, 108 - 1); strncpy(addr.sun_path, *path, 108 - 1);
*proxyFD = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC); *proxyFileDescriptor = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC);
*reason = EGET(); *reason = EGET();
if (*proxyFD == -1) if (*proxyFileDescriptor == -1)
{ {
#ifdef PANIC #ifdef PANIC
*logofs << "Loop: PANIC! Call to socket failed. " *logofs << "Loop: PANIC! Call to socket failed. "
...@@ -7082,7 +7082,7 @@ int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* rea ...@@ -7082,7 +7082,7 @@ int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFD, int* rea
else else
SetTimer(20000); SetTimer(20000);
int result = connect(*proxyFD, (sockaddr *) &addr, sizeof(sockaddr_un)); int result = connect(*proxyFileDescriptor, (sockaddr *) &addr, sizeof(sockaddr_un));
*reason = EGET(); *reason = EGET();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment