Skip to content

Commit

Permalink
增加 ListenTable 来检测端口占用 (#291)
Browse files Browse the repository at this point in the history
* 增加 ListenTable 来检测端口占用


* 使用Arc封装GlobalSocketHandle

* 删除 listen 处的端口检测逻辑,延至实现端口复用时完成

* 设立两张表,分别记录TCP和UDP的端口占用

* 实现 meatadata 相关逻辑

* 实现socket关闭时,端口在表中移除

* 使用端口管理器重构端口记录表

* 修正与RawSocket相关的端口管理逻辑

* 补充测试文件

* 修正 unbind_port 在逻辑错误

* 修正格式问题

---------

Co-authored-by: longjin <longjin@RinGoTek.cn>
  • Loading branch information
ccrysisa and fslongjin committed Jul 28, 2023
1 parent 7cc4a02 commit 821bb9a
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 51 deletions.
2 changes: 1 addition & 1 deletion kernel/src/filesystem/vfs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub fn do_mkdir(path: &str, _mode: FileMode) -> Result<u64, SystemError> {
return Ok(0);
}

/// @breif 删除文件夹
/// @brief 删除文件夹
pub fn do_remove_dir(path: &str) -> Result<u64, SystemError> {
// 文件名过长
if path.len() > PAGE_4K_SIZE as usize {
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/io/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub trait BlockDevice: Any + Send + Sync + Debug {
/// @brief: 同步磁盘信息,把所有的dirty数据写回硬盘 - 待实现
fn sync(&self) -> Result<(), SystemError>;

/// @breif: 每个块设备都必须固定自己块大小,而且该块大小必须是2的幂次
/// @brief: 每个块设备都必须固定自己块大小,而且该块大小必须是2的幂次
/// @return: 返回一个固定量,硬编码(编程的时候固定的常量).
fn blk_size_log2(&self) -> u8;

Expand Down
4 changes: 2 additions & 2 deletions kernel/src/mm/allocator/buddy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ pub struct BuddyAllocator<A> {

impl<A: MemoryManagementArch> BuddyAllocator<A> {
const BUDDY_ENTRIES: usize =
// 定义一个变量记录buddy表的大小
// 定义一个变量记录buddy表的大小
(A::PAGE_SIZE - mem::size_of::<PageList<A>>()) / mem::size_of::<PhysAddr>();

pub unsafe fn new(mut bump_allocator: BumpAllocator<A>) -> Option<Self> {
let initial_free_pages = bump_allocator.usage().free();
kdebug!("Free pages before init buddy: {:?}", initial_free_pages);
Expand Down
Loading

0 comments on commit 821bb9a

Please sign in to comment.