summaryrefslogtreecommitdiff
path: root/TAO/examples
diff options
context:
space:
mode:
authorvzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-03-17 13:55:49 +0000
committervzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-03-17 13:55:49 +0000
commitb5db93e26de4db7ed9dd083b058c9dfacde3a1e6 (patch)
treecb78f984dceae83473c8f7dc5ddc2c35a2e336c1 /TAO/examples
parent3a7b3e4e0a4739c1326e04498fcc0c91faa885bf (diff)
downloadATCD-b5db93e26de4db7ed9dd083b058c9dfacde3a1e6.tar.gz
Wed Mar 17 13:44:06 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com>
* tao/RTScheduling/Request_Interceptor.cpp: * tao/RTScheduling/RTScheduler_Manager.inl: * tao/RTScheduling/Current.cpp: * tao/RTScheduling/Current.h: * tao/RTScheduling/RTScheduler_Initializer.cpp: * tao/RTScheduling/RTScheduler_Initializer.h: Fixed a number of memory leaks. * tests/RTScheduling/DT_Spawn/test.cpp: * tests/RTScheduling/DT_Spawn/Thread_Action.h: * tests/RTScheduling/Scheduler.cpp: * tests/RTScheduling/Current/Thread_Task.cpp: * tests/RTScheduling/Scheduling_Interceptor/test_server.cpp: * tests/RTScheduling/VoidData/test_client.cpp: * tests/RTScheduling/Thread_Cancel/Thread_Task.h: * tests/RTScheduling/Thread_Cancel/test.cpp: * tests/RTScheduling/Thread_Cancel/Thread_Task.cpp: * examples/Kokyu_dsrt_schedulers/fp_example/client.cpp: * examples/Kokyu_dsrt_schedulers/fp_example/server.cpp: * examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp: * examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp: * examples/Kokyu_dsrt_schedulers/mif_example/client.cpp: * examples/Kokyu_dsrt_schedulers/mif_example/server.cpp: * examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp: * examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp: * examples/Kokyu_dsrt_schedulers/muf_example/client.cpp: * examples/Kokyu_dsrt_schedulers/muf_example/server.cpp: * examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp: * examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp: * examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp: * examples/RTScheduling/Thread_Task.h: * examples/RTScheduling/POA_Holder.cpp: * examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp: * examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h: * examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp: * examples/RTScheduling/Fixed_Priority_Scheduler/test.h: * examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp: * examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl: * examples/RTScheduling/Job_i.cpp: * examples/RTScheduling/DT_Creator.cpp: * examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp: * examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h: * examples/RTScheduling/MIF_Scheduler/test.cpp: * examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp: * examples/RTScheduling/MIF_Scheduler/test.h: * examples/RTScheduling/MIF_Scheduler/run_test.pl: * examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp: * examples/RTScheduling/Thread_Task.cpp: * examples/RTScheduling/DT_Creator.h: Fixed a lot of memory leaks which are actually similar from test to test.
Diffstat (limited to 'TAO/examples')
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp60
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp48
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp46
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp46
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/fp_example/client.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/fp_example/server.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp8
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/mif_example/client.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/mif_example/server.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp8
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/muf_example/client.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/muf_example/server.cpp7
-rw-r--r--TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp8
-rw-r--r--TAO/examples/RTScheduling/DT_Creator.cpp46
-rw-r--r--TAO/examples/RTScheduling/DT_Creator.h7
-rw-r--r--TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp3
-rw-r--r--TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h2
-rw-r--r--TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp4
-rwxr-xr-xTAO/examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl6
-rw-r--r--TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp61
-rw-r--r--TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.h5
-rw-r--r--TAO/examples/RTScheduling/Job_i.cpp9
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp12
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp102
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h3
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp6
-rwxr-xr-xTAO/examples/RTScheduling/MIF_Scheduler/run_test.pl26
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/test.cpp65
-rw-r--r--TAO/examples/RTScheduling/MIF_Scheduler/test.h4
-rw-r--r--TAO/examples/RTScheduling/POA_Holder.cpp7
-rw-r--r--TAO/examples/RTScheduling/Thread_Task.cpp9
-rw-r--r--TAO/examples/RTScheduling/Thread_Task.h2
32 files changed, 415 insertions, 230 deletions
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp
index f036d5d85f8..66dd7848174 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp
@@ -30,7 +30,7 @@ EDF_Scheduler::EDF_Scheduler (CORBA::ORB_ptr orb,
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
int ace_sched_policy,
int ace_sched_scope)
- : orb_ (orb),
+ : orb_ (CORBA::ORB::_duplicate (orb)),
disp_impl_type_ (disp_impl_type),
ace_sched_policy_ (ace_sched_policy),
ace_sched_scope_ (ace_sched_scope)
@@ -230,9 +230,10 @@ void
EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
{
int int_guid;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_CLIENT_SCHED_TIME, int_guid, 0, 0);
Kokyu::Svc_Ctxt_DSRT_QoS sc_qos;
@@ -250,7 +251,7 @@ EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
IOP::ServiceContext sc;
sc.context_id = Client_Interceptor::SchedulingInfo;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
CORBA::Long importance;
@@ -285,8 +286,8 @@ EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
#endif
}
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
sc_qos.deadline = deadline;
sc_qos.importance = importance;
sc_qos.task_id = task_id;
@@ -294,9 +295,8 @@ EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data =
- ACE_reinterpret_cast<IOP::ServiceContext::_tao_seq_CORBA_Octet_ &> (
- *codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -316,7 +316,7 @@ EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
DSUI_EVENT_LOG (EDF_SCHED_FAM, CALL_KOKYU_DISPATCH_UPDATE_SCHEDULE,
int_guid, 0, 0);
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
+ kokyu_dispatcher_->update_schedule (guid.in (),
Kokyu::BLOCK);
DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_KOKYU_DISPATCH_UPDATE_SCHEDULE,
int_guid,0,0);
@@ -389,7 +389,8 @@ EDF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri,
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
@@ -463,9 +464,10 @@ void
EDF_Scheduler::send_poll (PortableInterceptor::ClientRequestInfo_ptr)
{
int int_guid;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_POLL, int_guid, 0, 0);
}
@@ -473,9 +475,10 @@ void
EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
{
int int_guid;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SEND_REPLY, int_guid, 0, 0);
Kokyu::Svc_Ctxt_DSRT_QoS sc_qos;
@@ -496,7 +499,7 @@ EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
CORBA::Long importance;
TimeBase::TimeT deadline;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
if (CORBA::is_nil (sched_policy))
@@ -522,8 +525,8 @@ EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value ();
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
deadline = sched_param->deadline;
importance = sched_param->importance;
@@ -533,10 +536,8 @@ EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data = ACE_reinterpret_cast(
- IOP::ServiceContext::
- _tao_seq_CORBA_Octet_ &,
- *codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
// Add this context to the service context list.
ri->add_reply_service_context (sc, 1);
@@ -546,7 +547,7 @@ EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
#endif
}
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
+ kokyu_dispatcher_->update_schedule (guid.in (),
Kokyu::BLOCK);
DSUI_EVENT_LOG (EDF_SCHED_FAM, EXIT_SEND_REPLY, int_guid, 0, 0);
@@ -559,9 +560,10 @@ void
EDF_Scheduler::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri)
{
int int_guid;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_EXCEPTION, int_guid, 0, 0);
send_reply (ri);
@@ -571,9 +573,10 @@ void
EDF_Scheduler::send_other (PortableInterceptor::ServerRequestInfo_ptr ri)
{
int int_guid;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_OTHER, int_guid, 0, 0);
send_reply (ri);
@@ -628,7 +631,8 @@ EDF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri)
//and we are not supposed to free it.
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
sc_qos_as_any >>= sc_qos_ptr;
deadline = sc_qos_ptr->deadline;
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp b/TAO/examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp
index e67d0b94d89..aae8f93cd82 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/FP_Scheduler.cpp
@@ -61,7 +61,7 @@ Fixed_Priority_Scheduler::Fixed_Priority_Scheduler (
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
int ace_sched_policy,
int ace_sched_scope)
- : orb_ (orb),
+ : orb_ (CORBA::ORB::_duplicate (orb)),
disp_impl_type_ (disp_impl_type),
ace_sched_policy_ (ace_sched_policy),
ace_sched_scope_ (ace_sched_scope)
@@ -256,13 +256,14 @@ Fixed_Priority_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_p
IOP::ServiceContext sc;
sc.context_id = Client_Interceptor::SchedulingInfo;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
/*
- int guid;
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
*/
RTCORBA::Priority desired_priority;
if (CORBA::is_nil (sched_policy))
@@ -282,22 +283,22 @@ Fixed_Priority_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_p
#ifdef KOKYU_DSRT_LOGGING
int int_guid;
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%t): send_request desired_priority from current = %d, guid = %d\n"),
desired_priority, int_guid));
#endif
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
sc_qos.desired_priority = desired_priority;
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data =
- reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -316,8 +317,8 @@ Fixed_Priority_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_p
));
#endif
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
- Kokyu::BLOCK);
+ kokyu_dispatcher_->update_schedule (guid.in (),
+ Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -371,7 +372,8 @@ Fixed_Priority_Scheduler::receive_request (PortableInterceptor::ServerRequestInf
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
@@ -435,9 +437,11 @@ Fixed_Priority_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr
sc.context_id = Server_Interceptor::SchedulingInfo;
ACE_DEBUG ((LM_DEBUG, "in send_reply: before accessing current_->sched_param\n"));
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
if (CORBA::is_nil (sched_policy))
{
ACE_DEBUG ((LM_DEBUG, "sched_policy nil. desired_priority not set in sched params\n"));
@@ -456,13 +460,14 @@ Fixed_Priority_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr
desired_priority = sched_param.base_priority;
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
- sc_qos.desired_priority = desired_priority;
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
+ sc_qos.desired_priority = desired_priority;
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data = reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
// Add this context to the service context list.
ri->add_reply_service_context (sc, 1);
@@ -472,7 +477,7 @@ Fixed_Priority_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr
#endif
}
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
+ kokyu_dispatcher_->update_schedule (guid.in (),
Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
@@ -530,7 +535,8 @@ Fixed_Priority_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_
//and we are not supposed to free it.
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
sc_qos_as_any >>= sc_qos_ptr;
desired_priority = sc_qos_ptr->desired_priority;
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp b/TAO/examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp
index 41b1fc25fa3..c17ebbdacba 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/MIF_Scheduler.cpp
@@ -61,7 +61,7 @@ MIF_Scheduler::MIF_Scheduler (CORBA::ORB_ptr orb,
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
int ace_sched_policy,
int ace_sched_scope)
- : orb_ (orb),
+ : orb_ (CORBA::ORB::_duplicate (orb)),
disp_impl_type_ (disp_impl_type),
ace_sched_policy_ (ace_sched_policy),
ace_sched_scope_ (ace_sched_scope)
@@ -253,13 +253,14 @@ MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
IOP::ServiceContext sc;
sc.context_id = Client_Interceptor::SchedulingInfo;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
/*
- int guid;
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
*/
CORBA::Short importance;
if (CORBA::is_nil (sched_policy))
@@ -277,22 +278,22 @@ MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
#ifdef KOKYU_DSRT_LOGGING
int int_guid;
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): send_request importance from current = %d, guid = %d\n",
importance, int_guid));
#endif
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
sc_qos.importance = importance;
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data =
- reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -311,8 +312,8 @@ MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
));
#endif
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
- Kokyu::BLOCK);
+ kokyu_dispatcher_->update_schedule (guid.in (),
+ Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -366,7 +367,8 @@ MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri,
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
@@ -423,9 +425,11 @@ MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
IOP::ServiceContext sc;
sc.context_id = Server_Interceptor::SchedulingInfo;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
if (CORBA::is_nil (sched_policy))
{
#ifdef KOKYU_DSRT_LOGGING
@@ -450,13 +454,14 @@ MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
importance = sched_param->importance;
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
sc_qos.importance = importance;
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data = reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
// Add this context to the service context list.
ri->add_reply_service_context (sc, 1);
@@ -466,7 +471,7 @@ MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
#endif
}
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
+ kokyu_dispatcher_->update_schedule (guid.in (),
Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
@@ -529,7 +534,8 @@ MIF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri)
//and we are not supposed to free it.
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
sc_qos_as_any >>= sc_qos_ptr;
importance = sc_qos_ptr->importance;
guid.length (sc_qos_ptr->guid.length ());
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp b/TAO/examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp
index 6f8a932e22e..3ad7be56260 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/MUF_Scheduler.cpp
@@ -61,7 +61,7 @@ MUF_Scheduler::MUF_Scheduler (CORBA::ORB_ptr orb,
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type,
int ace_sched_policy,
int ace_sched_scope)
- : orb_ (orb),
+ : orb_ (CORBA::ORB::_duplicate (orb)),
disp_impl_type_ (disp_impl_type),
ace_sched_policy_ (ace_sched_policy),
ace_sched_scope_ (ace_sched_scope)
@@ -255,14 +255,15 @@ MUF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
IOP::ServiceContext sc;
sc.context_id = Client_Interceptor::SchedulingInfo;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
/*
- int guid;
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
*/
CORBA::Long criticality;
@@ -289,24 +290,24 @@ MUF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
#ifdef KOKYU_DSRT_LOGGING
int int_guid;
ACE_OS::memcpy (&int_guid,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
ACE_DEBUG ((LM_DEBUG,
"(%t|%T): send_request guid = %d\n",
int_guid));
#endif
//Fill the guid in the SC Qos struct
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
sc_qos.deadline = deadline;
sc_qos.estimated_initial_execution_time = exec_time;
sc_qos.criticality = criticality;
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data =
- reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -325,8 +326,8 @@ MUF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
));
#endif
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
- Kokyu::BLOCK);
+ kokyu_dispatcher_->update_schedule (guid.in (),
+ Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
ACE_DEBUG ((LM_DEBUG,
@@ -385,7 +386,8 @@ MUF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri,
sc->context_data.get_buffer (),
0);
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
//Don't store in a _var, since >>= returns a pointer to an
//internal buffer and we are not supposed to free it.
sc_qos_as_any >>= sc_qos_ptr;
@@ -459,9 +461,11 @@ MUF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
CORBA::Long criticality;
TimeBase::TimeT deadline,exec_time;
- CORBA::Policy_ptr sched_policy =
+ CORBA::Policy_var sched_policy =
this->current_->scheduling_parameter();
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
if (CORBA::is_nil (sched_policy))
{
#ifdef KOKYU_DSRT_LOGGING
@@ -486,8 +490,8 @@ MUF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
MUF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value ();
- sc_qos.guid.length (this->current_->id ()->length ());
- guid_copy (sc_qos.guid, *(this->current_->id ()));
+ sc_qos.guid.length (guid->length ());
+ guid_copy (sc_qos.guid, guid.in ());
deadline = sched_param->deadline;
exec_time = sched_param->estimated_initial_execution_time;
@@ -499,7 +503,8 @@ MUF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
CORBA::Any sc_qos_as_any;
sc_qos_as_any <<= sc_qos;
- sc.context_data = reinterpret_cast<CORBA::OctetSeq &> (*codec_->encode (sc_qos_as_any));
+ CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any);
+ sc.context_data = cdtmp.in ();
// Add this context to the service context list.
ri->add_reply_service_context (sc, 1);
@@ -509,7 +514,7 @@ MUF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri)
#endif
}
- kokyu_dispatcher_->update_schedule (*(this->current_->id ()),
+ kokyu_dispatcher_->update_schedule (guid.in (),
Kokyu::BLOCK);
#ifdef KOKYU_DSRT_LOGGING
@@ -574,7 +579,8 @@ MUF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri)
//and we are not supposed to free it.
Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr;
CORBA::Any sc_qos_as_any;
- sc_qos_as_any = *codec_->decode (oc_seq);
+ CORBA::Any_var scqostmp = codec_->decode (oc_seq);
+ sc_qos_as_any = scqostmp.in ();
sc_qos_as_any >>= sc_qos_ptr;
deadline = sc_qos_ptr->deadline;
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/client.cpp
index b1603de385b..903861c8896 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/client.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/client.cpp
@@ -142,6 +142,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -165,7 +167,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n"));
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -186,6 +188,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -255,6 +258,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
scheduler->shutdown ();
ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n"));
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/server.cpp
index 5672a0c42ce..e96c701e13a 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/server.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/server.cpp
@@ -97,6 +97,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -119,7 +121,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -140,6 +142,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -204,6 +207,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n"));
scheduler->shutdown ();
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp
index b50709d97ce..e33abf37b70 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/fp_example/test_i.cpp
@@ -20,10 +20,11 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
ACE_Thread::self (thr_handle);
int prio;
int guid;
+ RTScheduling::Current::IdType_var id = this->current_->id ();
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- sizeof (this->current_->id ()->length ()));
+ id->get_buffer (),
+ sizeof (id->length ()));
ACE_High_Res_Timer timer;
ACE_Time_Value elapsed_time;
@@ -92,8 +93,7 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
if (yield_count_down_time <= ACE_Time_Value::zero)
{
CORBA::Policy_var sched_param_policy =
- CORBA::Policy::_duplicate (current_->
- scheduling_parameter());
+ current_->scheduling_parameter();
const char * name = 0;
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/client.cpp
index fd07c9d8814..832769561a5 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/client.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/client.cpp
@@ -142,6 +142,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -165,7 +167,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n"));
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -186,6 +188,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -249,6 +252,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
scheduler->shutdown ();
ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n"));
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/server.cpp
index 4f02e48e40a..38744bb405e 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/server.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/server.cpp
@@ -97,6 +97,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -119,7 +121,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -140,6 +142,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -204,6 +207,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n"));
scheduler->shutdown ();
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp
index 74fd3856ade..98905c46b97 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/mif_example/test_i.cpp
@@ -20,10 +20,11 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
ACE_Thread::self (thr_handle);
int prio;
int guid;
+ RTScheduling::Current::IdType_var id = this->current_->id ();
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- sizeof (this->current_->id ()->length ()));
+ id->get_buffer (),
+ sizeof (id->length ()));
ACE_High_Res_Timer timer;
ACE_Time_Value elapsed_time;
@@ -92,8 +93,7 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
if (yield_count_down_time <= ACE_Time_Value::zero)
{
CORBA::Policy_var sched_param_policy =
- CORBA::Policy::_duplicate (current_->
- scheduling_parameter());
+ current_->scheduling_parameter();
const char * name = 0;
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/client.cpp
index e5b449da7e8..e5c9e374b88 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/client.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/client.cpp
@@ -147,6 +147,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -170,7 +172,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n"));
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -191,6 +193,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -315,6 +318,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
scheduler->shutdown ();
ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n"));
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/server.cpp
index 3689b5d5f90..0a4158c7153 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/server.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/server.cpp
@@ -97,6 +97,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
try
{
+ RTScheduling::Scheduler_var sched_owner;
+
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
@@ -119,7 +121,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (enable_dynamic_scheduling)
{
- CORBA::Object_ptr manager_obj =
+ CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
@@ -140,6 +142,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
disp_impl_type,
sched_policy,
sched_scope), -1);
+ sched_owner = scheduler;
manager->rtscheduler (scheduler);
@@ -204,6 +207,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n"));
scheduler->shutdown ();
+
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp
index 74fd3856ade..98905c46b97 100644
--- a/TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp
+++ b/TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp
@@ -20,10 +20,11 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
ACE_Thread::self (thr_handle);
int prio;
int guid;
+ RTScheduling::Current::IdType_var id = this->current_->id ();
ACE_OS::memcpy (&guid,
- this->current_->id ()->get_buffer (),
- sizeof (this->current_->id ()->length ()));
+ id->get_buffer (),
+ sizeof (id->length ()));
ACE_High_Res_Timer timer;
ACE_Time_Value elapsed_time;
@@ -92,8 +93,7 @@ Simple_Server_i::test_method (CORBA::Long exec_duration)
if (yield_count_down_time <= ACE_Time_Value::zero)
{
CORBA::Policy_var sched_param_policy =
- CORBA::Policy::_duplicate (current_->
- scheduling_parameter());
+ current_->scheduling_parameter();
const char * name = 0;
diff --git a/TAO/examples/RTScheduling/DT_Creator.cpp b/TAO/examples/RTScheduling/DT_Creator.cpp
index adf7897f900..81f335c633c 100644
--- a/TAO/examples/RTScheduling/DT_Creator.cpp
+++ b/TAO/examples/RTScheduling/DT_Creator.cpp
@@ -99,7 +99,6 @@ DT_Creator::init (int argc, ACE_TCHAR *argv [])
{
dt_count_ = ACE_OS::atoi (current_arg);
ACE_NEW_RETURN (dt_list_, Thread_Task*[dt_count_], -1);
- active_dt_count_ = dt_count_;
arg_shifter.consume_arg ();
}
else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-POA_Count"))))
@@ -111,7 +110,6 @@ DT_Creator::init (int argc, ACE_TCHAR *argv [])
else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-JOB_Count"))))
{
job_count_ = ACE_OS::atoi (current_arg);
- active_job_count_ = job_count_;
ACE_NEW_RETURN (job_list_, Job_i*[job_count_], -1);
arg_shifter.consume_arg ();
}
@@ -154,12 +152,12 @@ DT_Creator::init (int argc, ACE_TCHAR *argv [])
}
else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-OutFile"))))
{
- file_name_ = ACE_OS::strdup (current_arg);
+ file_name_ = current_arg;
arg_shifter.consume_arg ();
}
else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-LogFile"))))
{
- log_file_name_ = ACE_OS::strdup (current_arg);
+ log_file_name_ = current_arg;
arg_shifter.consume_arg ();
}
else
@@ -298,6 +296,8 @@ DT_Creator::activate_job_list (void)
for (int i = 0; i < job_count_; ++i)
{
+ ++active_job_count_;
+
job = job_list_[i];
if (TAO_debug_level > 0)
@@ -415,8 +415,6 @@ DT_Creator::resolve_naming_service (void)
this->naming_ =
CosNaming::NamingContextExt::_narrow (naming_obj.in ());
- //@@tmp hack, otherwise crashes on exit!..??
- CosNaming::NamingContextExt::_duplicate (this->naming_.in());
return 0;
}
@@ -434,11 +432,18 @@ DT_Creator::create_distributable_threads (RTScheduling::Current_ptr current)
while (!this->synch ()->synched ())
{
- this->orb_->perform_work ();
+ try
+ {
+ this->orb_->perform_work ();
+ }
+ catch (const CORBA::Exception &)
+ {
+ return;
+ }
}
CORBA::Policy_var sched_param;
- sched_param = CORBA::Policy::_duplicate (this->sched_param (100));
+ sched_param = this->sched_param (100);
const char * name = 0;
current->begin_scheduling_segment (name,
sched_param.in (),
@@ -468,17 +473,18 @@ DT_Creator::create_distributable_threads (RTScheduling::Current_ptr current)
(elapsed_time.sec () < dt_list_[i]->start_time ()))
{
time_t suspension_time = dt_list_[i]->start_time () - elapsed_time.sec ();
- ACE_OS::sprintf (buf, "suspension_tome = %lu\n", suspension_time);
+ ACE_OS::sprintf (buf, "suspension_time = %lu\n", suspension_time);
log [log_index++] = ACE_OS::strdup (buf);
yield (suspension_time, dt_list_[i]);
}
- sched_param = CORBA::Policy::_duplicate (this->sched_param (dt_list_ [i]->importance ()));
+ sched_param = this->sched_param (dt_list_ [i]->importance ());
dt_list_ [i]->activate_task (current,
sched_param.in (),
flags,
base_time_);
+ ++active_dt_count_;
}
this->wait ();
@@ -509,6 +515,8 @@ DT_Creator::job_ended (void)
{
ACE_GUARD (ACE_Lock, ace_mon, *state_lock_);
--active_job_count_;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "Active job count = %d\n",active_job_count_));
char buf [BUFSIZ];
ACE_OS::sprintf (buf,"Active job count = %d\n",active_job_count_);
log [log_index++] = ACE_OS::strdup (buf);
@@ -536,7 +544,6 @@ DT_Creator::check_ifexit (void)
// All tasks have finished and all jobs have been shutdown.
if (active_dt_count_ == 0 && active_job_count_ == 0)
{
-
ACE_DEBUG ((LM_DEBUG, "Shutdown in progress ...\n"));
/*
@@ -550,13 +557,13 @@ DT_Creator::check_ifexit (void)
job_list_[i]->dump_stats ();
}
*/
- TASK_STATS::instance ()->dump_samples (file_name_,
+ TASK_STATS::instance ()->dump_samples (file_name_.c_str (),
ACE_TEXT("#Schedule Output"),
ACE_High_Res_Timer::global_scale_factor ());
shutdown = 1;
- FILE* log_file = ACE_OS::fopen (log_file_name_, "w");
+ FILE* log_file = ACE_OS::fopen (log_file_name_.c_str (), "w");
if (log_file != 0)
{
@@ -597,8 +604,8 @@ DT_Creator::DT_Creator (void)
active_job_count_ (0),
log (0),
base_time_ (0),
- file_name_ (0),
- log_file_name_ (0),
+ file_name_ (),
+ log_file_name_ (),
gsf_ (0),
synch_ (0)
{
@@ -606,10 +613,15 @@ DT_Creator::DT_Creator (void)
DT_Creator::~DT_Creator (void)
{
- // for (int i = 0; i < (BUFSIZ * 100); i++)
+ for (int i = 0; i < log_index; ++i)
+ ACE_OS::free (log[i]);
delete[] log;
+ for (int i = 0; i < this->dt_count_; ++i)
+ delete this->dt_list_[i];
delete[] dt_list_;
+ for (int i = 0; i < this->poa_count_; ++i)
+ delete this->poa_list_[i];
delete[] poa_list_;
delete[] job_list_;
@@ -654,5 +666,5 @@ DT_Creator::base_time (ACE_Time_Value* base_time)
Synch_i*
DT_Creator::synch (void)
{
- return this->synch_;
+ return this->synch_.in ();
}
diff --git a/TAO/examples/RTScheduling/DT_Creator.h b/TAO/examples/RTScheduling/DT_Creator.h
index 7895bbdb082..3a79f51966d 100644
--- a/TAO/examples/RTScheduling/DT_Creator.h
+++ b/TAO/examples/RTScheduling/DT_Creator.h
@@ -10,6 +10,7 @@
#include "tao/RTScheduling/RTScheduler.h"
#include "orbsvcs/CosNamingC.h"
+#include "tao/Utils/Servant_Var.h"
#include "ace/Service_Config.h"
#include "ace/Service_Object.h"
@@ -102,10 +103,10 @@ class RTSCHEDTESTLIB_Export DT_Creator : public ACE_Service_Object
ACE_Time_Value* base_time_;
/// A naming context.
CosNaming::NamingContextExt_var naming_;
- ACE_TCHAR* file_name_;
- ACE_TCHAR* log_file_name_;
+ ACE_TString file_name_;
+ ACE_TString log_file_name_;
ACE_UINT32 gsf_;
- Synch_i* synch_;
+ TAO::Utils::Servant_Var<Synch_i> synch_;
};
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp
index 565bd839600..ea89484736b 100644
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.cpp
@@ -145,11 +145,12 @@ Fixed_Priority_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_p
ACE_DEFAULT_THREAD_PRIORITY));
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
IOP::ServiceContext* srv_con = new IOP::ServiceContext;
srv_con->context_id = Client_Interceptor::SchedulingInfo;
srv_con->context_data.length (sizeof (size_t));
ACE_OS::memcpy (srv_con->context_data.get_buffer (),
- current_->id ()->get_buffer (),
+ guid->get_buffer (),
sizeof (size_t));
request_info->add_request_service_context (*srv_con,
0);
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h
index af64e947998..61e16e20b4c 100644
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Scheduler.h
@@ -103,8 +103,6 @@ public ::CORBA::LocalObject
private:
RTScheduling::Current_var current_;
- RTCORBA::PriorityMapping* pm_;
-
};
#endif //FIXED_PRIORITY_SCHEDULER_H
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp
index ec80d1fd20f..08fd2ed49be 100644
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/FP_Task.cpp
@@ -32,11 +32,11 @@ FP_Task::activate_task (RTScheduling::Current_ptr current,
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "Thread_Task::activate %d\n",
+ "FP_Task::activate %d\n",
importance_));
char msg [BUFSIZ];
- ACE_OS::sprintf (msg, "Thread_Task::activate task\n");
+ ACE_OS::sprintf (msg, "FP_Task::activate task\n");
dt_creator_->log_msg (msg);
base_time_ = base_time;
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl
index 6c5c47bf35a..cff13f8c4c4 100755
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl
@@ -44,12 +44,12 @@ $NS = $nstarget->CreateProcess ("../../../orbsvcs/Naming_Service/Naming_Service"
"-o $nstarget_iorfile");
$SV = $server->CreateProcess ("test",
"-ORBInitRef NameService=file://$server_iorfile ".
- "-ORBSvcConf $server_svcfile");
+ "-ORBSvcConf $server_svcfile -ORBDebugLevel $debug_level");
$CL = $client->CreateProcess ("test",
"-ORBInitRef NameService=file://$client_iorfile ".
"-ORBSvcConf $client_svcfile");
-$ST = $client->CreateProcess ("Starter",
- "-ORBInitRef NameService=file://$starter_iorfile");
+$ST = $starter->CreateProcess ("Starter",
+ "-ORBInitRef NameService=file://$starter_iorfile");
print STDERR "Starting Naming Service\n";
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp
index bcf04daf6a1..4191f159e99 100644
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.cpp
@@ -4,11 +4,50 @@
#include "tao/RTScheduling/RTScheduler_Manager.h"
#include "tao/ORB_Core.h"
#include "ace/Arg_Shifter.h"
-#include "../Thread_Task.h"
#include "../Task_Stats.h"
#include "../Synch_i.h"
#include "ace/OS_NS_errno.h"
+#include "ace/Event_Handler.h"
+#include "ace/Sig_Handler.h"
+
+class TestShutdown : public ACE_Event_Handler
+{
+public:
+ TestShutdown (CORBA::ORB_ptr orb)
+ : orb_(CORBA::ORB::_duplicate (orb))
+ {
+#if !defined(ACE_LACKS_UNIX_SIGNALS)
+ this->shutdown_.register_handler (SIGTERM, this);
+ this->shutdown_.register_handler (SIGINT, this);
+#elif defined(ACE_WIN32)
+ this->shutdown_.register_handler (SIGINT, this);
+#endif
+ }
+
+ ~TestShutdown (void)
+ {
+#if !defined(ACE_LACKS_UNIX_SIGNALS)
+ this->shutdown_.remove_handler (SIGTERM);
+ this->shutdown_.remove_handler (SIGINT);
+#elif defined(ACE_WIN32)
+ this->shutdown_.remove_handler (SIGINT);
+#endif
+ }
+
+ virtual int handle_signal (int, siginfo_t*, ucontext_t*)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Shutting down...\n"));
+ this->orb_->shutdown ();
+ return 0;
+ }
+
+private:
+ CORBA::ORB_var orb_;
+
+ ACE_Sig_Handler shutdown_;
+};
+
DT_Test::DT_Test (void)
{
base_t = ACE_OS::gethrtime ();
@@ -74,16 +113,16 @@ DT_Test::init (int argc, ACE_TCHAR *argv [])
TASK_STATS::instance ()->init (dt_creator_->total_load ());
- CORBA::Object_ptr manager_obj = orb_->resolve_initial_references ("RTSchedulerManager");
+ CORBA::Object_var manager_obj = orb_->resolve_initial_references ("RTSchedulerManager");
- TAO_RTScheduler_Manager_var manager = TAO_RTScheduler_Manager::_narrow (manager_obj);
+ TAO_RTScheduler_Manager_var manager = TAO_RTScheduler_Manager::_narrow (manager_obj.in ());
ACE_NEW_RETURN (scheduler_,
Fixed_Priority_Scheduler (orb_.in ()),
-1);
- manager->rtscheduler (scheduler_);
+ manager->rtscheduler (scheduler_.in ());
CORBA::Object_var object =
orb_->resolve_initial_references ("RTScheduler_Current");
@@ -119,6 +158,8 @@ DT_Test::run (int argc, ACE_TCHAR* argv [])
{
init (argc,argv);
+ TestShutdown killer (this->orb_.in ());
+
if (this->dt_creator_->resolve_naming_service () == -1)
return;
@@ -132,8 +173,7 @@ DT_Test::run (int argc, ACE_TCHAR* argv [])
this->dt_creator_->activate_job_list ();
this->dt_creator_->activate_schedule ();
- DT_Creator* dt_creator = this->dt_creator_;
- dt_creator->register_synch_obj ();
+ this->dt_creator_->register_synch_obj ();
ACE_DEBUG ((LM_DEBUG,
"Registered Synch Object\n"));
@@ -146,10 +186,13 @@ DT_Test::run (int argc, ACE_TCHAR* argv [])
char msg [BUFSIZ];
ACE_OS::sprintf (msg, "ORB RUN\n");
- dt_creator_->log_msg (msg);
+ this->dt_creator_->log_msg (msg);
- //ACE_Thread_Manager::instance ()->wait ();
orb_->run ();
+
+ ACE_Thread_Manager::instance ()->wait ();
+
+ orb_->destroy ();
}
void
@@ -167,7 +210,7 @@ DT_Test::dt_creator (void)
Fixed_Priority_Scheduler*
DT_Test::scheduler (void)
{
- return this->scheduler_;
+ return this->scheduler_.in ();
}
int
diff --git a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.h b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.h
index 87954c23550..565adffb08a 100644
--- a/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.h
+++ b/TAO/examples/RTScheduling/Fixed_Priority_Scheduler/test.h
@@ -10,6 +10,7 @@
#include "ace/Synch.h"
#include "ace/Task.h"
#include "FP_DT_Creator.h"
+#include "tao/Utils/Servant_Var.h"
class Task_Stats;
@@ -36,8 +37,6 @@ class DT_Test :public ACE_Task <ACE_SYNCH>
ACE_hrtime_t base_t;
- void register_synch_obj (void);
-
protected:
/// task svc
virtual int svc (void);
@@ -54,7 +53,7 @@ class DT_Test :public ACE_Task <ACE_SYNCH>
int min_priority_;
RTScheduling::Current_var current_;
FP_DT_Creator* dt_creator_;
- Fixed_Priority_Scheduler* scheduler_;
+ TAO::Utils::Servant_Var<Fixed_Priority_Scheduler> scheduler_;
RTCORBA::RTORB_var rt_orb_;
/// Reference to the root poa.
PortableServer::POA_var root_poa_;
diff --git a/TAO/examples/RTScheduling/Job_i.cpp b/TAO/examples/RTScheduling/Job_i.cpp
index 0ad1ee49907..2e8ebdfeadb 100644
--- a/TAO/examples/RTScheduling/Job_i.cpp
+++ b/TAO/examples/RTScheduling/Job_i.cpp
@@ -60,7 +60,7 @@ Job_i::work (CORBA::ULong work,
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "test_i::method: %d units of work\n",
+ "Job_i::work: %d units of work\n",
work));
CORBA::Object_var object =
@@ -69,11 +69,12 @@ Job_i::work (CORBA::ULong work,
RTScheduling::Current_var current =
RTScheduling::Current::_narrow (object.in ());
+ RTScheduling::Current::IdType_var guid = current->id ();
if (guid_ == 0)
ACE_OS::memcpy (&guid_,
- current->id ()->get_buffer (),
- sizeof (current->id ()->length ()));
+ guid->get_buffer (),
+ sizeof (guid->length ()));
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
@@ -111,7 +112,7 @@ Job_i::work (CORBA::ULong work,
TASK_STATS::instance ()->sample (run_time.sec (), guid_);
CORBA::Policy_var sched_param;
- sched_param = CORBA::Policy::_duplicate (dt_creator_->sched_param (importance));
+ sched_param = dt_creator_->sched_param (importance);
const char * name = 0;
current->update_scheduling_segment (name,
sched_param.in (),
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp
index fd822063210..d70147e227a 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_DT_Creator.cpp
@@ -54,7 +54,7 @@ MIF_DT_Creator::yield (time_t suspend_time,
ACE_OS::sleep (1);
CORBA::Policy_var sched_param;
- sched_param = CORBA::Policy::_duplicate (this->sched_param (100));
+ sched_param = this->sched_param (100);
const char * name = 0;
current->update_scheduling_segment (name,
sched_param.in (),
@@ -81,6 +81,16 @@ MIF_DT_Creator::wait (void)
{
while (active_dt_count_ > 0 || active_job_count_ > 0)
{
+ try
+ {
+ (void)this->orb_->work_pending ();
+ }
+ catch (CORBA::BAD_INV_ORDER const &)
+ {
+ // If there is BAD_INV_ORDER exception there is
+ // no point in running this loop any more.
+ break;
+ }
yield(1,0);
}
}
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp
index 711fc6b91f4..439252ff276 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.cpp
@@ -92,6 +92,14 @@ MIF_Scheduler::MIF_Scheduler (CORBA::ORB_ptr orb)
MIF_Scheduler::~MIF_Scheduler (void)
{
+ while (free_que_.message_count () > 0)
+ {
+ DT *dt = 0;
+ ACE_Message_Block *msg = 0;
+ free_que_.dequeue_head (msg);
+ dt = dynamic_cast<DT*> (msg);
+ delete dt;
+ }
}
void
@@ -148,9 +156,11 @@ MIF_Scheduler::begin_new_scheduling_segment (const RTScheduling::Current::IdType
CORBA::Policy_ptr)
{
size_t count = 0;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
ACE_OS::memcpy (&count,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param =
@@ -200,9 +210,11 @@ MIF_Scheduler::update_scheduling_segment (const RTScheduling::Current::IdType &/
CORBA::Policy_ptr /*implicit_sched_param*/)
{
size_t count = 0;
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
+
ACE_OS::memcpy (&count,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param =
MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (sched_policy);
@@ -234,6 +246,7 @@ MIF_Scheduler::update_scheduling_segment (const RTScheduling::Current::IdType &/
run_dt->resume ();
new_dt->suspend ();
lock_.release ();
+ free_que_.enqueue_prio (run_dt);
}
else
{
@@ -266,6 +279,7 @@ MIF_Scheduler::end_scheduling_segment (const RTScheduling::Current::IdType &guid
lock_.acquire ();
run_dt->resume ();
lock_.release ();
+ free_que_.enqueue_prio (run_dt);
}
}
@@ -279,43 +293,47 @@ MIF_Scheduler::end_nested_scheduling_segment (const RTScheduling::Current::IdTyp
void
MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr request_info)
{
+ CORBA::Policy_var sched_param = current_->scheduling_parameter ();
+
MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param_var =
- MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (current_->scheduling_parameter ());
+ MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (sched_param.in ());
- IOP::ServiceContext* srv_con = new IOP::ServiceContext;
- srv_con->context_id = Client_Interceptor::SchedulingInfo;
+ IOP::ServiceContext srv_con;
+ srv_con.context_id = Client_Interceptor::SchedulingInfo;
- int guid_length = current_->id ()->length ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
- RTScheduling::Current::IdType* guid = current_->id ();
+ int guid_length = guid->length ();
- CORBA::Octet *seq_buf = CORBA::OctetSeq::allocbuf (guid_length);
- ACE_OS::memcpy (seq_buf,
+ CORBA::OctetSeq seq_buf (guid_length);
+ seq_buf.length (seq_buf.maximum ());
+ ACE_OS::memcpy (seq_buf.get_buffer (),
guid->get_buffer (),
guid_length);
int cxt_data_length = sizeof (int) + guid_length;
- srv_con->context_data.length (cxt_data_length);
+ srv_con.context_data.length (cxt_data_length);
int i = 0;
for (;i < guid_length;i++)
{
- srv_con->context_data [i] = seq_buf [i];
+ srv_con.context_data [i] = seq_buf [i];
}
int importance = sched_param_var->importance ();
- CORBA::Octet *int_buf = CORBA::OctetSeq::allocbuf (sizeof (importance));
- ACE_OS::memcpy (int_buf,
+ CORBA::OctetSeq int_buf (sizeof (importance));
+ int_buf.length (int_buf.maximum ());
+ ACE_OS::memcpy (int_buf.get_buffer (),
&importance,
sizeof (importance));
int j = 0;
for (;i < cxt_data_length;i++)
{
- srv_con->context_data [i] = int_buf [j++];
+ srv_con.context_data [i] = int_buf [j++];
}
- request_info->add_request_service_context (*srv_con,
+ request_info->add_request_service_context (srv_con,
0);
lock_.acquire ();
@@ -352,6 +370,7 @@ MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr request_
ready_que_.dequeue_head (msg);
run_dt = dynamic_cast<DT*> (msg);
run_dt->resume ();
+ free_que_.enqueue_prio (run_dt);
}
lock_.release ();
@@ -369,7 +388,7 @@ MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr reque
ACE_DEBUG ((LM_DEBUG,
"MIF_Scheduler::receive_request\n"));
- IOP::ServiceContext* serv_cxt =
+ IOP::ServiceContext_var serv_cxt =
request_info->get_request_service_context (Server_Interceptor::SchedulingInfo);
if (serv_cxt != 0)
@@ -396,7 +415,8 @@ MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr reque
gu_id));
- CORBA::Octet *int_buf = CORBA::OctetSeq::allocbuf (sizeof (long));
+ CORBA::OctetSeq int_buf (sizeof (long));
+ int_buf.length (int_buf.maximum ());
int i = sizeof (long);
for (unsigned int j = 0;j < sizeof (int);j++)
{
@@ -405,11 +425,11 @@ MIF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr reque
int importance = 0;
ACE_OS::memcpy (&importance,
- int_buf,
+ int_buf.get_buffer (),
sizeof (importance));
- guid_out.ptr () = guid;
- sched_param_out.ptr () = DT_TEST::instance ()->scheduler ()->create_segment_scheduling_parameter (importance);
+ guid_out = guid;
+ sched_param_out = DT_TEST::instance ()->scheduler ()->create_segment_scheduling_parameter (importance);
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
@@ -434,7 +454,7 @@ void
MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr)
{
- RTScheduling::Current::IdType* guid = current_->id ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
size_t count;
ACE_OS::memcpy (&count,
@@ -454,6 +474,7 @@ MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr)
lock_.acquire ();
run_dt->resume ();
lock_.release ();
+ free_que_.enqueue_prio (run_dt);
}
}
@@ -469,6 +490,7 @@ MIF_Scheduler::send_exception (PortableInterceptor::ServerRequestInfo_ptr)
lock_.acquire ();
run_dt->resume ();
lock_.release ();
+ free_que_.enqueue_prio (run_dt);
}
}
@@ -477,7 +499,7 @@ MIF_Scheduler::send_other (PortableInterceptor::ServerRequestInfo_ptr)
{
if (TAO_debug_level > 0)
{
- RTScheduling::Current::IdType* guid = current_->id ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
size_t count;
ACE_OS::memcpy (&count,
@@ -499,6 +521,7 @@ MIF_Scheduler::send_other (PortableInterceptor::ServerRequestInfo_ptr)
lock_.acquire ();
run_dt->resume ();
lock_.release ();
+ free_que_.enqueue_prio (run_dt);
}
}
@@ -510,17 +533,14 @@ MIF_Scheduler::send_poll (PortableInterceptor::ClientRequestInfo_ptr)
void
MIF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr)
{
+ CORBA::Policy_var sched_param = current_->scheduling_parameter ();
MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param_var =
- MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (current_->scheduling_parameter ());
+ MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (sched_param.in ());
int importance = sched_param_var->importance ();
- CORBA::Octet *int_buf = CORBA::OctetSeq::allocbuf (sizeof (importance));
- ACE_OS::memcpy (int_buf,
- &importance,
- sizeof (importance));
- RTScheduling::Current::IdType* guid = current_->id ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
size_t gu_id;
ACE_OS::memcpy (&gu_id,
@@ -563,16 +583,14 @@ MIF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr)
void
MIF_Scheduler::receive_exception (PortableInterceptor::ClientRequestInfo_ptr)
{
+ CORBA::Policy_var sched_param = current_->scheduling_parameter ();
+
MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param_var =
- MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (current_->scheduling_parameter ());
+ MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (sched_param.in ());
int importance = sched_param_var->importance ();
- CORBA::Octet *int_buf = CORBA::OctetSeq::allocbuf (sizeof (importance));
- ACE_OS::memcpy (int_buf,
- &importance,
- sizeof (importance));
- RTScheduling::Current::IdType* guid = current_->id ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
size_t gu_id;
ACE_OS::memcpy (&gu_id,
@@ -609,16 +627,14 @@ MIF_Scheduler::receive_exception (PortableInterceptor::ClientRequestInfo_ptr)
void
MIF_Scheduler::receive_other (PortableInterceptor::ClientRequestInfo_ptr)
{
- MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param_var =
- MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (current_->scheduling_parameter ());
+ CORBA::Policy_var sched_param = current_->scheduling_parameter ();
+
+ MIF_Scheduling::SegmentSchedulingParameterPolicy_var sched_param_var =
+ MIF_Scheduling::SegmentSchedulingParameterPolicy::_narrow (sched_param.in ());
int importance = sched_param_var->importance ();
- CORBA::Octet *int_buf = CORBA::OctetSeq::allocbuf (sizeof (importance));
- ACE_OS::memcpy (int_buf,
- &importance,
- sizeof (importance));
- RTScheduling::Current::IdType* guid = current_->id ();
+ RTScheduling::Current::IdType_var guid = current_->id ();
size_t gu_id;
ACE_OS::memcpy (&gu_id,
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h
index d0a5177bdfc..940488711b9 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Scheduler.h
@@ -136,10 +136,9 @@ public ::CORBA::LocalObject
RTScheduling::Current_var current_;
RTCORBA::PriorityMappingManager_var mapping_manager_;
TAO_SYNCH_MUTEX lock_;
- TAO_SYNCH_MUTEX wait_lock_;
TAO_SYNCH_CONDITION wait_cond_;
DT_Message_Queue ready_que_;
- DT_Message_Queue wait_que_;
+ DT_Message_Queue free_que_;
int wait_;
};
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp
index 8a894488a6a..f9ad227ec89 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/MIF_Task.cpp
@@ -54,11 +54,11 @@ MIF_Task::activate_task (RTScheduling::Current_ptr current,
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "Thread_Task::activate %d\n",
+ "MIF_Task::activate %d\n",
importance_));
char msg [BUFSIZ];
- ACE_OS::sprintf (msg, "Thread_Task::activate task\n");
+ ACE_OS::sprintf (msg, "MIF_Task::activate task\n");
dt_creator_->log_msg (msg);
base_time_ = base_time;
@@ -98,7 +98,7 @@ MIF_Task::perform_task (void)
static CORBA::ULong prime_number = 9619;
CORBA::Policy_var sched_param;
- sched_param = CORBA::Policy::_duplicate (dt_creator_->sched_param (this->importance_));
+ sched_param = dt_creator_->sched_param (this->importance_);
const char * name = 0;
for (int i = 0; i < this->iter_; i++)
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/run_test.pl b/TAO/examples/RTScheduling/MIF_Scheduler/run_test.pl
index 6c5c47bf35a..f7baaf9b50f 100755
--- a/TAO/examples/RTScheduling/MIF_Scheduler/run_test.pl
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/run_test.pl
@@ -44,12 +44,12 @@ $NS = $nstarget->CreateProcess ("../../../orbsvcs/Naming_Service/Naming_Service"
"-o $nstarget_iorfile");
$SV = $server->CreateProcess ("test",
"-ORBInitRef NameService=file://$server_iorfile ".
- "-ORBSvcConf $server_svcfile");
+ "-ORBSvcConf $server_svcfile -ORBDebugLevel $debug_level");
$CL = $client->CreateProcess ("test",
"-ORBInitRef NameService=file://$client_iorfile ".
"-ORBSvcConf $client_svcfile");
-$ST = $client->CreateProcess ("Starter",
- "-ORBInitRef NameService=file://$starter_iorfile");
+$ST = $starter->CreateProcess ("Starter",
+ "-ORBInitRef NameService=file://$starter_iorfile");
print STDERR "Starting Naming Service\n";
@@ -113,7 +113,7 @@ if ($client_status != 0) {
sleep (5);
-$starter_status = $ST->SpawnWaitKill ($starter->ProcessStartWaitInterval() + 185);
+$starter_status = $ST->SpawnWaitKill ($starter->ProcessStartWaitInterval());
if ($starter_status != 0) {
print STDERR "ERROR: starter returned $starter_status\n";
@@ -123,14 +123,28 @@ if ($starter_status != 0) {
exit 1;
}
-$server_status = $SV->TerminateWaitKill ($server->ProcessStopWaitInterval());
+$server_status = $SV->Wait ($server->ProcessStopWaitInterval() + 90);
+
+if ($server_status == -1) {
+ # if SV is still alive terminate it.
+ $server_status = $SV->TerminateWaitKill ($server->ProcessStopWaitInterval());
+} else {
+ $server_status = $SV->Kill ($server->ProcessStopWaitInterval())
+}
if ($server_status != 0) {
print STDERR "ERROR: server returned $server_status\n";
$status = 1;
}
-$client_status = $CL->TerminateWaitKill ($client->ProcessStopWaitInterval());
+$client_status = $CL->Wait ($client->ProcessStopWaitInterval());
+
+if ($client_status == -1) {
+ # if CL is still alive terminate it.
+ $client_status = $CL->TerminateWaitKill ($client->ProcessStopWaitInterval());
+} else {
+ $client_status = $CL->Kill ($client->ProcessStopWaitInterval());
+}
if ($client_status != 0) {
print STDERR "ERROR: client returned $client_status\n";
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/test.cpp b/TAO/examples/RTScheduling/MIF_Scheduler/test.cpp
index 4aea91230c4..46ae6149271 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/test.cpp
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/test.cpp
@@ -1,7 +1,6 @@
//$Id$
#include "test.h"
-#include "../Thread_Task.h"
#include "../Task_Stats.h"
#include "../Synch_i.h"
@@ -10,6 +9,46 @@
#include "ace/Arg_Shifter.h"
+#include "ace/Event_Handler.h"
+#include "ace/Sig_Handler.h"
+
+class TestShutdown : public ACE_Event_Handler
+{
+public:
+ TestShutdown (CORBA::ORB_ptr orb)
+ : orb_(CORBA::ORB::_duplicate (orb))
+ {
+#if !defined(ACE_LACKS_UNIX_SIGNALS)
+ this->shutdown_.register_handler (SIGTERM, this);
+ this->shutdown_.register_handler (SIGINT, this);
+#elif defined(ACE_WIN32)
+ this->shutdown_.register_handler (SIGINT, this);
+#endif
+ }
+
+ ~TestShutdown (void)
+ {
+#if !defined(ACE_LACKS_UNIX_SIGNALS)
+ this->shutdown_.remove_handler (SIGTERM);
+ this->shutdown_.remove_handler (SIGINT);
+#elif defined(ACE_WIN32)
+ this->shutdown_.remove_handler (SIGINT);
+#endif
+ }
+
+ virtual int handle_signal (int, siginfo_t*, ucontext_t*)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Shutting down...\n"));
+ this->orb_->shutdown ();
+ return 0;
+ }
+
+private:
+ CORBA::ORB_var orb_;
+
+ ACE_Sig_Handler shutdown_;
+};
+
DT_Test::DT_Test (void)
{
}
@@ -21,7 +60,7 @@ DT_Test::init (int argc, ACE_TCHAR *argv [])
dt_creator_->orb (orb_.in ());
- CORBA::Object_ptr manager_obj = orb_->resolve_initial_references ("RTSchedulerManager");
+ CORBA::Object_var manager_obj = orb_->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager = TAO_RTScheduler_Manager::_narrow (manager_obj);
@@ -29,7 +68,7 @@ DT_Test::init (int argc, ACE_TCHAR *argv [])
ACE_NEW_RETURN (scheduler_,
MIF_Scheduler (orb_.in ()), -1);
- manager->rtscheduler (scheduler_);
+ manager->rtscheduler (scheduler_.in ());
CORBA::Object_var object =
orb_->resolve_initial_references ("RTScheduler_Current");
@@ -45,6 +84,8 @@ DT_Test::run (int argc, ACE_TCHAR* argv [])
{
init (argc,argv);
+ TestShutdown killer (this->orb_.in ());
+
TASK_STATS::instance ()->init (this->dt_creator_->total_load ());
if (this->dt_creator_->resolve_naming_service () == -1)
return;
@@ -55,15 +96,16 @@ DT_Test::run (int argc, ACE_TCHAR* argv [])
this->dt_creator_->activate_job_list ();
this->dt_creator_->activate_schedule ();
- DT_Creator* dt_creator = this->dt_creator_;
- dt_creator->register_synch_obj ();
+ this->dt_creator_->register_synch_obj ();
ACE_DEBUG ((LM_DEBUG,
"Registered Synch Object\n"));
- dt_creator_->create_distributable_threads (current_.in ());
+ this->dt_creator_->create_distributable_threads (current_.in ());
- orb_->destroy ();
+ ACE_Thread_Manager::instance ()->wait ();
+
+ this->orb_->destroy ();
ACE_DEBUG ((LM_DEBUG,
"Test Terminating......\n"));
@@ -80,7 +122,7 @@ DT_Test::dt_creator (MIF_DT_Creator* dt_creator)
MIF_Scheduler*
DT_Test::scheduler (void)
{
- return this->scheduler_;
+ return this->scheduler_.in ();
}
/*
int
@@ -122,12 +164,6 @@ DT_Test::svc (void)
}
*/
-RTScheduling::Current_ptr
-DT_Test::current (void)
-{
- return this->current_.in ();
-}
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
@@ -146,6 +182,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
return 1;
}
+ ACE_DEBUG ((LM_DEBUG, "END\n"));
return 0;
}
diff --git a/TAO/examples/RTScheduling/MIF_Scheduler/test.h b/TAO/examples/RTScheduling/MIF_Scheduler/test.h
index 0a60cfaa92e..fa3e8eec8ae 100644
--- a/TAO/examples/RTScheduling/MIF_Scheduler/test.h
+++ b/TAO/examples/RTScheduling/MIF_Scheduler/test.h
@@ -9,6 +9,7 @@
#include "tao/ORB_Core.h"
#include "ace/Synch.h"
#include "ace/Task.h"
+#include "tao/Utils/Servant_Var.h"
class Task_Stats;
@@ -28,7 +29,6 @@ class DT_Test //:public ACE_Task <ACE_SYNCH>
int activate_task (void);
- RTScheduling::Current_ptr current (void);
/* protected: */
/* /// task svc */
@@ -45,7 +45,7 @@ class DT_Test //:public ACE_Task <ACE_SYNCH>
int min_priority_;
RTScheduling::Current_var current_;
MIF_DT_Creator* dt_creator_;
- MIF_Scheduler* scheduler_;
+ TAO::Utils::Servant_Var<MIF_Scheduler> scheduler_;
};
typedef ACE_Singleton <DT_Test, TAO_SYNCH_MUTEX> DT_TEST;
diff --git a/TAO/examples/RTScheduling/POA_Holder.cpp b/TAO/examples/RTScheduling/POA_Holder.cpp
index 2e5c487fef4..190b5a51cfc 100644
--- a/TAO/examples/RTScheduling/POA_Holder.cpp
+++ b/TAO/examples/RTScheduling/POA_Holder.cpp
@@ -296,7 +296,8 @@ POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb, PortableServer::POA_ptr parent_
PortableServer::POAManager_var poa_manager =
parent_poa->the_POAManager ();
- parent_poa->create_POA (POA_name_.c_str (),
- poa_manager.in (),
- poa_policy_list);
+ PortableServer::POA_var poa =
+ parent_poa->create_POA (POA_name_.c_str (),
+ poa_manager.in (),
+ poa_policy_list);
}
diff --git a/TAO/examples/RTScheduling/Thread_Task.cpp b/TAO/examples/RTScheduling/Thread_Task.cpp
index 8404388523e..fa72abcae77 100644
--- a/TAO/examples/RTScheduling/Thread_Task.cpp
+++ b/TAO/examples/RTScheduling/Thread_Task.cpp
@@ -18,7 +18,7 @@ Thread_Task::Thread_Task (void)
dt_creator_ (0),
base_time_ (0),
dist_ (0),
- job_name_ (0),
+ job_name_ (),
task_stats_ (0)
{
}
@@ -41,9 +41,10 @@ Thread_Task::svc (void)
sched_param_.in (),
implicit_sched_param.in ());
+ RTScheduling::Current::IdType_var guid = this->current_->id ();
ACE_OS::memcpy (&count_,
- this->current_->id ()->get_buffer (),
- this->current_->id ()->length ());
+ guid->get_buffer (),
+ guid->length ());
ACE_TCHAR msg [BUFSIZ];
ACE_OS::sprintf (msg,
@@ -90,7 +91,7 @@ Thread_Task::perform_task (void)
const char*
Thread_Task::job (void)
{
- return job_name_;
+ return job_name_.in ();
}
void
diff --git a/TAO/examples/RTScheduling/Thread_Task.h b/TAO/examples/RTScheduling/Thread_Task.h
index f88093ee6cc..0bea6f2f01d 100644
--- a/TAO/examples/RTScheduling/Thread_Task.h
+++ b/TAO/examples/RTScheduling/Thread_Task.h
@@ -53,7 +53,7 @@ class RTSCHEDTESTLIB_Export Thread_Task : public ACE_Task <ACE_SYNCH>
//Task *task_;
ACE_Time_Value* base_time_;
int dist_;
- char *job_name_;
+ CORBA::String_var job_name_;
Job_var job_;
Task_Stats *task_stats_;
};