!32 修复在两层常量引用上使用'.borrow'报错问题

From: @wu-leilei 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
This commit is contained in:
openeuler-ci-bot 2023-08-03 07:42:19 +00:00 committed by Gitee
commit 93bd94ca65
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 60 additions and 1 deletions

View File

@ -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 <wu_lei@hoperun.com> - 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.

View File

@ -0,0 +1,55 @@
From 1d5586780b7144b3e1fa17b827f461b10f076be4 Mon Sep 17 00:00:00 2001
From: Simon Pichugin <spichugi@redhat.com>
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<CacheStats>` 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