Bug 1230 - Problems with usage of reactor->notify () calls within the ORB
Summary: Problems with usage of reactor->notify () calls within the ORB
Status: RESOLVED FIXED
Alias: None
Product: TAO
Classification: Unclassified
Component: ORB (show other bugs)
Version: 1.2.3
Hardware: All All
: P3 normal
Assignee: Nanbor Wang
URL:
Depends on:
Blocks: 1202
  Show dependency tree
 
Reported: 2002-06-18 13:31 CDT by Nanbor Wang
Modified: 2002-07-03 12:46 CDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nanbor Wang 2002-06-18 13:31:59 CDT
The notify  () calls in the critical path creates dangling references to
connection handlers within the ORB. 
When the ORB is doing something like this:

1 Receive two simultaneous requests on one event handler.
2 Queue the second request using the notify() trick.
3 Send the response to the first request.
4 Ooops, the connection is broken (client died), close the connection.
5 Delete the event handler.
6 Dequeue the notification and try to use the event handler.
7 Ooooooooooops, the event handler in the notification pipe/queue is invalid
8 Crash.

Solutions like purging the notify calls between 4 and 5 dont work if the notify
mechanism used is a pipe. There are two possible solutions to this. Both of them
are centered around incrementing the refcount of the connection handler. Here
are the ideas 

- Increase the reference count every time the Connection_Handler is put through
the notification mechanism.  Then decrement the count on handle_input(), but
only if the ACE_HANDLE parameter is ACE_INVALID_HANDLE.    This only works if
notifications have an invalid handle, while normal events have the right handle.
 Reading the code confirms this, but I'm not sure if there is a "promise" that
this will be the case.

- Instead of sending a notification to the TAO_Connection_Handler create a
helper Event_Handler, something like:

class TAO_Notifier : public ACE_Event_Handler
{
public:
  TAO_Notifier (TAO_Connection_Handler * ch) : ch_(ch)
  {
     // increase ch refcount
  }
  virtual ~TAO_Notifier()
  {
     // decreate ch refcount
  }
  virtual int handle_input(ACE_HANDLE h)
  {
    (void) ch_->handle_input(ch);
    return -1; // Automatically commit suicide...
  }
}

Thus the temporary object is created for each notification, and it
automatically keeps the reference count too.

In both cases we need to ensure that all notifications are indeed executed,
otherwise we will leak resources at the end of the day.
Comment 1 Nanbor Wang 2002-06-18 13:33:20 CDT
Assigning the bug to me since I would be working on it
Comment 2 Nanbor Wang 2002-06-18 13:34:02 CDT
Accepting the bug
Comment 3 Nanbor Wang 2002-07-03 12:46:37 CDT
This should be fixed now and here is the ChangeLog entry


Tue Jul  2 15:46:14 2002  Balachandran Natarajan  <bala@cs.wustl.edu>