On Wed, 2006-11-08 at 15:36 +0100, Piotr Szymanek wrote:
> Hello
> 
> I find some causes Acces Violation.
> and usage 100% cpu if network is not avilable.
> 
> file SipXMediaLib/src/mp/NetInTask.cpp
> //-----------------------------------------------
> 
> function int NetInTask::getWriteFD()
> 
>     sLock.releaseRead();
> -  return mpWriteSocket->getSocketDescriptor();
> 
> + if(mpWriteSocket)
> +  return mpWriteSocket->getSocketDescriptor();
> + else return 0;
> 
> //---------------------------------------------

In sipX Main, I see this code.  The 'if' at the top of getWriteFD
prevents getSocketDescriptor from being called if mpWriteSocket is null:


int NetInTask::getWriteFD()
{
    if (NULL != mpWriteSocket) {
        return mpWriteSocket->getSocketDescriptor();
    }

    // connect to the socket
    sLock.acquireRead();
    if (NULL != mpWriteSocket) {
        sLock.releaseWrite();
        return mpWriteSocket->getSocketDescriptor();
    }

    if (OsTask::getCurrentTask() == NetInTask::spInstance) {
        OsEvent* pNotify;
        NetInTaskHelper* pHelper;

        // Start our helper thread to go open the socket
        pNotify = new OsEvent;
        pHelper = new NetInTaskHelper(this, pNotify);
        if (!pHelper->isStarted()) {
            pHelper->start();
        }
        pNotify->wait();
        delete pHelper;
        delete pNotify;
    } else {
        // we are in a different thread already, go do it ourselves.
        osPrintf("Not NetInTask: opening connection directly\n");
        OsSysLog::add(FAC_MP, PRI_DEBUG, "Not NetInTask: opening connection 
directly\n");
        openWriteFD();
    }
    sLock.releaseRead();
    return mpWriteSocket->getSocketDescriptor();
}


> function int NetInTask::run(void *pNotUsed)
> 
> 
> #endif /* DEBUG_BY_SUSPEND ] */
> 
> /* is it a request to modify the set of file descriptors? */
> - if (FD_ISSET(mpReadSocket->getSocketDescriptor(), fds)) {
> -                numReady--;
> -                if (NET_TASK_MAX_MSG_LEN !=
> -                     mpReadSocket->read((char *) &msg, 
> NET_TASK_MAX_MSG_LEN)) {
> -                    osPrintf("NetInTask::run: Invalid request!\n");
> -                    } else if (-2 == (int) msg.pRtpSocket) {
> 
> + if (mpReadSocket && FD_ISSET(mpReadSocket->getSocketDescriptor(), fds)) {
> +               numReady--;
> +               if (NET_TASK_MAX_MSG_LEN !=
> +                    mpReadSocket->read((char *) &msg, 
> NET_TASK_MAX_MSG_LEN)) {
> +                   osPrintf("NetInTask::run: Invalid request!\n");
> +                   ::Sleep(100); //Not occur 100% cpu for example if 
> network is not available
> +               } else if (-2 == (int) msg.pRtpSocket) {
> 
> //-------------------------------------


In sipX Main, this code is wrapped in a while that ensures mpReadSocket
is non-null:


        while (mpReadSocket && mpReadSocket->isOk()) {


Dale


_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to