[ 
https://issues.apache.org/jira/browse/QPID-2076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steve Huston updated QPID-2076:
-------------------------------

    Attachment: QPID-2076.diff

Diffs attached to resolve this issue. Since this requires a change to existing 
message store modules, I have not checked this in. Please review it this week 
if you maintain a message store plugin. If I don't hear anything more by Friday 
Sept 25, I'll commit the changes.

The existing use cases can change to this scheme by constructing a 
boost::shared_ptr with the newly allocated message store pointer and passing it 
instead of the naked pointer.

FYI, the case where the store should not be deleted ever is effected by:

  class NoopDeleter {
  public:
      NoopDeleter() {}
      void operator()(qpid::broker::MessageStore *p) {}
  };

....

    NoopDeleter d;
    boost::shared_ptr<qpid::broker::MessageStore> sp(this, d);
    broker->setStore(sp);


> C++ Broker assumes it can delete a pointer passed by message store plugin
> -------------------------------------------------------------------------
>
>                 Key: QPID-2076
>                 URL: https://issues.apache.org/jira/browse/QPID-2076
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.5
>            Reporter: Steve Huston
>         Attachments: QPID-2076.diff
>
>
> The 0.5 broker/message-store plugin arrangement has the plugin allocating an 
> object derived from MessageStore and calling 
> qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal 
> operation to invoke methods through the pointer.
> The passed MessageStore pointer is stored in a std::auto_ptr and the Broker 
> destruction deletes the store. This is not valid in all cases. Particularly, 
> on Windows, different DLLs can have different heaps. Memory allocated in one 
> DLL (such as a plugin) can often not be deleted from a different DLL or 
> executable (such as the broker) - it looks like freeing memory which was 
> never allocated.
> It also may be desireable in some cases to pass a pointer to 
> qpid::broker::Broker::setStore() that is not dynamically allocated.
> I propose changing the store pointer in qpid::broker::Broker from 
> std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to 
> control if, when, and how the memory is released.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to