| 3094 | } |
| 3095 | |
| 3096 | DDS::ReturnCode_t DataWriterImpl::get_or_create_instance_handle( |
| 3097 | DDS::InstanceHandle_t& handle, |
| 3098 | const Sample& sample, |
| 3099 | const DDS::Time_t& source_timestamp) |
| 3100 | { |
| 3101 | ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, get_lock(), DDS::RETCODE_ERROR); |
| 3102 | |
| 3103 | handle = lookup_instance(sample); |
| 3104 | if (handle == DDS::HANDLE_NIL || !get_handle_instance(handle)) { |
| 3105 | Sample_rch copy = sample.copy(Sample::ReadOnly, Sample::KeyOnly); |
| 3106 | #if OPENDDS_CONFIG_SECURITY && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER |
| 3107 | DDS::DynamicData_var dynamic_data = copy->get_dynamic_data(dynamic_type_); |
| 3108 | DDS::Security::SecurityException ex; |
| 3109 | if (dynamic_data && security_config_ && |
| 3110 | participant_permissions_handle_ != DDS::HANDLE_NIL && |
| 3111 | !security_config_->get_access_control()->check_local_datawriter_register_instance(participant_permissions_handle_, this, dynamic_data, ex)) { |
| 3112 | if (log_level >= LogLevel::Notice) { |
| 3113 | ACE_ERROR((LM_NOTICE, |
| 3114 | "(%P|%t) NOTICE: DataWriterImpl::get_or_create_instance_handle: unable to register instance SecurityException[%d.%d]: %C\n", |
| 3115 | ex.code, ex.minor_code, ex.message.in())); |
| 3116 | } |
| 3117 | return DDS::Security::RETCODE_NOT_ALLOWED_BY_SECURITY; |
| 3118 | } |
| 3119 | #endif |
| 3120 | |
| 3121 | // don't use fast allocator for registration. |
| 3122 | const TypeSupportImpl* const ts = get_type_support(); |
| 3123 | Message_Block_Ptr serialized(serialize_sample(*copy)); |
| 3124 | if (!serialized) { |
| 3125 | if (log_level >= LogLevel::Notice) { |
| 3126 | ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: %CDataWriterImpl::get_or_create_instance_handle: " |
| 3127 | "failed to serialize sample\n", ts->name())); |
| 3128 | } |
| 3129 | return DDS::RETCODE_ERROR; |
| 3130 | } |
| 3131 | |
| 3132 | // tell DataWriterLocal and Publisher about the instance. |
| 3133 | const DDS::ReturnCode_t ret = register_instance_i(handle, OPENDDS_MOVE_NS::move(serialized), source_timestamp); |
| 3134 | // note: the WriteDataContainer/PublicationInstance maintains ownership |
| 3135 | // of the marshalled sample. |
| 3136 | if (ret != DDS::RETCODE_OK) { |
| 3137 | handle = DDS::HANDLE_NIL; |
| 3138 | return ret; |
| 3139 | } |
| 3140 | |
| 3141 | if (!insert_instance(handle, copy)) { |
| 3142 | handle = DDS::HANDLE_NIL; |
| 3143 | if (log_level >= LogLevel::Notice) { |
| 3144 | ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: %CDataWriterImpl::get_or_create_instance_handle: " |
| 3145 | "insert instance failed\n", ts->name())); |
| 3146 | } |
| 3147 | return DDS::RETCODE_ERROR; |
| 3148 | } |
| 3149 | |
| 3150 | send_all_to_flush_control(guard); |
| 3151 | } |
| 3152 | |
| 3153 | return DDS::RETCODE_OK; |
nothing calls this directly
no test coverage detected