thanks Achal for your last response.
I have a question regarding closing mutexes under error conditions.
In the main method (processRequest) usually when we encouter an error condition we reort it and "continue".
Should not we close mutexes
For example:
req.m_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (req.m_socket == -1)
{
req.serverError.opcode = htons(5);
req.serverError.errorcode = htons(0);
strcpy(req.serverError.errormessage, "Thread Socket Creation Error");
req.bytesSent = sendto(req.knock, (const char*)&req.serverError,
strlen(req.serverError.errormessage) + 5, 0, (sockaddr*)&req.client, req.clientsize);
logMess(&req, 1);//goes to debug log
continue;
}
should be
The mutex can be opened and crushed by calling following two capacities :The principal work delivers the lock and the subsequent capacity devastates the lock so it can't be utilized anyplace in future. int pthread_mutex_unlock(pthread_mutex_t *mutex) : Releases a mutex object
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
thanks Achal for your last response.
I have a question regarding closing mutexes under error conditions.
In the main method (processRequest) usually when we encouter an error condition we reort it and "continue".
Should not we close mutexes
For example:
req.m_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (req.m_socket == -1)
{
req.serverError.opcode = htons(5);
req.serverError.errorcode = htons(0);
strcpy(req.serverError.errormessage, "Thread Socket Creation Error");
req.bytesSent = sendto(req.knock, (const char*)&req.serverError,
strlen(req.serverError.errormessage) + 5, 0, (sockaddr*)&req.client, req.clientsize);
logMess(&req, 1);//goes to debug log
continue;
}
should be
req.m_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (req.m_socket == -1)
{
req.serverError.opcode = htons(5);
req.serverError.errorcode = htons(0);
strcpy(req.serverError.errormessage, "Thread Socket Creation Error");
req.bytesSent = sendto(req.knock, (const char*)&req.serverError, strlen(req.serverError.errormessage) + 5, 0, (sockaddr*)&req.client, req.clientsize);
logMess(&req, 1);//goes to debug log
continue;
}
please ignore this message!
The mutex can be opened and crushed by calling following two capacities :The principal work delivers the lock and the subsequent capacity devastates the lock so it can't be utilized anyplace in future. int pthread_mutex_unlock(pthread_mutex_t *mutex) : Releases a mutex object