Skip to main content

VBC All Versions - How to avoid an orb exception from resulting in unreleased application mutex lock ?

  • February 16, 2013
  • 0 replies
  • 0 views

Problem:

  • Product Name : VisiBroker C
  • Product Version: All
  • Platform : All

Application process has a thread showing the following sequence for example :

Frame 1 : VBC orb call
Frame 2 : Application call
Frame 3 : VBC orb call

Is it possible that while the application call is being processed(frame 2), an exception is raised from the orb call in frame 1, and is caught in the orb call in frame 3 (and resulting in the applicationin an unstable state) ?

Resolution:

Yes, it is possible, if the application call does not catch the exception thrown by frame 1.
The following suggestion can be implemented to eliminate a situation in which the application fails to release a lock in case of an exception :
Application can use smart pointer (auto_ptr) in the application code if it is acquiring a mutex lock.The constructor of the smart pointer acquires the lock; and the destructor releases the lock.This way the lock is released when the smart pointer goes out of scope.


#c
#C
#mutex
#smartpointer
#VisiBroker
#Security