summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-09-22TimeoutCallBack wraps timeout_cb to simplify callback function writing, ↵HEADmasterzy
still have some problem: - `arg: &'a mut T ` need be `&'a mut T` or `&'a T` ? - for RefCell::new(session), how to ensure the life cycle? test code update
2023-09-22Enable periodic timeout : TimeoutType::INTzy
- periodic timeout, start time only supports relative time. - first expired on now + timeout, then expired at now + timeout + timeout + .. TimeoutManager - add Iterator for expired_timeouts and netx_tiemouts - expired_timeout support periodic timeout, only return quote (Ownership still on C side) test code update
2023-09-22mv test_timeout.rs to /tests/zy
make mod be pub
2023-09-22test_callback updatezy
2023-09-21tiemout_bind.rs: allow non_upper_casezy
2023-09-21TimeoutSItFlag: remove CLEARzy
Test code update
2023-09-21change Timeout ref timeout -> Timeout = timeoutzy
- use ref can not fix timeout's life cycle. - rewrite is_pending / is_expired , no need `& mut self` anymore. - fix drop for Timeout. TimeoutSItFlag - remove TIMEOUTS_CLEAR: make sure when call TimeoutManager::next_timeout , any list will not chang. TimeoutManager - add: Pass in ownership of the Timeout object - next_expired_timeout -> expired_timeout: Ownership of timeout objects moved from c to rust - next_timeout: return next quote of timeout objects Test code update
2023-09-21find bug: Timeout should 1to1 with timeout.zy
2023-09-20- TimeoutCallBack 定义 和 单元测试(通过)zy
- fix TimeoutSIt drop 时候 free 内存() - TimeoutManager: get_next_wait_time 根据 c 代码,修正 定义 和 单元测试 - test_timeout_manger 单元测试
2023-09-20timeout_cb 修改 函数指针名称 和 定义zy
2023-09-20TimeoutSItFlag -> i32zy
补充 TimeoutSItFlag 单元测试
2023-09-20- 简化 TimeoutSItFlagzy
- 修正 TimeoutSIt 实例申请 bug (Box::into_raw)
2023-09-20fix errzy
- timeout 申请内存在 rust 通过 Box::into_raw 将所有权交给 C 侧. 最后 Timeout drop 时 调用 C free释放 - 主要为了 is_pending is_expired 等方法减少样板代码 - 修正 NonNull 错误 - 简化 TimeoutType - timeout_type timeout 的单元测试 通过
2023-09-20high level api (no test yet)zy
2023-09-20完善bindzy
- 字符串常量补充 `\0` - timeout_t 改为 rust 的 u64 类型 - 精简 timeouts 结构体声明(无需)
2023-09-20更多注释zy
2023-09-15重命名文件 -> bind 与 封装区分zy
2023-09-15check_intervals 完成, 与 test-timeout.c 输出相同.zy
ffi 导出 bind 完整过了测试.
2023-09-15修正一个变量类型zy
2023-09-15remove TODO..zy
2023-09-15gcc 优化级别 O0 方便调试,默认是 O2 ↵zy
对宏定义有优化,断点追踪时常失效.
2023-09-15test: check_randomized finishzy
2023-09-15移除 `#[link(name = "timeout")]` 声明,提前到 build.rs 中.zy
补充缺失的 struct 定义
2023-09-15rust-analyzer 使用 rust-gdb 调试, 这样可以跳转到 C ↵zy
的断点调试了. - 一个缺点: c 代码中变量有时会识别成 rust 的可空类型, 个别时候得手动加个打印
2023-09-14链接静态库,方便调试zy
2023-09-14timeout: 添加静态编译zy
2023-09-14debug 添加 vscode c 调试配置zy
2023-09-13仿照 test-timeout.c 编写 test_timeout.rszy
- cfg1 测试不通过, 临时的 now 超过了 100 就 panic - cfg2b 反而可以测试通过; 修正了 timeout.rs 的几个类型错误, 为一些结构体 提供默认初始化方法.
2023-09-13lib.rszy
2023-09-13增加 rand 依赖(test_timeout.rs 需要随机数生成)zy
2023-09-13timeouts_it 等定义zy
2023-09-12timeout.h ffi 绑定和部分测试zy
todo: 宏定义部分待检查.
2023-09-12从 系统 获取 libtimeout.sozy
2023-09-12timeout: 增加 install 选项, 安装到系统zy
2023-09-12调整文件布局, rs-timeout 为主目录, timeout.c 等为二级目录zy
2023-09-12gitignore: ignore 忽略 rustzy
2023-09-12rust 容器环境zy
2023-09-12rs-timeout initzy
2023-09-12timeout: makefile add timeout.so outputzy
2016-05-12Fix a signed overflow warning in test_timeouts.cNick Mathewson
Technically, when int is 32-bit, 1<<31 is an overflow.
2016-02-26Merge branch 'nmathewson-test_foreach'William Ahern
2016-02-26Merge branch 'test_foreach' of git://github.com/nmathewson/timeout into ↵William Ahern
nmathewson-test_foreach
2016-02-26Merge branch 'nmathewson-fixing_intervals'William Ahern
2016-02-26Merge branch 'fixing_intervals' of git://github.com/nmathewson/timeout into ↵William Ahern
nmathewson-fixing_intervals
2016-02-26add Lua module, move noise into subdirectories, and make build portable by ↵William Ahern
only using POSIX make syntax and semantics
2016-02-26fix use-after-free in test-timeout.cWilliam Ahern
2016-02-26Branch-complete tests for timeouts_next()Nick Mathewson
2016-02-26Make the tests cover timeout_readd() betterNick Mathewson
Also, make them check the required invariants for to->expires after timeout_readd(). Also, actually use the different timeout values in the main() function (whoops).
2016-02-26Correct and simplify timeouts_readd()Nick Mathewson
William Ahern tells me that the intent here is that timeout_readd() should always reschedule the timeout at the first time in the future that is an even multiple of to->interval, as if we had called: do { to->expires += to->interval; } while (to->expires <= T->curtime); But of course, that's not efficient. The implementation strategy used in this patch simplifies the calculation down to a single % operation, plus a few additions and subtractions. To verify the correctness of the formula used here, note first that 0 <= r < to->interval, and so 0 < to->interval - r <= to->interval. Since expires' = curtime + (interval - r), curtime < expires' <= curtime + interval, and so the new expiration time is no more than one interval after curtime. Note second that since r = (curtime - expires) % interval, expires' = curtime + (interval - r), we have (expires' - expires) % interval = (curtime + (interval - r) - expires) % interval = (curtime - r - expires) % interval = (curtime - (curtime-expires) % interval - expires) % interval = (curtime - curtime + expires - expires) % interval = 0. And so the new expiration time is an even multiple of interval from the original expiration time. Since we have both properties we wanted, this formula should be right.
2016-02-25silence really annoying -Wmissing-field-initializers GCC and clang warningWilliam Ahern