00001 #include "tao/Resume_Handle.h" 00002 #include "tao/ORB_Core.h" 00003 #include "debug.h" 00004 00005 #include "ace/Reactor.h" 00006 00007 #if !defined (__ACE_INLINE__) 00008 # include "tao/Resume_Handle.inl" 00009 #endif /* __ACE_INLINE__ */ 00010 00011 ACE_RCSID (tao, 00012 Resume_Handle, 00013 "$Id: Resume_Handle.cpp 72071 2006-04-11 16:36:14Z zhangw $") 00014 00015 00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00017 00018 void 00019 TAO_Resume_Handle::resume_handle (void) 00020 { 00021 // If we have a complete message, just resume the handler 00022 // Resume the handler. 00023 if (this->orb_core_ && 00024 this->orb_core_->reactor ()->resumable_handler () && 00025 this->flag_ == TAO_HANDLE_RESUMABLE && 00026 this->handle_ != ACE_INVALID_HANDLE) 00027 { 00028 this->orb_core_->reactor ()->resume_handler (this->handle_); 00029 } 00030 00031 // Set the flag, so that we dont resume again.. 00032 this->flag_ = TAO_HANDLE_ALREADY_RESUMED; 00033 } 00034 00035 void 00036 TAO_Resume_Handle::handle_input_return_value_hook (int& return_value) 00037 { 00038 // RT8248: The return value is only changed from 1 to 0 if: 00039 // 1) the handle_input return value wants an immediate callback 00040 // on the handle (i.e. will return "1") 00041 // 2) this->resume_handle was already called 00042 // 3) reactor->resume_handler was called by this->resume_handle 00043 // The value is changed because you can't ask for an immediate callback 00044 // on a handle that you have already given up ownership of. (RT8248) 00045 if ( return_value == 1 && 00046 this->flag_ == TAO_HANDLE_ALREADY_RESUMED && 00047 this->orb_core_ && 00048 this->orb_core_->reactor ()->resumable_handler () && 00049 this->handle_ != ACE_INVALID_HANDLE) 00050 { 00051 // a return value of "1" means "call me back immediately; 00052 // but we can't "call me back immediately" on an 00053 // already-resumed handle 00054 return_value = 0; 00055 00056 if (TAO_debug_level > 6) 00057 { 00058 ACE_DEBUG ((LM_DEBUG, 00059 "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, " 00060 "overriding return value of 1 with retval = %d\n", 00061 return_value)); 00062 } 00063 } 00064 else if ( return_value == -1 ) 00065 { 00066 // this covers the "connection close" case, where you want 00067 // to leave the handle suspended if you're return -1 to 00068 // remove the handle from the Reactor. (See ChangeLog entry 00069 // Fri Dec 16 14:40:54 2005) 00070 this->flag_ = TAO_HANDLE_LEAVE_SUSPENDED; 00071 00072 if (TAO_debug_level > 6) 00073 { 00074 ACE_DEBUG ((LM_DEBUG, 00075 "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, " 00076 "handle_input returning -1, so handle is not resumed.\n")); 00077 } 00078 } 00079 } 00080 00081 TAO_END_VERSIONED_NAMESPACE_DECL