From 4359fc36180c9baf93997a3b91e58576e2c177b4 Mon Sep 17 00:00:00 2001 From: wu-leilei Date: Thu, 3 Aug 2023 14:10:45 +0800 Subject: [PATCH] Fix using on a double reference --- 389-ds-base.spec | 6 ++- fix-using-borrow-on-a-double-reference.patch | 55 ++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 fix-using-borrow-on-a-double-reference.patch diff --git a/389-ds-base.spec b/389-ds-base.spec index cee5cea..2827a6e 100644 --- a/389-ds-base.spec +++ b/389-ds-base.spec @@ -6,7 +6,7 @@ ExcludeArch: i686 Name: 389-ds-base Summary: Base 389 Directory Server Version: 2.3.2 -Release: 2 +Release: 3 License: GPLv3+ URL: https://www.port389.org Source0: https://releases.pagure.org/389-ds-base/389-ds-base-%{version}.tar.bz2 @@ -14,6 +14,7 @@ Source1: 389-ds-base-git.sh Source2: 389-ds-base-devel.README Patch0: Replace-LegacyVersion-with-DSVersion-to-fix-build-error.patch +Patch1: fix-using-borrow-on-a-double-reference.patch BuildRequires: nspr-devel nss-devel >= 3.34 perl-generators openldap-devel libdb-devel cyrus-sasl-devel icu BuildRequires: libicu-devel pcre-devel cracklib-devel gcc-c++ net-snmp-devel lm_sensors-devel bzip2-devel @@ -319,6 +320,9 @@ exit 0 %{_mandir}/*/* %changelog +* Thu Aug 03 2023 wulei - 2.3.2-3 +- Fix using `.borrow()` on a double reference + * Tue Jul 18 2023 xu_ping <707078654@qq.com> - 2.3.2-2 - Replace LegacyVersion with DSVersion to fix build error. diff --git a/fix-using-borrow-on-a-double-reference.patch b/fix-using-borrow-on-a-double-reference.patch new file mode 100644 index 0000000..443acdd --- /dev/null +++ b/fix-using-borrow-on-a-double-reference.patch @@ -0,0 +1,55 @@ +From 1d5586780b7144b3e1fa17b827f461b10f076be4 Mon Sep 17 00:00:00 2001 +From: Simon Pichugin +Date: Mon, 24 Jul 2023 15:42:11 -0700 +Subject: [PATCH] fix using borrow() on a double reference +Reference: https://github.com/389ds/389-ds-base/pull/5854 + +error: using `.borrow()` on a double reference, which returns +`&concread::cowcell::CowCellReadTxn` instead of borrowing the inner type + +We're getting the error about borrowing a double reference because +we're trying to borrow a type that is already a reference. +Fix - use the type directly. + +--- + src/librslapd/src/cache.rs | 4 +--- + src/slapi_r_plugin/src/value.rs | 2 +- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/src/librslapd/src/cache.rs b/src/librslapd/src/cache.rs +index 092c81d..b025c83 100644 +--- a/src/librslapd/src/cache.rs ++++ b/src/librslapd/src/cache.rs +@@ -1,6 +1,5 @@ + // This exposes C-FFI capable bindings for the concread concurrently readable cache. + use concread::arcache::{ARCache, ARCacheBuilder, ARCacheReadTxn, ARCacheWriteTxn}; +-use std::borrow::Borrow; + use std::convert::TryInto; + use std::ffi::{CStr, CString}; + use std::os::raw::c_char; +@@ -56,8 +55,7 @@ pub extern "C" fn cache_char_stats( + debug_assert!(!cache.is_null()); + &(*cache) as &ARCacheChar + }; +- let stat_rguard = cache_ref.inner.view_stats(); +- let stats = stat_rguard.borrow(); ++ let stats = cache_ref.inner.view_stats(); + *reader_hits = stats.reader_hits.try_into().unwrap(); + *reader_includes = stats.reader_includes.try_into().unwrap(); + *write_hits = stats.write_hits.try_into().unwrap(); +diff --git a/src/slapi_r_plugin/src/value.rs b/src/slapi_r_plugin/src/value.rs +index cd56529..2fd35c8 100644 +--- a/src/slapi_r_plugin/src/value.rs ++++ b/src/slapi_r_plugin/src/value.rs +@@ -182,7 +182,7 @@ impl From<&Uuid> for Value { + let s_ptr = cstr.as_ptr(); + Box::leak(cstr); + +- let mut v = unsafe { slapi_value_new() }; ++ let v = unsafe { slapi_value_new() }; + unsafe { + (*v).bv.len = len; + (*v).bv.data = s_ptr as *const u8; +-- +2.27.0 +