fix: 在插入新的timer时,边界条件判断不正确的问题 (#1091)

修复split_pos 初始值错误导致原本应该被插入到链表末尾的定时器,插入到了链表头

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
LoGin 2025-03-07 12:05:45 +08:00 committed by GitHub
parent 597315b04d
commit 6fa06ff08a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

3
.gitignore vendored
View File

@ -18,4 +18,5 @@ cppcheck.xml
/target/ /target/
Cargo.lock Cargo.lock
.cache .cache
compile_commands.json compile_commands.json
/logs/

View File

@ -157,7 +157,7 @@ impl Timer {
let expire_jiffies = inner_guard.expire_jiffies; let expire_jiffies = inner_guard.expire_jiffies;
let self_arc = inner_guard.self_ref.upgrade().unwrap(); let self_arc = inner_guard.self_ref.upgrade().unwrap();
drop(inner_guard); drop(inner_guard);
let mut split_pos: usize = 0; let mut split_pos: usize = timer_list.len();
for (pos, elt) in timer_list.iter().enumerate() { for (pos, elt) in timer_list.iter().enumerate() {
if Arc::ptr_eq(&self_arc, &elt.1) { if Arc::ptr_eq(&self_arc, &elt.1) {
warn!("Timer already in list"); warn!("Timer already in list");