Menu

unlocking mutexes

Help
Erez
2008-06-02
2020-09-04
  • Erez

    Erez - 2008-06-02

    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;
            }

     
    • Erez

      Erez - 2008-06-02

      please ignore this message!

       
  • Donald1010

    Donald1010 - 2020-09-04

    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

     

Log in to post a comment.