Skip to content

add new init method for FdTable and BufferTable#50

Merged
wokron merged 1 commit into
masterfrom
add-new-table-init
Feb 19, 2026
Merged

add new init method for FdTable and BufferTable#50
wokron merged 1 commit into
masterfrom
add-new-table-init

Conversation

@wokron
Copy link
Copy Markdown
Member

@wokron wokron commented Feb 17, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds new init methods to both FdTable and BufferTable classes that allow initialization with pre-populated arrays, complementing the existing init methods that only allocate capacity. The PR also corrects documentation for the update methods to accurately reflect that they return the count of updated items rather than 0 on success.

Changes:

  • Added FdTable::init(const int *fds, unsigned nr_fds) method for initializing with file descriptor arrays
  • Added BufferTable::init(const iovec *vecs, unsigned nr_vecs) method for initializing with buffer arrays
  • Updated documentation for FdTable::update and BufferTable::update to correctly state they return the number of items updated
  • Added test cases for the new initialization methods

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
include/condy/ring.hpp Added new init method overloads for FdTable and BufferTable; corrected return value documentation for update methods
tests/test_fd_table.cpp Added test case for init with fd array; updated existing test to verify update return values
tests/test_buffer_table.cpp Added test case for init with iovec array
Comments suppressed due to low confidence (1)

tests/test_fd_table.cpp:75

  • The test does not clean up the fd_table after initialization. Unlike the test_buffer_table.cpp which tests destroy() and multiple init() calls to verify state management (line 17-23), this test doesn't call destroy() after using init(). This could lead to resource leaks or state pollution between tests if the table is shared. Consider adding cleanup or verifying that multiple init() calls are handled correctly.
TEST_CASE("test fd_table - init with fd array") {
    auto func = []() -> condy::Coro<void> {
        auto &fd_table = condy::detail::Context::current().ring()->fd_table();

        int pipes[2];
        int ret = pipe(pipes);
        REQUIRE(ret == 0);

        int r = fd_table.init(pipes, 2);
        REQUIRE(r == 0);

        close(pipes[0]);
        close(pipes[1]);

        pipes[0] = -1;
        pipes[1] = -1;

        r = fd_table.update(0, pipes, 2);
        REQUIRE(r == 2);

        co_return;
    };

    condy::sync_wait(func());
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/condy/ring.hpp
Comment thread tests/test_buffer_table.cpp
@wokron wokron marked this pull request as ready for review February 19, 2026 07:50
@wokron wokron merged commit c9b3d97 into master Feb 19, 2026
24 of 25 checks passed
@wokron wokron deleted the add-new-table-init branch February 19, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants