| 1969 | } |
| 1970 | |
| 1971 | void finish_store_instance_data(unique_ptr<MessageTypeWithAllocator> instance_data, const DataSampleHeader& header, |
| 1972 | SubscriptionInstance_rch instance_ptr, bool is_dispose_msg, bool is_unregister_msg ) |
| 1973 | { |
| 1974 | if ((qos_.resource_limits.max_samples_per_instance != |
| 1975 | DDS::LENGTH_UNLIMITED) && |
| 1976 | (instance_ptr->rcvd_samples_.size() >= |
| 1977 | static_cast<size_t>(qos_.resource_limits.max_samples_per_instance))) { |
| 1978 | |
| 1979 | // According to spec 1.2, Samples that contain no data do not |
| 1980 | // count towards the limits imposed by the RESOURCE_LIMITS QoS policy |
| 1981 | // so do not remove the oldest sample when unregister/dispose |
| 1982 | // message arrives. |
| 1983 | |
| 1984 | if (!is_dispose_msg && !is_unregister_msg |
| 1985 | && !instance_ptr->rcvd_samples_.matches(DDS::READ_SAMPLE_STATE)) |
| 1986 | { |
| 1987 | DDS::DataReaderListener_var listener |
| 1988 | = listener_for(DDS::SAMPLE_REJECTED_STATUS); |
| 1989 | |
| 1990 | set_status_changed_flag(DDS::SAMPLE_REJECTED_STATUS, true); |
| 1991 | |
| 1992 | sample_rejected_status_.last_reason = |
| 1993 | DDS::REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT; |
| 1994 | ++sample_rejected_status_.total_count; |
| 1995 | ++sample_rejected_status_.total_count_change; |
| 1996 | sample_rejected_status_.last_instance_handle = instance_ptr->instance_handle_; |
| 1997 | |
| 1998 | if (!CORBA::is_nil(listener.in())) |
| 1999 | { |
| 2000 | ACE_GUARD(typename DataReaderImpl::Reverse_Lock_t, unlock_guard, reverse_sample_lock_); |
| 2001 | |
| 2002 | listener->on_sample_rejected(this, sample_rejected_status_); |
| 2003 | sample_rejected_status_.total_count_change = 0; |
| 2004 | } // do we want to do something if listener is nil??? |
| 2005 | notify_status_condition_no_sample_lock(); |
| 2006 | return; |
| 2007 | } |
| 2008 | else if (!is_dispose_msg && !is_unregister_msg) |
| 2009 | { |
| 2010 | // Discard the oldest previously-read sample |
| 2011 | OpenDDS::DCPS::ReceivedDataElement* item = |
| 2012 | instance_ptr->rcvd_samples_.remove_head(); |
| 2013 | item->dec_ref(); |
| 2014 | } |
| 2015 | } |
| 2016 | else if (qos_.resource_limits.max_samples != DDS::LENGTH_UNLIMITED) |
| 2017 | { |
| 2018 | CORBA::Long total_samples = 0; |
| 2019 | { |
| 2020 | ACE_GUARD(ACE_Recursive_Thread_Mutex, instance_guard, instances_lock_); |
| 2021 | for (OpenDDS::DCPS::DataReaderImpl::SubscriptionInstanceMapType::iterator iter = instances_.begin(); |
| 2022 | iter != instances_.end(); |
| 2023 | ++iter) { |
| 2024 | OpenDDS::DCPS::SubscriptionInstance_rch ptr = iter->second; |
| 2025 | |
| 2026 | total_samples += (CORBA::Long) ptr->rcvd_samples_.size(); |
| 2027 | } |
| 2028 | } |
no test coverage detected