Commit Graph

40 Commits

Author SHA1 Message Date
Eugene Kabanov d270dba8a3
Fix unused warnings, result, asyncCheck and 80 cpl (#185)
* Fix sources to follow 80 characters per line.
Fix unused compilation warnings.
Refactor (remove result) handles.nim.
Fix tests to use asyncSpawn instead of asyncCheck.

* Fix handles for Unix platforms.
2021-05-07 23:52:24 +03:00
Eugene Kabanov 39f4060e07
Refactor and optimization of BoundedStream. (#180)
Documentation for BoundedStream.
Fix HttpServer bounding.
2021-04-26 14:05:37 +03:00
Jacek Sieka 895fc53193
add explicit gcsafe annotations (fixes #174) (#175)
Seems like a variation of https://github.com/nim-lang/Nim/issues/17369
2021-04-03 10:05:08 +02:00
Jacek Sieka 4abd7a5645
exception tracking (#166)
* exception tracking

This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.

In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.

As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.

Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.

Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.

* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there

* fixes

* docs, platform-independent eh specifiers for some functions

* add feature flag for strict exception mode

also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.

* fix AsyncCheck for non-void T
2021-03-24 10:08:33 +01:00
cheatfate fb137112be Remove debugging changes. 2021-02-18 22:16:04 +02:00
cheatfate 13eddf382d Simplification and fixes for TLSStream state machine. 2021-02-18 22:16:04 +02:00
cheatfate 49fd70f504 Attempt #4. 2021-02-18 22:16:04 +02:00
cheatfate f1b43aeb04 Investigation of Linux freezes #3. 2021-02-18 22:16:04 +02:00
Eugene Kabanov 0933feaa35
Fix callSoon to raise Defect only. (#145)
* Initial commit.

* Move pragmas to forward declaration.
Add raises to callSoon declaration.

* Fix for IOSelectorsException.
2021-01-11 18:15:23 +01:00
Eugene Kabanov ac9b3e304f
Fix deadlock for pending write() calls on transport close. (#139)
Add tests for read() and write() deadlocks.
2020-11-18 11:30:33 +02:00
Eugene Kabanov 57ebe84d17
Add Defect check for arguments `pbytes` and `nbytes`. (#128)
* Add Defect check for arguments `pbytes` and `nbytes`.

* Allow some edge cases to be not Defect.
2020-09-10 03:50:06 +03:00
Eugene Kabanov 31fec25063
Fix accept races. (#110)
* Fix accept races.
2020-07-15 11:09:34 +03:00
cheatfate 783f84aa4b
Fix EAGAIN issue in acceptLoop(). 2020-07-15 01:07:03 +03:00
Ștefan Talpalaru 0ad7321aa0
ServerFlags.ReusePort support on POSIX (#95) 2020-07-12 18:13:22 +02:00
Eugene Kabanov 528688d01e
Add sanity check. (#105) 2020-06-25 09:32:41 +03:00
Eugene Kabanov 02b8da986b
Add accept() call (#103)
* Add accept() call and tests.
* Fix rare fd leaks on Windows.
* Fix compilation warnings.
* Add fd leak test.
* Bump version to 2.4.0.
2020-06-24 11:21:52 +03:00
Eugene Kabanov bedd1ded5e
Properly fix cancellation race and not introduce FD leaks. (#102) 2020-06-05 19:11:51 +03:00
Eugene Kabanov d6d0084333
Fix cancellation race when connect() call is getting cancelled. (#101) 2020-06-04 13:07:52 +03:00
Jacek Sieka d8f8e3d9fc
readMsg branch by @arnetheduck with some changes. (#83)
Co-authored-by: Eugene Kabanov <ka@hardcore.kiev.ua>
2020-03-05 10:59:10 +01:00
cheatfate 64583b4269
Fix Windows datagram's AnyAddress issue.
Add test for datagram's AnyAddress.
Bump version to 2.3.6.
2020-02-25 23:50:39 +02:00
cheatfate 80351cb928
Fix #73. 2020-02-12 22:54:05 +02:00
cheatfate 74700fdcab Fix bug cancellation handlers not called in wait() and withTimeout().
Fix double completion bug because of callback race.
Fix deprecation warnings.
Rename some internal procedures.
Bump version to 2.3.5.
2020-01-27 22:32:08 +02:00
cheatfate 811c5f66ae
More *nix fixes. 2019-10-30 00:40:02 +02:00
cheatfate fb00b20cfa
Fix all compilation warnings for 1.0.2.
Fix all related problems.
2019-10-29 23:19:41 +02:00
cheatfate b59e759e87
Fix #53 2019-10-23 14:13:23 +03:00
cheatfate 3b8874a9e8
Fix issue with Windows connect(0.0.0.0). 2019-10-09 15:12:19 +03:00
cheatfate 7029f8bc1e
Fix behavior for write operations. 2019-08-28 07:57:06 +03:00
cheatfate 03eb8a0157
Add pipe support for StreamTransport.
Bump version to 2.2.8.
2019-07-15 12:59:42 +03:00
cheatfate 7d7753b7fd
Initial cancellation proposal. 2019-06-20 23:30:41 +03:00
cheatfate f83d1b4da4
Remove some unused symbols. 2019-06-08 08:37:58 +03:00
cheatfate a8a1138b8b
Fix for race condition in *nix connect(). 2019-06-06 21:22:17 +03:00
Eugene Kabanov 9160dcdbba
Merge pull request #37 from status-im/asyncstream
Asynchronous streams.
2019-06-06 15:05:08 +03:00
cheatfate 49bae9792d
Fix documentation for read(n) procedure. 2019-05-28 20:12:00 +03:00
cheatfate 317ce3c797
Ignore ECONNRESET and EPIPE errors on sending.
Add test for ECONNRESET error.
2019-05-28 09:29:00 +03:00
cheatfate 6e7a753793
Fix for Windows server close procedure. 2019-05-09 20:59:15 +03:00
cheatfate 1763c9dcff
Add AsyncStreams.
Add Chunked-Encoding AsyncStream reader/writer.
Add tests.
2019-05-07 23:11:40 +03:00
cheatfate 6a1f7785a0
Custom tracking mechanism.
1. Add simple tracking of Datagram and Stream transports.
2. Fix leaks in tests.
3. Add leaks tests to Datagram and Stream transport tests.
2019-04-04 12:34:23 +03:00
cheatfate 80ee289847
Fix rarely appearing Windows bug with close(transport).
Add tests for it.
Add fromProc for all Future[T] in transports.
Add testall to improve tests speed.
Bump version to 2.2.4.
2019-03-31 00:31:10 +02:00
Eugene Kabanov 67e214c5df Introduce monotonic timer functions. (#24)
* Introduce monotonic timer functions.
Old fast timers are available through compiler switch.
Add tests for both timers.
* Bump version to 2.2.2.
2019-03-24 10:57:36 -06:00
Mamy Ratsimbazafy 9f15c6b752
Rebrand Asyncdispatch2 to Chronos [WIP] (#20)
* Update file headers, copyright date

* Rename files and hopefully fix nimble

* Forgot to change path in tests

* Update readme
2019-02-06 15:49:11 +01:00