Modifications to resolve issues found during self-code review.

This commit is contained in:
Juan Carlos Luciani
2006-12-08 05:45:03 +00:00
parent 9a0426279c
commit 8ade751650
34 changed files with 524 additions and 268 deletions

View File

@@ -390,9 +390,9 @@ CChannel::connectionThread(
{
CChannel *pCChannel = *pSmartCChannel;
bool doneReceivingData = false;
unsigned long bytesReceived;
int32_t bytesReceived;
uint32_t reqId;
int payloadLength;
int32_t payloadLength;
unsigned long totalPayloadBytesReceived = 0;
char reqDataPktHdr[ReqDataPktHdrTemplate.length()];
char *pRecvBuff;
@@ -441,7 +441,7 @@ CChannel::connectionThread(
&payloadLength))
{
// Procced based on the packet type
switch (ChannelProto::getPktType(*reqDataPktHdr))
switch (ChannelProto::getPktType(*reqDataPktHdr, sizeof(reqDataPktHdr)))
{
case ChannelProto::ReqDataCarrierPacketType:
@@ -747,7 +747,7 @@ CChannel::submitReq(
uint32_t reqId,
ClientReq &clientReq,
char *pClientData,
int clientDataLen)
int32_t clientDataLen)
//
// Arguments:
//

View File

@@ -222,7 +222,7 @@ public:
int submitReq(uint32_t reqId,
ClientReq &clientReq,
char *pClientData,
int clientDataLen);
int32_t clientDataLen);
//
// Remove Request routine

View File

@@ -354,8 +354,6 @@ IpcClientCloseRemoteEndPoint(
DbgTrace(0, "IpcClientCloseRemoteEndPoint- Not initialized\n", 0);
}
exit:
DbgTrace(1, "IpcClientCloseRemoteEndPoint- End, status = %0X\n", retStatus);
return retStatus;
@@ -368,9 +366,9 @@ int
IpcClientSubmitReq(
IN uint32_t endPointHandle,
IN char *pClientData,
IN int clientDataLen,
IN int32_t clientDataLen,
INOUT char **ppServerData,
INOUT int *pServerDataLen)
INOUT int32_t *pServerDataLen)
//
// Arguments In: endPointHandle - Handle of the remote endpoint that will
// be the target of the request.
@@ -410,6 +408,15 @@ IpcClientSubmitReq(
DbgTrace(1, "IpcClientSubmitReq- Start\n", 0);
// Verify input parameters
if (pClientData == NULL
|| ppServerData == NULL
|| pServerDataLen == NULL)
{
DbgTrace(0, "IpcClientSubmitReq- Invalid parameter\n", 0);
goto exit;
}
// Verify that we have been initialized
if (svcInitialized)
{
@@ -425,7 +432,7 @@ IpcClientSubmitReq(
// the request.
SmartRemoteEndPoint *pSmartRemoteEndPoint = new SmartRemoteEndPoint(*(iter->second));
// Release our mutex before deleting the endpoint
// Release our mutex before using the remote endpoint
pthread_mutex_unlock(&clientMutex);
// Submit the request
@@ -450,6 +457,8 @@ IpcClientSubmitReq(
DbgTrace(0, "IpcClientSubmitReq- Not initialized\n", 0);
}
exit:
DbgTrace(1, "IpcClientSubmitReq- End, retStatus = %0X\n", retStatus);
return retStatus;
@@ -498,7 +507,7 @@ IpcClientInit(
DbgTrace(1, "IpcClientInit- Start\n", 0);
// Check input parameters
if (pAppName == NULL)
if (pName == NULL)
{
DbgTrace(0, "IpcClientInit- Invalid parameter\n", 0);
goto exit;

View File

@@ -142,7 +142,7 @@ ClientReq::~ClientReq(void)
void
ClientReq::processServerData(
char *pServerData,
int serverDataLength)
int32_t serverDataLength)
//
// Arguments:
//
@@ -230,7 +230,7 @@ ClientReq::processError(void)
int
ClientReq::waitForCompletion(
char **ppResponseData,
int *pResponseDataLength)
int32_t *pResponseDataLength)
//
// Arguments:
//

View File

@@ -52,7 +52,7 @@ class ClientReq
// Server Data
char *m_pServerData;
int m_serverDataLen;
int32_t m_serverDataLen;
// Flag indicating the state of the submitting
// thread.
@@ -114,7 +114,7 @@ public:
// Returns: Nothing.
//
void processServerData(char *pServerData,
int serverDataLength);
int32_t serverDataLength);
//
// Process Error routine
@@ -147,7 +147,7 @@ public:
// -1 == Request did not complete gracefully
//
int waitForCompletion(char **ppResponseData,
int *pResponseDataLength);
int32_t *pResponseDataLength);
//
// Completion status

View File

@@ -80,31 +80,41 @@ RemoteEndPoint::RemoteEndPoint(
{
DbgTrace(1, "RemoteEndPoint::RemoteEndPoint- Start, Obj = %0X\n", this);
// Initialize our mutex
pthread_mutex_init(&m_mutex, NULL);
// Verify that the specified path is not too long
if (strlen(pSocketFileName) < sizeof(sizeof(m_serverUnAddr.sun_path)))
{
// Initialize our mutex
pthread_mutex_init(&m_mutex, NULL);
// Set the necessary information in the m_serverUnAddr variable
m_serverUnAddr.sun_family = AF_UNIX;
strcpy(m_serverUnAddr.sun_path, pSocketFileName);
// Set the necessary information in the m_serverUnAddr variable
m_serverUnAddr.sun_family = AF_UNIX;
strncpy(m_serverUnAddr.sun_path, pSocketFileName, sizeof(m_serverUnAddr.sun_path) - 1);
// Set the necessary flags to indicate that DOMAIN sockets
// should be used for communications.
m_Use_PF_UNIX = true;
m_Use_AF_INET = false;
// Set the necessary flags to indicate that DOMAIN sockets
// should be used for communications.
m_Use_PF_UNIX = true;
m_Use_AF_INET = false;
// Setup the number of channels that we may have based on
// whether the application is multi-threaded or not.
if (multithreaded)
m_numCChannels = MAX_CHANNELS_PER_ENDPOINT;
// Setup the number of channels that we may have based on
// whether the application is multi-threaded or not.
if (multithreaded)
m_numCChannels = MAX_CHANNELS_PER_ENDPOINT;
else
m_numCChannels = 1;
// Instantiate entries in SmartCChannel vector
try {
for (int i = 0; i < m_numCChannels; i++)
m_cchannelVector.push_back(SmartCChannelPointer());
} catch (...) {
DbgTrace(0, "RemoteEndPoint::RemoteEndPoint- Exception caught while initializing the cchannelVector\n", 0);
pthread_mutex_destroy(&m_mutex);
throw bad_alloc();
}
}
else
m_numCChannels = 1;
// Instantiate entries in SmartCChannel vector
try {
for (int i = 0; i < m_numCChannels; i++)
m_cchannelVector.push_back(SmartCChannelPointer());
} catch (...) {
DbgTrace(0, "RemoteEndPoint::RemoteEndPoint- Exception caught while initializing the cchannelVector\n", 0);
{
DbgTrace(0, "RemoteEndPoint::RemoteEndPoint- Socket file path name too long\n", 0);
throw bad_alloc();
}
@@ -166,6 +176,7 @@ RemoteEndPoint::RemoteEndPoint(
m_cchannelVector.push_back(SmartCChannelPointer());
} catch (...) {
DbgTrace(0, "RemoteEndPoint::RemoteEndPoint- Exception caught while initializing the cchannelVector\n", 0);
pthread_mutex_destroy(&m_mutex);
throw bad_alloc();
}
@@ -259,7 +270,7 @@ RemoteEndPoint::getCChannel(void)
m_cchannelVector[channelSelector].setPointer(NULL);
}
CChannel *pCChannel;
CChannel *pCChannel = NULL;
try {
// Use the appropriate server address when instantiating
@@ -325,9 +336,9 @@ RemoteEndPoint::getCChannel(void)
int
RemoteEndPoint::submitReq(
char *pClientData,
int clientDataLen,
int32_t clientDataLen,
char **ppServerData,
int *pServerDataLen)
int32_t *pServerDataLen)
//
// Arguments:
//

View File

@@ -186,9 +186,9 @@ public:
// Note: The routine blocks until the request completes.
//
int submitReq(char *pClientData,
int clientDataLen,
int32_t clientDataLen,
char **ppServerData,
int *pServerDataLen);
int32_t *pServerDataLen);
};
typedef SmartPtr<RemoteEndPoint> SmartRemoteEndPoint;