[ace-users] Init for svc

JR Andreassen janrune at io.com
Mon Sep 24 17:09:44 CDT 2007


Hi Steve..

Steve Huston wrote:

>Hi JR,
>  
>
>>Hi All...
>> Quick question for you....
>>But first...
>>
>>    ACE VERSION: 5.5.9
>>    HOST MACHINE and OPERATING SYSTEM:    Win XP, sp1
>>    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
>>
>>    COMPILER NAME AND VERSION:     VC++ 8.0(MSVC 2005) & VC6
>>
>>    CONTENTS OF $ACE_ROOT/ace/config.h
>>#if !defined (_WIN32_WCE)
>>#    define ACE_ENABLE_SWAP_ON_WRITE
>>//#    define ACE_DISABLE_SWAP_ON_READ
>>#    define ACE_DISABLE_WIN32_ERROR_WINDOWS
>>#    define ACE_HAS_STANDARD_CPP_LIBRARY 1
>>#endif
>>#include "ace/config-win32.h"
>>    
>>
>I'm using my onw Exception handling and need to initialize it for the 
>  
>
>>svc thread.
>>Where whould it be best to hook in the initialization ???
>>    
>>
>
>Is this for a Service Config framework-loaded service? 
>
Yes

>If so, can you do the initialize in the service's init() hook, or its svc() hook
>itself?
>  
>
Yes...

Actualy I  sent the question off a little too quick.
The svc runs in the main(entry) trhead that is already initialized(since 
I have to initialize teh exception handling in each thread)
The problem is that I keep getting 'ACCESS Violations', without the 
expected thread dump.
and I thought I had all my threads are accounted for. :)

It should look something like:
(2007-09-24 15:04:02.131|5276)    
c:\c_projects\sdi_lib\src\sdi\ace\net\sockstream_event_handler.cpp(500) 
catch(exception e&)[SEH:[0xC0000005]EXCEPTION_ACCESS_VIOLATION @ 
100A62C1, Bad Read ]
+ stack dump
....

What I get is:
(2007-09-23 02:06:53.843|1040)    
[SOCK_SC]SOCK_SC[0x009F5858]::handle_input() Receive MB failed 
10053[ECONNABORTED/Unknown error]
ERROR: ACCESS VIOLATION
ERROR: ACCESS VIOLATION
....

I have try  catch blocks arroud the

Well, I guess I'll have to keep looking...
  Thanks
     JR

typedef SDIACE_EXPORT ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>    
        ACE_SockStream_MTSYNCH;

class SDIACE_EXPORT SOCKStream_Client
    :public ACE_SockStream_MTSYNCH

// 
----------------------------------------------------------------------------
/**
 *  Read Data from port
 * @param    peer        Connection to read from
 * @parm    buff        Buffer to fill
 * @parm    buffsz        Size of Buffer to fill
 * @parm    tottransf    Return bytecount read
 * @return    Last return code from recive
 */
int SOCKStream_Client::handle_input(ACE_HANDLE fd)
{
    int retVal = ACE_GOOD_RETURN_VALUE;
    try
    {
        retVal = _handle_input(fd);
    }
    catch(SDI::MErrorObject& err)
    {   
        if(err.getErrSeverity() >= SDI::MErrorObject::Fatal)
        {    retVal = ACE_BAD_RETURN_VALUE;}
        SDI::GlobalDebug::Exception(err, THIS_FILE, __LINE__, 
"[SOCK_SC]%s[0x%p]::handle_input() Enqueue MB failed", getTaskName(), this);
    }
    catch(...)
    {    retVal = ACE_BAD_RETURN_VALUE;
        SDI::GlobalDebug::Exception("...", THIS_FILE, __LINE__, 
"[SOCK_SC]%s[0x%p]::handle_input() Enqueue MB failed", getTaskName(), this);
    }
  return retVal;
}

int SOCKStream_Client::handle_output(ACE_HANDLE fd)
{
    int retVal = ACE_GOOD_RETURN_VALUE;
    try
    {
        retVal = _handle_output(fd);
    }
    catch(SDI::MErrorObject& err)
    {   
        if(err.getErrSeverity() >= SDI::MErrorObject::Fatal)
        {    retVal = ACE_BAD_RETURN_VALUE;}
        SDI::GlobalDebug::Exception(err, THIS_FILE, __LINE__, 
"[SOCK_SC]%s[0x%p]::handle_input() Enqueue MB failed", getTaskName(), this);
    }
    catch(...)
    {    retVal = ACE_BAD_RETURN_VALUE;
        SDI::GlobalDebug::Exception("...", THIS_FILE, __LINE__, 
"[SOCK_SC]%s[0x%p]::handle_input() Enqueue MB failed", getTaskName(), this);
    }
  return retVal;
}

// 
----------------------------------------------------------------------------
/**
 *  Read Data from port
 * @param    peer        Connection to read from
 * @parm    buff        Buffer to fill
 * @parm    buffsz        Size of Buffer to fill
 * @parm    tottransf    Return bytecount read
 * @return    Last return code from recive
 */
int SOCKStream_Client::_handle_input(ACE_HANDLE fd)
{
    int retVal = ACE_GOOD_RETURN_VALUE;
    if(!ISNULL(getMBToSend()) && getDebugLevel())
    {    SDI::GlobalDebug::Debug("[SOCK_SC]%s[0x%p]::_handle_input() 
Have cached on entryMB[0x%p]", getTaskName(), this, getMBToSend());
    }
    sendSavedMB(0);
    // Extend timeout
    resetTimeout();
//    ACE_Message_Block* mb = allocateMessageBlock(NULL, m_iPayloadLen, 
SDI_PROTOCOL_FLAG_DATA_IN);
    ACE_Message_Block* mb = getCurrInbMessageBlock();
    bool sendmessge = false;
    if(!ISNULL(mb))
    {
        SSIZE_T recv_cnt = 0;
        SSIZE_T recv_tot = 0;
        do
        {
            recv_cnt = this->peer ().recv (mb->wr_ptr(), mb->space() - 1);
            if (recv_cnt > 0)
            {
                mb->wr_ptr(recv_cnt);
                // terminate block
                sendmessge = true;
                retVal = ACE_GOOD_RETURN_VALUE;
                recv_tot += recv_cnt;

            }
            else if(recv_cnt == 0) // No More Data
            {
                sendmessge = true;
                retVal = ACE_GOOD_RETURN_VALUE;
            }
            else if (recv_cnt < 0)
            {
//                
SDI::GlobalDebug::Debug("[SOCK_SC]%s[0x%p]::handle_input() Peer Closed", 
getTaskName(), this);
                retVal = handleIOError("handle_input()", "Receive MB 
failed");
//                if(!ACE_IS_GOOD_RETURN_STATUS(retVal))
//                {    mb = releaseMessageBlock(mb);}
            }
        } while(ACE_IS_GOOD_RETURN_STATUS(retVal) && mb->space() > 1 && 
recv_cnt > 0);
 // ----------------------------------------------------------
        if(sendmessge)
        {
            SDI::ACE_Utils::terminateMessage(mb);
            sendSavedMB();
        }
    }
  return retVal;
}



More information about the Ace-users mailing list