00001
00002
00003 #include "tao/Exclusive_TMS.h"
00004 #include "tao/Reply_Dispatcher.h"
00005 #include "tao/debug.h"
00006 #include "tao/Transport.h"
00007
00008 ACE_RCSID (tao,
00009 Exclusive_TMS,
00010 "$Id: Exclusive_TMS.cpp 76551 2007-01-24 13:42:44Z johnnyw $")
00011
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 TAO_Exclusive_TMS::TAO_Exclusive_TMS (TAO_Transport *transport)
00015 : TAO_Transport_Mux_Strategy (transport),
00016 request_id_generator_ (0),
00017 has_request_ (false),
00018 request_id_ (0),
00019 rd_ (0)
00020 {
00021 }
00022
00023 TAO_Exclusive_TMS::~TAO_Exclusive_TMS (void)
00024 {
00025 }
00026
00027
00028
00029
00030 CORBA::ULong
00031 TAO_Exclusive_TMS::request_id (void)
00032 {
00033 ++this->request_id_generator_;
00034
00035
00036
00037
00038
00039
00040
00041 int const bidir_flag =
00042 this->transport_->bidirectional_flag ();
00043
00044 if ((bidir_flag == 1 && ACE_ODD (this->request_id_generator_))
00045 || (bidir_flag == 0 && ACE_EVEN (this->request_id_generator_)))
00046 ++this->request_id_generator_;
00047
00048 if (TAO_debug_level > 4)
00049 ACE_DEBUG ((LM_DEBUG,
00050 ACE_TEXT ("TAO (%P|%t) - Exclusive_TMS::request_id - <%d>\n"),
00051 this->request_id_generator_));
00052
00053 return this->request_id_generator_;
00054 }
00055
00056
00057 int
00058 TAO_Exclusive_TMS::bind_dispatcher (CORBA::ULong request_id,
00059 TAO_Reply_Dispatcher *rd)
00060 {
00061 this->has_request_ = true;
00062 this->request_id_ = request_id;
00063 this->rd_ = rd;
00064
00065 return 0;
00066 }
00067
00068 int
00069 TAO_Exclusive_TMS::unbind_dispatcher (CORBA::ULong request_id)
00070 {
00071 if (!this->has_request_ || this->request_id_ != request_id)
00072 return -1;
00073 this->has_request_ = false;
00074 this->request_id_ = 0;
00075 this->rd_ = 0;
00076
00077 return 0;
00078 }
00079
00080 int
00081 TAO_Exclusive_TMS::dispatch_reply (TAO_Pluggable_Reply_Params ¶ms)
00082 {
00083
00084 if (!this->has_request_ || this->request_id_ != params.request_id_)
00085 {
00086 if (TAO_debug_level > 0)
00087 ACE_DEBUG ((LM_DEBUG,
00088 ACE_TEXT ("(%P|%t) TAO_Exclusive_TMS::dispatch_reply - <%d != %d>\n"),
00089 this->request_id_, params.request_id_));
00090
00091
00092
00093 return 0;
00094 }
00095
00096 TAO_Reply_Dispatcher *rd = this->rd_;
00097 this->has_request_ = false;
00098 this->request_id_ = 0;
00099 this->rd_ = 0;
00100
00101
00102
00103 return rd->dispatch_reply (params);
00104 }
00105
00106 bool
00107 TAO_Exclusive_TMS::idle_after_send (void)
00108 {
00109 return false;
00110 }
00111
00112 bool
00113 TAO_Exclusive_TMS::idle_after_reply (void)
00114 {
00115
00116
00117
00118 if (this->transport_ != 0)
00119 (void) this->transport_->make_idle ();
00120
00121 return true;
00122 }
00123
00124 void
00125 TAO_Exclusive_TMS::connection_closed (void)
00126 {
00127 if (this->rd_ != 0)
00128 this->rd_->connection_closed ();
00129 }
00130
00131 TAO_END_VERSIONED_NAMESPACE_DECL