[Ace-users] [ace-users] [strategy connector]: howto ?

Mateusz Berezecki mateusz.berezecki at meme.pl
Fri Mar 7 13:16:40 CST 2008


     ACE VERSION: 5.6.3

     HOST MACHINE and OPERATING SYSTEM: Mac OS X Leopard 10.5.2

     COMPILER NAME AND VERSION (AND PATCHLEVEL): i686-apple-darwin9- 
gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

     DOES THE PROBLEM AFFECT: EXECUTION

     SYNOPSIS:
	Trying to use strategy connector with cached connect strategy as
	found in ACE-tutorial.pdf by Umar Syyid results in Bus Error.

     DESCRIPTION:

The detailed error from gdb is below:
	Program received signal EXC_BAD_ACCESS, Could not access memory.  
Reason: KERN_PROTECTION_FAILURE at address: 0x00000014 0x00003975 in  
ACE_Recyclable::recycle_state (this=warning: .o file "/Users/m/ 
Downloads/ACE_wrappers/build/ace/.libs/libACE_la-Recyclable.o" more  
recent than executable timestamp 0x10) at Recyclable.inl:10 10 return  
this->recycle_state_;

(gdb) p this
$1 = (class ACE_Recyclable * const) 0x10


I created the strategy connector as follows:

typedef ACE_Acceptor<TcpTransport, ACE_SOCK_ACCEPTOR>  
TcpTransportAcceptor;

typedef ACE_Strategy_Connector<TcpTransport, ACE_SOCK_CONNECTOR>  
TcpTransportConnector;

typedef ACE_NOOP_Creation_Strategy<TcpTransport> NoopCreation;
typedef ACE_NOOP_Concurrency_Strategy<TcpTransport> NoopConcurrency;

typedef ACE_Cached_Connect_Strategy<TcpTransport,
		ACE_SOCK_CONNECTOR, ACE_SYNCH_RW_MUTEX> CachedConnect;

<snip>

   ACE_INET_Addr port_to_listen(3333);
         ACE_INET_Addr port_to_connect(3333, ACE_LOCALHOST);

         TcpTransportAcceptor acceptor;

         NoopCreation noop_create;
         NoopConcurrency noop_concurrency;
         CachedConnect cached_connect;
         TcpTransportConnector connector(ACE_Reactor::instance(),
         			&noop_create, &cached_connect, &noop_concurrency);

         TcpTransport transport;
         TcpTransport *pt = &transport;

         if (acceptor.open(port_to_listen) == -1)
         	return 1;

         if (connector.connect(pt, port_to_connect) == -1)
         	return 1;

         ACE_Reactor::instance()->run_reactor_event_loop();


The TcpTransport declaration is:

class TcpTransport : public Transport {
public:
         TcpTransport() : notifier_(0, this,  
ACE_Event_Handler::WRITE_MASK)
         {
         }

         TcpTransport(ACE_Thread_Manager*&) : notifier_(0, this,  
ACE_Event_Handler::WRITE_MASK) { }

         virtual int route(const Peer& dest, const Message& msg);

         virtual int open(void *p = 0);
         virtual int handle_input(ACE_HANDLE fd = ACE_INVALID_HANDLE);
         virtual int handle_output(ACE_HANDLE fd = ACE_INVALID_HANDLE);
         virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask  
close_mask);
         virtual void factory(MessageFactory*);

         int recycle(void *a = 0) { return 0; }

private:
		typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH> super;
		ACE_Reactor_Notification_Strategy notifier_;
		MessageFactory *factory_;
		ACE_Recyclable_State recycle_state_;
};


whereas Transport is defined as

class Transport : public ACE_Svc_Handler<ACE_SOCK_STREAM,  
ACE_MT_SYNCH> {
public:
         virtual int route(const Peer& dest, const Message& msg) = 0;
};

I played around in the GDB and here's what I found in check_hint_i ()

660       // Get the recycling act for the svc_handler
661       CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY  
*) sh->recycling_act ();
662
663       // Check to see if the hint svc_handler has been closed down
664       if (possible_entry->ext_id_.recycle_state () ==  
ACE_RECYCLABLE_CLOSED)


now I do not define the recycling_act() function anywhere in my classes.
Should I do that? If yes, then why and what are the semantics of this  
method. What does it
exactly do?

In my case sh->recycling_act() returns NULL so the
possible_entry->ext_id_.recycle_state() will obviously fail.

The question is why recycling_act() returns null and what should it  
return
instead if implemented on my own ? what are the semantics of void *  
returned
by recycling_act ?

Or simply put, how do I use cached_connect strategy :)


best regards,
Mateusz Berezecki



More information about the Ace-users mailing list