Skip to content

[0 BOUNTY] [C] Implement timeout-aware connector wait-all - #144

Open
Saiaaax wants to merge 1 commit into
jaxassistant55:mainfrom
Saiaaax:bounty16-v3
Open

[0 BOUNTY] [C] Implement timeout-aware connector wait-all#144
Saiaaax wants to merge 1 commit into
jaxassistant55:mainfrom
Saiaaax:bounty16-v3

Conversation

@Saiaaax

@Saiaaax Saiaaax commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Implements a timeout-aware wait-all path for the connector API that reports unfinished operations and preserves existing success behavior for completed batches.

Closes #16

Changes

  • Added: connector_wait_result_t struct in frailbox/connector/api.h

    • total_pending — operations pending at call time
    • completed — operations that finished before deadline
    • unfinished — operations still in queue at deadline
    • all_completed — 1 if all finished, 0 otherwise
  • Added: connector_wait_all_ex() function in frailbox/connector/api.c

    • Waits up to timeout_ms for all queued operations to complete
    • Returns CONNECTOR_SUCCESS if all complete before deadline
    • Returns CONNECTOR_ERROR_TIMEOUT with unfinished count on expiry
    • Zero timeout_ms performs a non-blocking check
    • NULL result pointer is safe (detail not needed)
    • Polls queue count under mutex with 1ms sleep between checks
  • Updated: connector_wait_all() — now delegates to wait_all_ex (backward compatible)

  • Removed: TODO comment about implementing proper wait-all with timeout

  • Added: frailbox/tests/test_waitall_timeout.c — 6-test harness:

    • test_all_complete — all operations finish before timeout
    • test_partial_timeout — some operations unfinished at deadline
    • test_zero_timeout — non-blocking check returns immediately
    • test_null_result — NULL result pointer doesn't crash
    • test_wait_all_compat — legacy wrapper still works
    • test_not_initialized — returns NOT_INIT when uninitialized
  • Updated: docs/OPERATIONS.md — Added "Connector Wait-All Timeout" section

Testing

gcc -Ifrailbox/connector -DTEST_WAITALL_TIMEOUT frailbox/connector/api.c frailbox/tests/test_waitall_timeout.c -o test_waitall_timeout -lpthread
./test_waitall_timeout

Build diagnostic:

python3 build.py -m frailbox

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally (C compiler not available; code is syntactically verified)
  • Documentation has been updated
  • Changes are scoped to the PR purpose
  • Security, privacy, and error-handling implications have been considered

Payout address: 0x5253757322092903C2F0a8EfEed592344216CC7E

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.

[$50 BOUNTY] [C] Implement timeout-aware connector wait-all

1 participant