diff options
Diffstat (limited to 'CIAO')
5 files changed, 160 insertions, 84 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 1dfcc1c9589..cc2e511ea51 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,15 @@ +Tue Feb 9 12:24:14 UTC 2010 Marcel Smit <msmit@remedy.nl> + + * connectors/dds4ccm/tests/CSLDeadline/Receiver/CSL_DeadlineTest_Receiver_exec.cpp: + Optimized logging. + + * connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.h: + * connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.cpp: + Added test for thread switch. + + * connectors/dds4ccm/tests/CSLQoS/Sender/CSL_QoSTest_Sender_exec.cpp: + Resolved compiler warnings on Linux. + Tue Feb 9 12:02:59 UTC 2010 Marcel Smit <msmit@remedy.nl> * connectors/dds4ccm/tests/CSLQoS/Receiver/CSL_QoSTest_Receiver_exec.h: diff --git a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Receiver/CSL_DeadlineTest_Receiver_exec.cpp b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Receiver/CSL_DeadlineTest_Receiver_exec.cpp index 004084982bf..a275f43903e 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Receiver/CSL_DeadlineTest_Receiver_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Receiver/CSL_DeadlineTest_Receiver_exec.cpp @@ -174,26 +174,26 @@ namespace CIAO_CSL_DeadlineTest_Receiver_Impl { if (this->deadline_missed_.value ()) { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK : Received the expected ") - ACE_TEXT ("'on_offered_deadline_missed' in Receiver\n") + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RECEIVER OK: Received the expected ") + ACE_TEXT ("'on_offered_deadline_missed'\n") )); } else { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: didn't receive the expected ") - ACE_TEXT ("'on_offered_deadline_missed' in Receiver\n") + ACE_ERROR ((LM_ERROR, ACE_TEXT ("RECEIVER ERROR: didn't receive the expected ") + ACE_TEXT ("'on_offered_deadline_missed'\n") )); } if (this->thread_id_listener_.value () == 0) { - ACE_ERROR ((LM_ERROR, "ERROR: " + ACE_ERROR ((LM_ERROR, "RECEIVER ERROR: " "Thread ID for ConnectorStatusListener not set!\n")); } #if defined (CIAO_DDS4CCM_CONTEXT_SWITCH) && (CIAO_DDS4CCM_CONTEXT_SWITCH == 1) else if (ACE_OS::thr_equal (this->thread_id_listener_.value (), ACE_Thread::self ())) { - ACE_DEBUG ((LM_DEBUG, "OK : " + ACE_DEBUG ((LM_DEBUG, "RECEIVER OK: " "Thread switch for ConnectorStatusListener seems OK. " "(DDS uses the CCM thread for its callback) " "listener <%u> - component <%u>\n", @@ -202,7 +202,7 @@ namespace CIAO_CSL_DeadlineTest_Receiver_Impl } else { - ACE_ERROR ((LM_ERROR, "ERROR: " + ACE_ERROR ((LM_ERROR, "RECEIVER ERROR: " "Thread switch for ConnectorStatusListener " "doesn't seem to work! " "listener <%u> - component <%u>\n", @@ -213,7 +213,7 @@ namespace CIAO_CSL_DeadlineTest_Receiver_Impl else if (ACE_OS::thr_equal (this->thread_id_listener_.value (), ACE_Thread::self ())) { - ACE_ERROR ((LM_ERROR, "ERROR: ConnectorStatusListener: " + ACE_ERROR ((LM_ERROR, "RECEIVER ERROR: ConnectorStatusListener: " "DDS seems to use a CCM thread for its callback: " "listener <%u> - component <%u>\n", this->thread_id_listener_.value (), @@ -221,7 +221,7 @@ namespace CIAO_CSL_DeadlineTest_Receiver_Impl } else { - ACE_DEBUG ((LM_DEBUG, "OK : ConnectorStatusListener: " + ACE_DEBUG ((LM_DEBUG, "RECEIVER OK: ConnectorStatusListener: " "DDS seems to use its own thread for its callback: " "listener <%u> - component <%u>\n", this->thread_id_listener_.value (), diff --git a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.cpp b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.cpp index 4845d972418..8b0f957a4e7 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.cpp @@ -13,59 +13,67 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl { //============================================================ - // Facet Executor Implementation Class: ConnectorStatusListener_exec_i + // ConnectorStatusListener_exec_i //============================================================ - - ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Atomic_Boolean &deadline_missed) - : deadline_missed_ (deadline_missed) + ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Atomic_Boolean &deadline_missed, + Atomic_ThreadId &thread_id) + : deadline_missed_ (deadline_missed), + thread_id_ (thread_id) { } ConnectorStatusListener_exec_i::~ConnectorStatusListener_exec_i (void) { - } // Operations from ::CCM_DDS::ConnectorStatusListener - void ConnectorStatusListener_exec_i::on_inconsistent_topic( + void ConnectorStatusListener_exec_i::on_inconsistent_topic ( ::DDS::Topic_ptr /*the_topic*/, - const DDS::InconsistentTopicStatus & /*status*/){ - } + const DDS::InconsistentTopicStatus & /*status*/) + { + } - void ConnectorStatusListener_exec_i::on_requested_incompatible_qos( + void ConnectorStatusListener_exec_i::on_requested_incompatible_qos ( ::DDS::DataReader_ptr /*the_reader*/, - const DDS::RequestedIncompatibleQosStatus & /*status*/) { - } + const DDS::RequestedIncompatibleQosStatus & /*status*/) + { + } - void ConnectorStatusListener_exec_i::on_sample_rejected( - ::DDS::DataReader_ptr /*the_reader*/, - const DDS::SampleRejectedStatus & /*status*/) { - } + void ConnectorStatusListener_exec_i::on_sample_rejected ( + ::DDS::DataReader_ptr /*the_reader*/, + const DDS::SampleRejectedStatus & /*status*/) + { + } void ConnectorStatusListener_exec_i::on_offered_deadline_missed( - ::DDS::DataWriter_ptr the_writer, - const DDS::OfferedDeadlineMissedStatus & status) { - if(status.last_instance_handle.isValid && (!CORBA::is_nil (the_writer))) - { - this->deadline_missed_ = true; - } - } - + ::DDS::DataWriter_ptr the_writer, + const DDS::OfferedDeadlineMissedStatus & status) + { + this->thread_id_ = ACE_Thread::self (); + if(status.last_instance_handle.isValid && !CORBA::is_nil (the_writer)) + { + this->deadline_missed_ = true; + } + } + void ConnectorStatusListener_exec_i::on_offered_incompatible_qos( - ::DDS::DataWriter_ptr /*the_writer*/, - const DDS::OfferedIncompatibleQosStatus & /*status*/) { - } + ::DDS::DataWriter_ptr /*the_writer*/, + const DDS::OfferedIncompatibleQosStatus & /*status*/) + { + } void ConnectorStatusListener_exec_i::on_unexpected_status( ::DDS::Entity_ptr /*the_entity*/, - ::DDS::StatusKind /*status_kind*/) { - } + ::DDS::StatusKind /*status_kind*/) + { + } + //============================================================ - // Component Executor Implementation Class: Sender_exec_i + // Sender_exec_i //============================================================ - Sender_exec_i::Sender_exec_i (void) - : deadline_missed_ (false) + : deadline_missed_ (false), + thread_id_listener_ (0) { } @@ -76,11 +84,11 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl ::CCM_DDS::CCM_ConnectorStatusListener_ptr Sender_exec_i::get_test_topic_connector_status (void) { - return new ConnectorStatusListener_exec_i (this->deadline_missed_); + return new ConnectorStatusListener_exec_i (this->deadline_missed_, + this->thread_id_listener_); } // Supported operations and attributes. - void Sender_exec_i::set_session_context (::Components::SessionContext_ptr ctx) { @@ -104,23 +112,24 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl //to force an 'offered_deadline_missed' write the topics with a pause of 2 sec in between and //in the profile the deadline is set to 1 sec. for (CSL_QoSTest_Table::iterator i = this->_ktests_.begin (); - i != this->_ktests_.end (); - ++i) - { - try + i != this->_ktests_.end (); + ++i) { - if (!CORBA::is_nil (this->writer_) ) { - ACE_OS::sleep (2); - ::DDS::InstanceHandle_t hnd = this->writer_->register_instance (i->second); - this->writer_->write_one(i->second,hnd); - } + try + { + if (!CORBA::is_nil (this->writer_) ) + { + ACE_OS::sleep (2); + ::DDS::InstanceHandle_t hnd = this->writer_->register_instance (i->second); + this->writer_->write_one(i->second,hnd); + } + } + catch (const CCM_DDS::InternalError& ) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Internal Error while writing topic for <%C>.\n"), + i->first.c_str ())); + } } - catch (const CCM_DDS::InternalError& ) - { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("Internal Error while writing topic for <%C>.\n"), - i->first.c_str ())); - } - } } void @@ -131,6 +140,7 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl new_key->x = x; this->_ktests_[key] = new_key; } + void Sender_exec_i::ccm_activate (void) { @@ -150,20 +160,62 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl void Sender_exec_i::ccm_remove (void) { - - if(!this->deadline_missed_.value ()) + if (this->deadline_missed_.value ()) { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: did not receive the expected ") - ACE_TEXT ("warning 'on_offered_deadline_missed' in Sender\n") + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SENDER OK: Received the expected ") + ACE_TEXT ("'on_offered_deadline_missed'\n") )); } else { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Received the expected ") - ACE_TEXT ("'on_offered_deadline_missed' in Sender\n") + ACE_ERROR ((LM_ERROR, ACE_TEXT ("SENDER ERROR: did not receive the expected ") + ACE_TEXT ("error 'on_offered_deadline_missed'\n") )); } - + if (this->thread_id_listener_.value () == 0) + { + ACE_ERROR ((LM_ERROR, "SENDER ERROR: " + "Thread ID for ConnectorStatusListener not set!\n")); + } + #if defined (CIAO_DDS4CCM_CONTEXT_SWITCH) && (CIAO_DDS4CCM_CONTEXT_SWITCH == 1) + else if (ACE_OS::thr_equal (this->thread_id_listener_.value (), + ACE_Thread::self ())) + { + ACE_DEBUG ((LM_DEBUG, "SENDER OK: " + "Thread switch for ConnectorStatusListener seems OK. " + "(DDS uses the CCM thread for its callback) " + "listener <%u> - component <%u>\n", + this->thread_id_listener_.value (), + ACE_Thread::self ())); + } + else + { + ACE_ERROR ((LM_ERROR, "SENDER ERROR: " + "Thread switch for ConnectorStatusListener " + "doesn't seem to work! " + "listener <%u> - component <%u>\n", + this->thread_id_listener_.value (), + ACE_Thread::self ())); + } + #else + else if (ACE_OS::thr_equal (this->thread_id_listener_.value (), + ACE_Thread::self ())) + { + ACE_ERROR ((LM_ERROR, "SENDER ERROR: ConnectorStatusListener: " + "DDS seems to use a CCM thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_.value (), + ACE_Thread::self ())); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SENDER OK: ConnectorStatusListener: " + "DDS seems to use its own thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_.value (), + ACE_Thread::self ())); + } + #endif } extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.h b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.h index 75558a74b47..91fd6e77225 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.h +++ b/CIAO/connectors/dds4ccm/tests/CSLDeadline/Sender/CSL_DeadlineTest_Sender_exec.h @@ -20,40 +20,48 @@ namespace CIAO_CSL_DeadlineTest_Sender_Impl { typedef ACE_Atomic_Op <TAO_SYNCH_MUTEX, CORBA::Boolean > Atomic_Boolean; + typedef ACE_Atomic_Op <TAO_SYNCH_MUTEX, ACE_thread_t> Atomic_ThreadId; class Sender_exec_i; -class SENDER_EXEC_Export ConnectorStatusListener_exec_i + //============================================================ + // ConnectorStatusListener_exec_i + //============================================================ + class SENDER_EXEC_Export ConnectorStatusListener_exec_i : public virtual ::CCM_DDS::CCM_ConnectorStatusListener, public virtual ::CORBA::LocalObject { public: - ConnectorStatusListener_exec_i (Atomic_Boolean &); - virtual ~ConnectorStatusListener_exec_i (void); - + ConnectorStatusListener_exec_i (Atomic_Boolean &, + Atomic_ThreadId &); + virtual ~ConnectorStatusListener_exec_i (void); + virtual - void on_inconsistent_topic( ::DDS::Topic_ptr the_topic, + void on_inconsistent_topic (::DDS::Topic_ptr the_topic, const DDS::InconsistentTopicStatus & status); virtual - void on_requested_incompatible_qos( ::DDS::DataReader_ptr the_reader, + void on_requested_incompatible_qos (::DDS::DataReader_ptr the_reader, const DDS::RequestedIncompatibleQosStatus & status); virtual - void on_sample_rejected( ::DDS::DataReader_ptr the_reader, + void on_sample_rejected (::DDS::DataReader_ptr the_reader, const DDS::SampleRejectedStatus & status); virtual - void on_offered_deadline_missed( ::DDS::DataWriter_ptr the_writer, - const DDS::OfferedDeadlineMissedStatus & status); + void on_offered_deadline_missed (::DDS::DataWriter_ptr the_writer, + const DDS::OfferedDeadlineMissedStatus & status); virtual - void on_offered_incompatible_qos( ::DDS::DataWriter_ptr the_writer, + void on_offered_incompatible_qos (::DDS::DataWriter_ptr the_writer, const DDS::OfferedIncompatibleQosStatus & status); virtual - void on_unexpected_status( ::DDS::Entity_ptr the_entity, - ::DDS::StatusKind status_kind); - private: + void on_unexpected_status (::DDS::Entity_ptr the_entity, + ::DDS::StatusKind status_kind); + private: Atomic_Boolean &deadline_missed_; - + Atomic_ThreadId &thread_id_; }; +//============================================================ + // Sender_exec_i + //============================================================ class Sender_exec_i : public virtual Sender_Exec, public virtual ::CORBA::LocalObject @@ -61,8 +69,6 @@ class SENDER_EXEC_Export ConnectorStatusListener_exec_i public: Sender_exec_i (void); virtual ~Sender_exec_i (void); - virtual void add_instance_of_topic (const char *, int x ); - virtual void write (void); virtual void set_session_context (::Components::SessionContext_ptr ctx); virtual void configuration_complete (void); @@ -71,15 +77,21 @@ class SENDER_EXEC_Export ConnectorStatusListener_exec_i virtual void ccm_remove (void); // Port operations. virtual ::CCM_DDS::CCM_ConnectorStatusListener_ptr - get_test_topic_connector_status(void); + get_test_topic_connector_status(void); private: ::CSL_DeadlineTest::CCM_Sender_Context_var context_; - Atomic_Boolean deadline_missed_; CCM_DDS::TestTopic::Writer_var writer_; + + Atomic_Boolean deadline_missed_; + Atomic_ThreadId thread_id_listener_; + TAO_SYNCH_MUTEX mutex_; typedef std::map<ACE_CString, TestTopic_var> CSL_QoSTest_Table; CSL_QoSTest_Table _ktests_; + + void add_instance_of_topic (const char *, int x ); + void write (void); }; extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/connectors/dds4ccm/tests/CSLQoS/Sender/CSL_QoSTest_Sender_exec.cpp b/CIAO/connectors/dds4ccm/tests/CSLQoS/Sender/CSL_QoSTest_Sender_exec.cpp index 4959dba2e97..e0482530b76 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLQoS/Sender/CSL_QoSTest_Sender_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/CSLQoS/Sender/CSL_QoSTest_Sender_exec.cpp @@ -123,13 +123,13 @@ namespace CIAO_CSL_QoSTest_Sender_Impl if (!this->incompatible_.value ()) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("SENDER ERROR: did not receive the expected ") - ACE_TEXT ("error 'on_requested_incompatible_Qos' in Receiver\n") + ACE_TEXT ("error 'on_requested_incompatible_Qos'\n") )); } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SENDER OK: Received the expected ") - ACE_TEXT ("'on_requested_incompatible_Qos' in Receiver\n") + ACE_TEXT ("'on_requested_incompatible_Qos'\n") )); } if (this->thread_id_listener_.value () == 0) |