Commit Graph

489 Commits

Author SHA1 Message Date
Jacek Sieka 0fc82049ac enable --styleCheck:usages 2021-12-27 17:33:25 +02:00
Tanguy 7dc58d42b6
Improve ram usage (#243)
Remove cyclic references of {.async.} Futures, allowing them to be picked up by the regular refc instead of Mark and Sweep
2021-12-10 11:19:14 +01:00
Zahary Karadjov 7ca85ddadc
Fix compilation errors with --styleCheck:usages --styleCheck:error 2021-12-08 16:58:24 +02:00
Tanguy cedc603b81
Remove future var (#247) 2021-12-08 12:30:12 +01:00
Jacek Sieka c25fa1f6cd
posix: fast path for write (#244)
When `write` is called on a `StreamTransport`, the current sequence of
operations is:

* copy data to queue
* register for "write" event notification
* return unfinished future to `write` caller
* wait for "write" notification (in `poll`)
* perform one `send`
* wait for notification again if there's more data to write
* complete the future

In this PR, we introduce a fast path for writing:

* If the queue is empty, try to send as much data as possible
  * If all data is sent, return completed future without `poll` round
  * If there's more data to send than can be sent in one go, add the
rest to queue
* If the queue is not empty, enqueue as above
* When notified that write is possible, keep writing until OS buffer is
full before waiting for event again

The fast path provides significant performance benefits when there are
many small writes, such as when sending gossip to many peers, by
avoiding the poll loop and data copy on each send.

Also fixes an issue where the socket would not be removed from the
writer set if there were pending writes on close.
2021-12-08 11:35:27 +01:00
Eugene Kabanov 7da1f5d4d2
Bump version to 3.0.9. (#249) 2021-12-03 15:32:58 +02:00
Eugene Kabanov 36e5f6fc89
Attempt to fix connection state. (#248)
* Attempt to fix connection state.

* Add actual values dump on asserts.

* Total rework of connection's states.
2021-12-03 13:11:39 +02:00
Eugene Kabanov 1c17d4c094
Fix connections management in http client. (#246)
* Proper connection lifetime handling mechanism.
HttpClientResponse do not close connection anymore.

* Add unique HTTP client connection identifier.
2021-12-01 12:23:39 +02:00
Andreas Rumpf 37c62af579
Added an explanation for the additional `gcsafe` pragmas (#241)
* prepare nim-chronos for Nim version 1.2

* enable --gc:orc testing

* ensure asyncmacro2 works with the upcoming 1.6

* added a remark
2021-11-22 14:48:59 +02:00
Ștefan Talpalaru ae95bc3d19
CI: test multiple Nim branches all the time (#240) 2021-11-20 14:29:09 +01:00
Ștefan Talpalaru 25ccbb0beb
version 3.0.8 2021-11-20 01:31:09 +01:00
Ștefan Talpalaru 4aaaa3379a
Nim-1.6 fixes (#239) 2021-11-20 01:30:23 +01:00
Eugene Kabanov f51158da65
Add NewConnectionAlways option to HttpClientFlags, which allows to ignore connection management in client. (#238)
Optimize server behavior when HeadersTimeout is set to Infinity.
2021-11-19 18:13:36 +02:00
Michael Bradley ad0029e3ee
add raises pragma to registerEvent in ioselectors_epoll (#237)
Include `IOSelectorsException` in addition to `Defect` in `raises: []`.
2021-11-19 17:47:58 +02:00
Ștefan Talpalaru b24ee653d3
version 3.0.7 2021-11-19 01:08:55 +01:00
Ștefan Talpalaru 56e007d165
comments for recent gcsafe pragmas 2021-11-19 01:07:46 +01:00
Andreas Rumpf cc22234dc6
Prepare chronos for Nim version 1.6 (#226) 2021-11-19 01:05:47 +01:00
Ștefan Talpalaru 0d46e0ff9b
CI: test multiple Nim branches in a daily cron job (#225) 2021-11-16 12:10:19 +01:00
Miran 3697426f85
properly move testing libbacktrace to a separate task (#236)
This is a continuation of #231.
2021-11-15 11:40:49 +01:00
Eugene Kabanov 0c7a0bd0a5
Handle accept() errors properly. (#234)
* Add more accept() call error handlers.
Fix issue when HTTP server silently stops accepting new connections.
Remove unneeded MacOS syscall to disable SIG_PIPE on socket, we already mask this signal in process.

* User `if` instead `case` because constants are actually variables.

* Fix mistypes.

* Do not use case for posix constants.

* Fix Linux compilation error.
2021-11-12 18:13:56 +02:00
Ștefan Talpalaru df980dd713
CI: separate libbacktrace test in its own task (#231) 2021-11-08 19:09:06 +02:00
Jacek Sieka 8ce9f54bb7
Document `-d:asyncBackend` (fixes #207) (#216) 2021-11-08 15:17:37 +01:00
cheatfate 661eae5732
Fix identifiers to be `uint` instead of `uint64`. 2021-10-21 17:46:06 +03:00
Eugene Kabanov 3bc0bc36f7
Change Future identifier type from `int` to `uint`. (#228)
* Change Future identifier type from `int` to `uint64`.

* Fix compilation error and tests.

* Add integer overflow test, to avoid confusion with next Nim versions, we expect that unsigned integers do not raise any exceptions if overflow happens.

* Switch from `uint64` to `uint` type.

* Add `uint` overflow tests.
2021-10-21 17:22:11 +03:00
cheatfate 2e57ddb455
Fix preferredContentType() function declaration to avoid confusion with `preferredContentType(varargs)`. 2021-10-21 14:01:46 +03:00
Eugene Kabanov 59b91bf0ca
Add more helpers to handle Accept header. (#224)
* Add API working with strings instead of `HttpRequestRef` object.

* Fix comment.
2021-09-28 01:41:29 +03:00
Eugene Kabanov d57aae27a0
Fix mingw64 distribution urls. (#223) 2021-09-27 18:40:42 +03:00
Eugene Kabanov 80102a3b6a
Eventbus implementation (#214)
* Initial commit.

* Move AsyncEventBus implementation to asyncsync.nim
Add subscriptAll(), waitAllEvents() primitives.
Add emitWait() primitive.
Add emitter source location implementation.
Add tests.
2021-09-15 16:55:15 +03:00
Eugene Kabanov bbbcb55493
Server-side events implementation. (#222)
Fix keep-alive issue.
Refactor some prepareXXX routines.
2021-09-14 20:32:58 +03:00
Eugene Kabanov 5034f0a5a6
Fix issue #219 (#220)
* Address issue #219 and add tests for it.
Some cosmetic refactoring.

* Fix *nix tests.
2021-09-05 00:53:27 +03:00
Eugene Kabanov 05c91418be
Export async-related imports to allow partial imports. (#218) 2021-08-26 14:22:29 +03:00
Eugene Kabanov 9d80c7068f
Server must not send `Host` header. (#215) 2021-08-15 04:29:48 +03:00
Eugene Kabanov b14f66c295
No more Defect on stream close. (#213)
Fix async streams issue with replacing state.
Add `closing` states to HTTP's server connection, request and bodyrw.
Fix Http server cancellation leaks.
2021-08-06 13:13:55 +03:00
Eugene Kabanov ef2430d08d
Add `Accept` header handling to httpserver.nim. (#211)
* Add `Accept` header handling to httpserver.nim.
Add simple test suite.
Bump version to 3.0.6.

* Fix compilation error.
2021-07-28 17:08:38 +03:00
Johann Bauer 3a9cc6bfc9
Update `toIPv4` and `toIPv6` to keep the port (#209)
Currently, converting a `TransportAddress` from IPv4 to IPv6 or vice-versa will set the port to 0.
2021-07-27 14:39:48 +03:00
Eugene Kabanov 14ebf269e9
Fix accept defect (#206)
* Fix accept() FutureDefect on cancellation.

* Do not close pipe twice.

* Check for retFuture state before changing it state.
2021-06-30 18:22:37 +03:00
Eugene Kabanov 15137f71c3
Basic authorization implementation for HTTP client. (#204)
* Basic authorization implementation for HTTP client.
Add tests for basic authorization.

* Bump chronos version to 3.0.5.
2021-06-29 02:38:08 +03:00
Eugene Kabanov f7dd6b76c2
Safely close connection's streams. (#199) 2021-06-14 15:16:33 +03:00
Eugene Kabanov e6fd38fd49
Add one more state `Closing` to help avoid race condition while in `closeWait` of request, response, connection. (#198) 2021-06-10 13:58:41 +03:00
Jacek Sieka 252e5d0d50
simplify future tests (#196) 2021-06-04 12:28:04 +02:00
Pietro Peterlongo a46cc59627
fix web framework name Looper -> Scorper (#189)
apparently it has changed name
2021-05-27 10:53:11 +02:00
Eugene Kabanov 7ccb170f7a
Enable comma as array delimiter and adding tests. (#191)
* Enable comma as array delimiter and adding tests.

* Bump version to 3.0.4.
2021-05-17 22:39:24 +03:00
cheatfate 67f0f1224f
Bump nimble version.
Make some useful fields public.
2021-05-10 10:40:56 +03:00
Eugene Kabanov be184a815c
Httpclient (#182)
* Initial commit.

* Some refactoring.

* Allow boundstream to accept uint64.
Fix httpserver and asyncstream tests to follow new uint64 requirement.

* send() and getBodyBytes() implementations.

* Add closeWait for response and request.
Refactor finish/close flow.

* Changes in state machine
Add first test.

* Missing test file.

* Fixed tests
Add http leaking trackers and tests.

* Some fixes in multipart.
Fix automatic Content-Length header for requests with body.
Fix getBodyBytes() assertions.
Merging tests to main suite.

* Post rebase fixes.

* Fix tests big message generation.

* Fix response state management and leaks for getBodyXXX() procedures.

* Add redirection support to client and server.
Add fetch(url) procedure with redirection support.
Add tests for redirection.
2021-05-10 10:26:36 +03:00
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 fed6b0ac92
Restore functionality of zero-sized bounded reader/writer streams. (#184)
* Restore functionality of zero-sized bounded reader/writer streams.
Adding tests for it.

* run build_nim.sh unconditionally

Co-authored-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com>
2021-05-07 18:52:44 +03:00
Ștefan Talpalaru c15c985c1f
support nimStackTraceOverride (#181) 2021-05-06 09:49:55 +02:00
Jacek Sieka 43b8aada20
Add message to task failure message (#183) 2021-05-06 09:46:58 +02:00
cheatfate 645d62db78
Remove fastpath execution and finally fix issue. 2021-04-27 00:07:49 +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