Commit Graph

61 Commits

Author SHA1 Message Date
Eugene Kabanov 39f4060e07
Refactor and optimization of BoundedStream. (#180)
Documentation for BoundedStream.
Fix HttpServer bounding.
2021-04-26 14:05:37 +03:00
Eugene Kabanov aab1e30a72
Refactor common.nim and add more resolve procedures. (#177)
* Refactor common.nim to remove `result` usage.
Fix comparison of TransportAddress issue.
Add resolveTAddress procedures for both IPv4 and IPv6 addresses.
Fix tests.

* Bump version to 3.0.2.
2021-04-10 00:39:54 +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
Andreas Rumpf 1324b2f787
Enable --gc:orc testing for nim-chronos (#161)
* enable --gc:orc testing on nim devel (1.5.x)
2021-03-03 20:04:09 +02:00
Eugene Kabanov eb6e32605f
Fix #156 and refactor osnet.nim (#157)
* Refactor osnet.nim to not use `result`.
Fix #156.

* Fix linux compilation error.
2021-02-25 22:04:56 +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
Jacek Sieka e7f5f855ab
use constant for ip kind (#151)
IPV6_MULTICAST_HOPS already declared in posix.nim while IP_MULTICAST_TTL
has a value that will stay constant on linux/x86_64 - better codegen and
nlvm compat like this.
2021-02-02 16:12:12 +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
Jacek Sieka 483054cda6
small fixes (#127)
* small fixes

* more efficient codegen for nil check (much less code)
* release futures earlier in AsyncEvent
* release finished future earlier in AsyncQueue
* avoid searches for futures (deque variant unused / broken)
* avoid catching defects

* Fix AsyncEvent test, because of optimization.

* delete fix

* avoid seq allocs

* Keep style consistent with other code.
Refactor AsyncEvent and AsyncQueue to not use `result` keyword.

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2020-09-10 11:39:10 +03: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 73de13ca7a
Fix SIGSEGV while consuming errors more then once. (#114) 2020-08-05 00:23:43 +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
Jacek Sieka f856c885fa
fix endian conversion issues (#82)
* fixes call to `bigEndian32` on a uint64 which breaks on big endian
platforms
* prefer endians2 for less and safer code
2020-07-12 18:22:47 +02: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
Kim De Mey bce0f878d1
Remove unreachable raise from initTAddress (#97) 2020-05-15 14:09:21 +03:00
Jacek Sieka aff69aaf29
fix closed error type (#99) 2020-05-13 22:45:40 +03:00
andri lim 72b4f14427
fix nim 1.2 compilation issue on linux 2020-03-26 16:46:31 +07: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 8e70d1be7a
Fix macos warnings. 2020-02-12 23:01:41 +02:00
cheatfate 80351cb928
Fix #73. 2020-02-12 22:54:05 +02:00
cheatfate 4a2416fe5e
Allow to setup datagram servers with 0 port. 2020-01-28 15:46:57 +02:00
cheatfate e34857364e
Attempt to fix #64. 2020-01-28 12:47:38 +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 73c130abb4
Remove usage of getCurrentException().
Bump version to 2.3.4.
2019-11-28 20:14:19 +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
Bruno Škvorc bb525ace25
Fix typo in doc string
This typo was breaking nim's doc generator.
2019-08-16 12:27:27 +02:00
cheatfate 03eb8a0157
Add pipe support for StreamTransport.
Bump version to 2.2.8.
2019-07-15 12:59:42 +03:00
cheatfate ec7f2a14a8
Fix compilation warnings in osnet.nim
Fix non stable stream tests.
2019-07-12 10:40:18 +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 38dd4cb6e7
Fix for Nim devel discrimination checks. 2019-06-03 10:24:51 +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