Commit Graph

540 Commits

Author SHA1 Message Date
Csaba Kiraly ca3ce6e8cc
Merge branch 'chronosFutureDuration' into das-dht2 2023-08-14 15:02:47 +02:00
Csaba Kiraly 8580b50ae1
simplify virtual timer and improve compatibility
Previous version of virtual timer used minimal modifications.
This one instead implements poll() directly, simplifying execution.
It also enforces one timer each poll, which makes it compatible with
one network even per poll cycle when network events are replaced by
timers for simulation.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 11:15:02 +02:00
Csaba Kiraly 7d4c8a4287
fixup: make field private, add public accessor
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-07 13:35:10 +02:00
Csaba Kiraly 3fbc74525d
Measure time in which a future gets finished
Adding this behind the `chronosFutureDuration` compile flag to
avoid changing memory footprint.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-07 13:35:09 +02:00
Csaba Kiraly 5b9ec0837c
introduce the virtual clock for simulations
This allows running code written for Chronos using
`-d:asyncTimer=virtual`
, turning it into a simple event-based simulation.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-06-12 09:56:35 +02:00
Eugene Kabanov 6525f4ce1d
Fix some warnings. (#310)
* Fix some warnings messages.

* More warning fixes.

* Address review comments.
Fix MacOS issues.

* More warning fixes.

* More Windows specific fixes.

* Fix macos and windows warnings.

* Fix warnings in timer.nim
Refactor to remove `result`.
Improve performance and behavior of timer to string procedure.
Add tests.
2022-11-02 08:09:15 +01:00
Tanguy 24146463a3
Token bucket (#279)
- A single sleepAsync per bucket
- Manual replenish with async
- Cancellation of consume

Co-authored-by: Jacek Sieka <jacek@status.im>
2022-11-02 08:03:19 +01:00
Eugene Kabanov 266e2c0ed2
HTTP client: Allow request connection management. (#323)
* Allow per-request connection management.
Fix NewConnectionAlways leak issue.

* Address review comment.
2022-10-13 10:18:13 +00:00
Eugene Kabanov 9df76c39df
Fix default content-type should not be sent if there is no body. (#315)
Make contentLength field publicly available.
2022-09-20 12:59:34 +00:00
Eugene Kabanov be2352027e
Fix nested waitFor (IndexError defect crash) bug. (#309)
Add IndexError crash test for Linux/MacOS.
Add Sentinel version of fix.
Add GetQueuedCompletionStatusEx() support for Windows, which allows to capture more then one event in single `poll()` call.
2022-09-16 22:34:18 +02:00
Eugene Kabanov 8e8263370b
Add more FutureBase helpers. (#304) 2022-09-12 12:11:13 +00:00
Jacek Sieka 396ed554f6
Update README.md 2022-09-06 18:50:12 +02:00
Jacek Sieka 746832384a
`Option` -> `Opt` (#307) 2022-09-05 11:08:52 +00:00
Miran 3e4b47e60a
switch CI to the supported versions of ubuntu and macos (#306)
* switch CI to the supported versions of ubuntu and macos

See:
- https://github.com/actions/runner-images/issues/6002
- https://github.com/actions/runner-images/issues/5583

* don't continue on error for Nim 1.6

* install openssl on macos for Nim devel

due to changes in https://github.com/nim-lang/Nim/pull/19814
2022-09-02 17:27:24 +02:00
Eugene Kabanov 1334cdfebd
getPreferredContentType() deprecate float math (#303)
* Deprecate float math.

* Remove unneeded helper procedures.

* Remove limitation of 99 types and comments.
2022-08-10 14:07:51 +03:00
Miran 93800879fd
make it more Nim 1.4+ compatible (#296) 2022-08-06 13:56:06 +03:00
Eugene Kabanov 15d7e0ebb7
Add optimized implementation for preferredContentType() which avoid sorting and double iteration. (#299)
Fix tests to use 80cpl.
2022-08-06 13:53:40 +03:00
Eugene Kabanov 939195626f
Use new Content-Type header value parser. (#302) 2022-08-05 19:59:26 +03:00
Eugene Kabanov 79c51914ae
Fix jigsaw test. (#301) 2022-07-30 23:16:30 +03:00
Eugene Kabanov e9d0e2d208
Apply fix for recent Nim devel changes. (#300) 2022-07-30 12:48:58 +03:00
Tanguy 41b82cdea3
Add test for nested finally transform issue (#295) 2022-07-18 23:30:27 +02:00
Jacek Sieka 2a19e4ca4c
bearssl: spelling (#294) 2022-07-16 20:46:19 +02:00
Eugene Kabanov f2e4d447d6
Workaround exception tracking issue. (#293)
* Workaround exception tracking issue.

* Fix SecureHttpServerRef too.
2022-07-04 12:31:18 +03:00
Ivan Yonchovski 59f611f0fc
Use unittest2 directly (#291) 2022-06-29 17:22:57 +03:00
Eugene Kabanov 377e197417
waitSignal() helper and tests for it. (#289)
* Add waitForSignal() implementation and tests.

* Fix compilation issues.

* Fix mistype.

* Rename to waitSignal().

* Fix Windows compilation issue.

* Re-export posix signals.

* Remove signal handler on continuation too.
2022-06-29 00:53:09 +03:00
Zahary Karadjov 84e32a3b69
Add high and low operators for Duration and Moment; Add Moment.epochSeconds and Moment.epochNanoSeconds 2022-06-28 16:47:59 +03:00
Jacek Sieka c6ce4d4fb2
bearssl: use split ABI (#282) 2022-06-17 12:39:14 +02:00
Eugene Kabanov 2a5095505f
Add headers argument to redirect() calls. (#287)
* Add headers argument to redirect() calls.

* Fix mistype.
2022-06-17 12:17:49 +03:00
Eugene Kabanov 61fbbc5512
asyncTest (#286)
* Initial commit.

* Change name to asynctests.
2022-06-16 14:35:24 +03:00
Eugene Kabanov f403b06de6
AsyncEventQueue (AsyncEventBus replacement). (#275)
* AsyncEventQueue (AsyncEventBus replacement) initial commit.

* Add closeWait() and remove assertion test.

* Fix "possible" memory leak.

* Add limits to AsyncEventQueue[T].
Add tests for AsyncEventQueue[T] limits.
Rebase AsyncSync errors to be children of AsyncError.

* Adopt AsyncEventQueue to garbage collect events on emit() too.
Add test from review comment.

* Remove AsyncEventBus test suite.

* Remove unneeded [T] usage.

* Optimize memory usage in 1m test.

* Lower number of events in test from 1m to 100k.

* Deprecate AsyncEventBus.
Add some GC debugging for tests.

* Fix mistype.

* One more attempt to fix crash.

* Add some echo debugging.

* More echo debugging.

* More closer debug echoes.

* Attempt to workaround crash place.

* More debugging echoes in exception handlers.

* Convert suspected test into async procedure.

* Make multiple consumers test async.

* Remove GC debugging.

* Disable added tests.

* Disable AsyncEventQueue tests to confirm that this is an issue.

* Enable all the tests.
2022-06-16 00:51:21 +03:00
Eugene Kabanov 623681e212
Add nimRawSetjmp define to config.nims (#285)
* Add nimRawSetjmp define to config.nims

* Add config to tests too.
2022-06-14 01:02:33 +03:00
Eugene Kabanov b3548583fc
Fix last connection state check. (#278) 2022-05-27 23:03:32 +03:00
Eugene Kabanov 728ab7faa7
Fix one more place of assertion for high concurrency requests. (#277) 2022-05-27 20:28:39 +03:00
Tanguy c5894bae1b
AsyncEventBus: fix multiple listeners (#271)
Co-authored-by: dbrignoli <dbrignoli@audioscience.com>
2022-05-20 11:57:37 +02:00
Derek 呆 1233f8fb4b
fix tiny typo in comment (#274) 2022-05-19 17:37:51 +02:00
zah 875d7d8e6e
Tentative fix for the HTTP client connection state assertion failures (#272)
* Tentative fix for the HTTP client connection state assertion failures

I've traced the problem to a HTTP connection being closed while there
are outstanding requests that still go through the motions (the crash
occurs when a requests reaches its `finish` processing step, but it
was already put in a Closed state by the connection that owns it).

* Use distinct error exception instead of cancellation error.

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2022-05-14 11:08:13 +03:00
Etan Kissling dedd7cb1d0
Guarantee exclusive use of `HttpClientConnection`. (#273)
When calling the HTTP `send` / `open` functions, `acquireConnection` is
called to obtain a connection in state `Ready`. In the next code block,
the connection state is advanced to `RequestHeadersSending`. However,
returning from chronos `async` procs yields control, similar to `await`.
This means that a connection may be added to the pool in `Ready` state,
and then a different `acquireConnection` call may obtain a second ref.
Introducing a new `Acquired` state ensures consistency in this case.

No tests added due to this being scheduler dependent; ran manual tests
by adding a `doAssert item.state != HttpClientConnectionState.Acquired`
between `if not(isNil(conn)):` and `return conn`. Eventually, the assert
got hit after several hours of repeated tests, confirming the edge case
to be solved by applying this fix.

Not sure if it is by design that returning from an `async` proc yields.
Even if it's not, this should solve current HTTP issues in nimbus-eth2.
2022-05-13 02:54:34 +03:00
Tanguy ae19d5b6f0
Handle multiple childs for opensymchoice (#266)
And more tests. Follow up of #261
2022-05-05 11:05:04 +02:00
zah 5a906ad56c
nimble setup (#269) 2022-04-17 11:41:14 +02:00
Jacek Sieka bb4c3298f5
fix crash after reading from fd > 1024 (#267)
The socket selector holds a `seq` of per-descriptor data. When a reader
is registered, a pointer to a seq item is stored - when the `seq` grows,
this pointer becomes dangling and causes crashes like
https://github.com/status-im/nimbus-eth2/issues/3521.

It turns out that there already exist two mechanisms for passing user
data around - this PR simply removes one of them, saving on memory usage
and removing the need to store pointers to the `seq` data that become
dangling on resize.
2022-04-11 11:56:30 +02:00
cheatfate ae2a87778f
Fix missing connection flag. 2022-04-10 19:35:04 +03:00
Tanguy 64386b3112
Fix nimdoc for async procs (#260) 2022-04-05 12:16:00 +02:00
Tanguy 3621143c89
reenable auth test with other server 2022-03-30 17:09:43 +02:00
Tanguy 0bd9238409
Skip failing test to restore CI 2022-03-30 16:56:04 +02:00
Tanguy fc65ff8c5b
Cleanup return type open syms (#261) 2022-03-30 16:13:58 +03:00
Tanguy 8719723077
Fix TLS certificate allocation (#259)
* Fix TLS certificate allocation

* change style + comment
2022-01-28 13:46:15 +02:00
Thomas Jost b47b2a96ce
Fix documentation build (#258)
`nim doc --project --index:on chronos.nim` was failing with the following error:

    /path/to/nim-chronos/chronos/transports/common.nim(519, 21) Error: '*' expected

...which in turned caused errors in all files that import this one.

Now the entire docs can be built successfully, with only a few warnings.

Fixes #186.
2022-01-26 20:56:22 +01:00
Emil 1f37dac810 Refactor `preferredContentType` proc & add tests
Fix of the following bug:
In case of multiple accept headers with same preference
`preferredContentType` used to select the first match within content types
provided by the application. For example, if user specifies accept headers
`application/octet-stream, application/json` and application provides
`application/json, application/octet-stream`, `application/octet-stream`
will be returned, and that is a bug.

Now the procedure returns the most suitable match according
to the application preferences.
2022-01-25 16:05:36 +02:00
Eugene Kabanov 519ca463df
Fix transport.write() unable to send data through OS pipes. (#256)
* Fix transport.write() unable to send data through pipe.
Add test for pipes.

* Fix flaky test.

* Add workaround for Nim's issue #19425.
2022-01-20 18:38:41 +02:00
Ștefan Talpalaru 17fed89c99
style fixes (#253)
* style fixes

and disable the cron CI job
2022-01-04 23:14:30 +01:00