2 #include "tao/ORB_Core.h"
3 #include "ace/Reverse_Lock_T.h"
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 TAO_Stub::reset_base ()
10 this->base_profiles_.rewind ();
11 this->profile_success_ = false;
13 this->set_profile_in_use_i (base_profiles_.get_next ());
17 ACE_INLINE const TAO_SYNCH_MUTEX&
18 TAO_Stub::profile_lock () const
20 return this->profile_lock_;
24 TAO_Stub::reset_forward ()
26 while (this->forward_profiles_ != 0
27 && this->forward_profiles_ != this->forward_profiles_perm_) // Disturbingly the permanent
28 // forwarded profile lives at the bottom
29 // of this stack if it exists. Avoid deleting it.
30 this->forward_back_one ();
34 TAO_Stub::reset_profiles_i ()
36 this->reset_forward ();
39 if (this->forward_profiles_perm_)
41 // The *permanent* forward is being kept in the transient
42 // forward queue (??!). We have just nuked it. Put it back the way it was.
43 // reset_base should have reset the profile success.
44 // @todo We have knives in the spoon draw - TAO_Stub needs total rewrite.
45 this->forward_profiles_ = this->forward_profiles_perm_;
46 this->forward_profiles_->rewind ();
47 this->set_profile_in_use_i (this->forward_profiles_->get_next ());
52 TAO_Stub::reset_profiles ()
54 ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX,
56 this->profile_lock_));
57 if (TAO_debug_level > 5)
59 TAOLIB_DEBUG ((LM_DEBUG,
60 ACE_TEXT ("TAO (%P|%t) - Stub::reset_profiles, acquired ")
61 ACE_TEXT ("profile lock this = 0x%x\n"),
65 this->reset_profiles_i ();
68 ACE_INLINE TAO_Profile *
69 TAO_Stub::profile_in_use ()
71 return this->profile_in_use_;
74 ACE_INLINE TAO_MProfile *
75 TAO_Stub::make_profiles ()
80 TAO_MProfile (base_profiles_),
86 ACE_INLINE TAO_Profile *
87 TAO_Stub::next_forward_profile ()
89 TAO_Profile *pfile_next = 0;
91 while (this->forward_profiles_
92 && (pfile_next = this->forward_profiles_->get_next ()) == 0
93 && this->forward_profiles_ != this->forward_profiles_perm_) // do not remove permanent forward from bottom of stack
94 // that was the last profile. Now we clean up our forward profiles.
95 // since we own the forward MProfiles, we must delete them when done.
96 this->forward_back_one ();
101 ACE_INLINE TAO_Profile *
102 TAO_Stub::next_profile_i ()
104 TAO_Profile *pfile_next = 0;
106 // First handle the case that a permanent forward occurred
107 if (this->forward_profiles_perm_) // the permanent forward defined
108 // at bottom of stack
111 // In case of permanent forward the base_profiles are ingored.
113 pfile_next = this->next_forward_profile ();
117 // COND: this->forward_profiles_ == this->forward_profiles_perm_
119 // reached end of list of permanent forward profiles
120 // now, reset forward_profiles_perm_
122 this->forward_profiles_->rewind ();
123 this->profile_success_ = false;
124 this->set_profile_in_use_i (this->forward_profiles_->get_next());
127 this->set_profile_in_use_i (pfile_next);
129 // We may have been forwarded to / from a collocated situation
130 // Check for this and apply / remove optimisation if required.
131 this->orb_core_->reinitialize_object (this);
137 if (this->forward_profiles_) // Now do the common operation
139 pfile_next = this->next_forward_profile ();
142 // Fall back to base profiles
143 pfile_next = this->base_profiles_.get_next ();
147 typedef ACE_Reverse_Lock<TAO_SYNCH_MUTEX> TAO_REVERSE_LOCK;
148 TAO_REVERSE_LOCK reverse (this->profile_lock_);
149 ACE_MT (ACE_GUARD_RETURN (TAO_REVERSE_LOCK, ace_mon, reverse, 0));
150 if (TAO_debug_level > 5)
152 TAOLIB_DEBUG ((LM_DEBUG,
153 ACE_TEXT ("TAO (%P|%t) - Stub::next_profile_i, ")
154 ACE_TEXT ("released profile lock to reinitialize ")
155 ACE_TEXT ("this = 0x%x\n"),
158 // We may have been forwarded to / from a collocated situation
159 // Check for this and apply / remove optimisation if required.
160 this->orb_core_->reinitialize_object (this);
162 if (TAO_debug_level > 5)
164 TAOLIB_DEBUG ((LM_DEBUG,
165 ACE_TEXT ("TAO (%P|%t) - Stub::next_profile_i, ")
166 ACE_TEXT ("reacquired profile lock on object ")
167 ACE_TEXT ("this = 0x%x\n"),
172 pfile_next = this->base_profiles_.get_next ();
177 this->set_profile_in_use_i (pfile_next);
183 ACE_INLINE TAO_Profile *
184 TAO_Stub::next_profile ()
186 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
190 if (TAO_debug_level > 5)
192 TAOLIB_DEBUG ((LM_DEBUG,
193 ACE_TEXT ("TAO (%P|%t) - Stub::next_profile, acquired profile lock this = 0x%x\n"), this));
195 return this->next_profile_i ();
198 ACE_INLINE CORBA::Boolean
199 TAO_Stub::valid_forward_profile ()
201 return (this->profile_success_ && this->forward_profiles_);
205 TAO_Stub::set_valid_profile ()
207 this->profile_success_ = true;
210 ACE_INLINE CORBA::Boolean
211 TAO_Stub::valid_profile () const
213 return this->profile_success_;
216 ACE_INLINE TAO_Profile *
217 TAO_Stub::base_profiles (const TAO_MProfile &mprofiles)
219 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
223 if (TAO_debug_level > 5)
225 TAOLIB_DEBUG ((LM_DEBUG,
226 ACE_TEXT ("TAO (%P|%t) - Stub::base_profiles, acquired profile lock this = 0x%x\n"), this));
230 // first reset things so we start from scratch!
232 // @note This reset forward could effect the collocation status
233 // but as this method is only used from the Stub ctr, when the status
234 // is already correctly set, we don't reinitialise here. sm.
235 this->reset_forward ();
236 this->base_profiles_.set (mprofiles);
238 return this->profile_in_use_;
242 ACE_INLINE CORBA::Boolean
243 TAO_Stub::next_profile_retry ()
245 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
249 if (TAO_debug_level > 5)
251 TAOLIB_DEBUG ((LM_DEBUG,
252 ACE_TEXT ("TAO (%P|%t) - Stub::next_profile_retry, acquired profile lock this = 0x%x\n"), this));
255 if (this->profile_success_ && this->forward_profiles_)
257 // We have a forwarded reference that we have managed to *send* a message to
258 // previously in the remote path only (but not counting object proxy broker ops).
259 // @todo I can see little sense to this. It is at best highly inconsistent. sm.
261 // In this case we are falling back from the forwarded IOR stright to the base IOR
262 this->reset_profiles_i ();
264 // We used to return unconditional true at this point but this results in
265 // infinite retries of any permanent location forward. This is undesirable.
266 return !this->forward_profiles_perm_;
268 else if (this->next_profile_i ())
276 ACE_INLINE const TAO_MProfile&
277 TAO_Stub::base_profiles () const
279 return this->base_profiles_;
282 ACE_INLINE TAO_MProfile&
283 TAO_Stub::base_profiles ()
285 return this->base_profiles_;
288 ACE_INLINE const TAO_MProfile *
289 TAO_Stub::forward_profiles () const
291 return this->forward_profiles_;
294 ACE_INLINE TAO_MProfile *
295 TAO_Stub::forward_profiles ()
297 return this->forward_profiles_;
300 ACE_INLINE CORBA::Boolean
301 TAO_Stub::is_collocated () const
303 return this->is_collocated_;
306 ACE_INLINE TAO_ORB_Core*
307 TAO_Stub::orb_core () const
309 return this->orb_core_.get ();
312 ACE_INLINE CORBA::ORB_var &
313 TAO_Stub::servant_orb_var ()
315 // Simply pass back the ORB pointer for temporary use.
316 return this->servant_orb_;
319 ACE_INLINE CORBA::ORB_ptr
320 TAO_Stub::servant_orb_ptr ()
322 // Simply pass back the ORB pointer for temporary use.
323 return CORBA::ORB::_duplicate (this->servant_orb_.in ());
327 TAO_Stub::servant_orb (CORBA::ORB_ptr orb)
329 this->servant_orb_ = CORBA::ORB::_duplicate (orb);
332 ACE_INLINE TAO_Abstract_ServantBase *
333 TAO_Stub::collocated_servant () const
335 return collocated_servant_;
339 TAO_Stub::collocated_servant (TAO_Abstract_ServantBase * servant)
341 this->collocated_servant_ = servant;
344 ACE_INLINE TAO::Object_Proxy_Broker *
345 TAO_Stub::object_proxy_broker () const
347 return this->object_proxy_broker_;
351 TAO_Stub::object_proxy_broker (TAO::Object_Proxy_Broker * object_proxy_broker)
353 this->object_proxy_broker_ = object_proxy_broker;
359 // The reference count better be zero at this point!
363 ACE_INLINE CORBA::Boolean
364 TAO_Stub::optimize_collocation_objects () const
366 return this->collocation_opt_;
369 ACE_INLINE TAO::Transport_Queueing_Strategy *
370 TAO_Stub::transport_queueing_strategy ()
372 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
374 bool has_synchronization;
375 Messaging::SyncScope scope;
377 this->orb_core_->call_sync_scope_hook (this, has_synchronization, scope);
379 if (has_synchronization == true)
380 return this->orb_core_->get_transport_queueing_strategy (this, scope);
381 #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */
383 // No queueing strategy, let the transport use its default
388 void TAO_Stub::forwarded_on_exception (bool forwarded)
390 forwarded_on_exception_ = forwarded;
394 bool TAO_Stub::forwarded_on_exception () const
396 return forwarded_on_exception_;
401 TAO_Stub::_incr_refcnt ()
408 TAO_Stub::_decr_refcnt ()
410 if (--this->refcount_ == 0)
416 TAO_Stub::at_starting_profile () const
418 return profile_in_use_ == base_profiles_.get_profile(0);
421 TAO_END_VERSIONED_NAMESPACE_DECL