1
0
mirror of https://github.com/janet-lang/janet synced 2024-07-04 11:03:15 +00:00
Commit Graph

122 Commits

Author SHA1 Message Date
Calvin Rose
317ab6df6b Add ev/thread and ev/do-thread.
- Also fix setting supervisor with net/accept-loop.
2021-01-22 12:52:45 -06:00
Sunil Nimmagadda
381128364e Replace malloc + memset with calloc.
Fixes an overflow warning from gcc with '-Wstringop-overflow' on
NetBSD-current.
2021-01-21 19:35:57 +05:30
Calvin Rose
5e1a8c86f9 Add more network and subprocess testing with redirection. 2021-01-11 18:32:56 -06:00
Calvin Rose
bf01bf631d More work on windows networking code.
Remove use of WSARecv and WSASend since for whatever reason
they seem suspect. We may want to revisit this later.
2021-01-11 18:00:31 -06:00
Calvin Rose
1f6d0d342b Fix #566 - bad docstring and bad arity for net/flush. 2021-01-10 12:02:28 -06:00
Calvin Rose
5536ba20a8 Move socket setup code from ev.c to net.c 2021-01-10 11:58:47 -06:00
Calvin Rose
2abb87eb63 Add space in docstring. 2021-01-07 18:57:13 -06:00
Calvin Rose
adc41e31f4 Address #547 - don't drop references.
Keep a separate stack for tagged references. May cause pegs to
use more memory but makes the backref and backmatch features much more
powerful.

Also disables the second stack if backref and backmatch are not used in the peg.
2021-01-05 20:27:15 -06:00
Calvin Rose
ab37ee6ebb Add :all option to ev/read.
Brings ev/read more in line with file/read.
2020-12-29 20:37:59 -06:00
Calvin Rose
adc3066dc8 Update doc-format and boot.janet docstrings.
Make doc-format respect leading indents, increase the default format
width to better accommodate markdown formatted documentation. We still
need to support single line style doc strings, such as those used
for most c functions which can be a single line of much longer than
80 or 120 characters.

Consecutive whitespace internal to lines is not preserved, though.
2020-11-26 14:58:36 -06:00
Calvin Rose
a7ed3dea4b Remove some flags in os/open. 2020-11-15 10:06:20 -06:00
Calvin Rose
e546731093 ev_lasterr -> janet_ev_lasterr 2020-11-14 15:24:13 -06:00
Calvin Rose
d50c4ef6da Try again for windows build. 2020-11-14 15:01:52 -06:00
Calvin Rose
12f09ad2d7 Add ev/pipe and move stream code into ev.c
Also adds a lot to the C API and changes things up.
2020-11-14 14:29:11 -06:00
Calvin Rose
b3e88a8d80 Move read/write functions into ev.c from net.c
This code can also be used for non-network streams.
2020-11-14 11:48:23 -06:00
Calvin Rose
1a75f68cb2 Fix windows build. 2020-11-12 14:52:02 -06:00
Calvin Rose
caa6576719 Fix formatting. 2020-11-11 15:35:44 -06:00
Calvin Rose
6f1d5d3b73 Add net/listen and net/accept-loop.
These are the elements that make up net/server, which has been moved
into pure Janet instead.
2020-11-09 11:18:09 -06:00
Calvin Rose
099a912992 Fix posix regression. 2020-11-08 19:48:44 -06:00
Calvin Rose
56b1ea3726 Include math.h to fix some bugs on 32 bit windows. 2020-11-08 19:06:35 -06:00
Calvin Rose
d6391f2d70 Get windows IOCP working for accept.
This also changes the api of servers slightly -
in light of having support for ev tasks, it is probably better
to remove the "simple" server code and replace it with some Janet
or remove it all together. While convenient, it has issues with error
handling and rigidity.
2020-11-08 18:56:13 -06:00
Calvin Rose
07910272e2 Get socket reads and writes working with IOCP. 2020-11-08 10:38:28 -06:00
Calvin Rose
5064d579d4 Add net header instead of ifdef check. 2020-11-03 17:49:09 -06:00
Calvin Rose
4d21b582c7 Improve reading and writing from streams.
Handle errors earlier, and allow 0 length packets from UDP
but not from TCP. This should more closely follow the exact specs
of send and recv calls.
2020-11-02 09:06:31 -06:00
Calvin Rose
f517cccf7b Fix unix domain sockets.
Also allow abstract unix domain sockets on Linux
(prefixed with '@' as is customary).
2020-11-02 08:16:28 -06:00
Calvin Rose
88c1cf3ee7 Reformat files. 2020-10-11 09:33:07 -05:00
Calvin Rose
964a800d51 More work on windows event loop code. 2020-10-06 19:07:29 -05:00
Calvin Rose
db67538311 Work on getting ev support on windows. 2020-10-04 12:46:15 -05:00
Calvin Rose
86e00e865e Merge branch 'master' into ev 2020-08-23 11:25:04 -05:00
Calvin Rose
30522bbf7d Merge branch 'master' into ev 2020-08-16 17:52:36 -05:00
Calvin Rose
06c268c274 Start working on throwing errors from async functions. 2020-08-11 08:33:24 -05:00
Calvin Rose
9b36e2b145 Be aggressive with setting SO_NOSIGPIPE on BSD/Apple. 2020-08-10 18:59:53 -05:00
Calvin Rose
ca75f8dc20 Address #463 - prevent sigpipe on client connections.
We erroneously did not set SO_NOSIGPIPE on connections aquired with
net/connect, only those quired thorugh net/server. This meant that
failed writes by a client could send sigpipe.
2020-08-10 18:45:44 -05:00
Calvin Rose
6f2f3fdb68 Return an error message if writes fail. Address #462. 2020-08-10 11:06:31 -05:00
Calvin Rose
ba08e487cb Disable PRF by default.
Since it is not any better by default without initializing the key, we
disable it by default. It can be turned on with JANET_PRF in
janetconf.h.
2020-07-25 13:34:40 -05:00
Calvin Rose
553b4d9428 Add timeouts to net functions.
Further debugging of the general timeout system, as well
as having a single fiber wait on multiple state machines (select).
2020-07-19 19:41:12 -05:00
Calvin Rose
cd197e8be3 Add ev/call.
This is a common operation, and making fibers manually can be tedious.
2020-07-06 19:13:32 -05:00
Calvin Rose
a0abf307b4 Merge branch 'master' into ev 2020-07-03 12:14:48 -05:00
Jason Pepas
5565f02dbd Simplifying workaround for missing O_CLOEXEC 2020-06-29 19:36:18 -05:00
Jason Pepas
f9f90ba1d6 Support for systems missing O_CLOEXEC 2020-06-26 14:44:57 -05:00
Calvin Rose
b1a4f05b5a Explicitly disallow handler for datagram server. 2020-06-13 08:29:48 -05:00
Calvin Rose
123710078d Add unix domain socket support to net.
Code is a bit messy, as getaddrinfo does not support
unix domain sockets directly. We require a keyword :unix
instead of the usual hostname string, and the port is the
path to unix domain socket. The UDS should support both stream
and datagram sockets.
2020-06-03 00:53:17 -05:00
Calvin Rose
ec0d0ba368 Initial UDP implementation. 2020-06-02 19:47:50 -05:00
Calvin Rose
3f434f2a44 Add backpressure capability to net. 2020-05-31 15:46:01 -05:00
Calvin Rose
a78af0a7fb Do not explicitly free state machines, instead return a status.
This makes it harder to have some kind of use after free issue.
2020-05-30 11:31:05 -05:00
Calvin Rose
117ae196fd Add net/flush.
Useful for simple TCP protocols (netrepl), which benefit from being able
to immediately send a message.
2020-05-28 19:22:38 -05:00
Calvin Rose
4c211c8dce More updates to the ev library. 2020-05-28 16:51:11 -05:00
Calvin Rose
fff66649aa Fix issue #416.
Be really sure we don't pass too large of a size to memcpy.
There seem to be some situations where the slotcount and the ua.count
do not match at all, so use the mimimum for copying.
2020-05-28 10:47:22 -05:00
Calvin Rose
b68b0a256e Start with ev module. 2020-05-28 10:39:40 -05:00
Calvin Rose
1bb9a9368b Make sure winsock2.h is included before windows.h
This should be true in the normal build, and especially in the
amalgamated build.
2020-05-16 12:41:26 -05:00
Calvin Rose
e8b3587946 Silence clang warnings about missing initializers. 2020-05-10 16:00:55 -05:00
Calvin Rose
95660002e1 fix include sys/fcntl.h to fcntl.h 2020-05-07 14:54:03 -05:00
Calvin Rose
084fc9776d Use SOCK_CLOEXEC correctly. 2020-05-07 07:55:08 -05:00
Calvin Rose
79c3139748 Check for SOCK_CLOEXEC.
Not available on all platforms.
2020-05-06 23:44:01 -05:00
Calvin Rose
dc3e9fb77c Add CLOEXECs when getting file descriptors (#374)
This should help address leaking file descriptors in multithreaded
programs. There are a few cases where a race can occur though, as
some apis (fopen and mktemp).
2020-05-06 18:33:25 -05:00
Calvin Rose
761ea65d81 Add fiber/roor and allow net/server to take
a numeric port.
2020-04-30 23:21:26 -05:00
Calvin Rose
1c0a015cc8 s/WSALastError/WSAGetLastError()/g 2020-04-30 13:26:14 -05:00
Calvin Rose
73989f5cc7 Consolidate windows and posix socket code.
Also remove code that ignored sigpipe and instead try
our best to ignore through various platform specific mechanisms.
2020-04-29 21:07:21 -05:00
Calvin Rose
c98e1f3cae Update documentation for net/read and net/chunk. 2020-04-27 19:26:05 -05:00
Calvin Rose
41894eb285 Add docstrings to net.c 2020-04-26 14:11:47 -05:00
Calvin Rose
d2ebf4b52d Merge branch 'net' 2020-04-26 12:27:37 -05:00
Calvin Rose
0d3c6abee8 POLLER -> POLLERR 2020-04-18 19:15:59 -04:00
Calvin Rose
4a693222b4 Port net code to windows.
Use winsock2 and WSAPoll. Not the most high performance
solution but should work well.
2020-04-18 19:14:38 -04:00
Calvin Rose
2904c19ed9 Switch to poll from select.
Simpler and more flexible interface, and also lets
us use epoll more easily on linux, which is the most important
plantform to optimize for network performance.
2020-04-18 15:22:20 -05:00
Calvin Rose
4ac382e553 Add alias JANET_SIGNAL_EVENT. 2020-04-17 16:27:02 -05:00
Calvin Rose
01a79dc965 Remove extra functionality. 2020-02-20 20:10:03 -06:00
Calvin Rose
0df220780a Fix issues with #282
Bad handling of write errors, as well as janet_root_fiber().
2020-02-20 19:54:31 -06:00
Calvin Rose
f4a46ba6ea Add methods to streams.
This makes streams polymorphic with files in many cases.
printf family functions still need porting.
2020-02-12 09:32:41 -06:00
Calvin Rose
79bb9e54d5 Remove direct references to file descriptors.
If a descriptor is freed by the Janet code, other
uses of that descriptor, say in the event loop, need
to know that it has been closed.
2020-02-11 08:57:44 -06:00
Calvin Rose
f4d7fd97f6 Working TCP echo server and client.
Required a few changes to APIs, namely janet_root_fiber()
to get topmost fiber that is active in the current scheduler.
This is distinct from janet_current_fiber(), which gets the bottom
most fiber in the fiber stack - it might have a parent, and so cannot
be reliably resumed.
This is the kind of situation that makes symmetric coroutines more
attractive.
2020-02-09 20:00:50 -06:00
Calvin Rose
eda61455d3 Work on tcp server code. 2020-02-03 09:29:51 -06:00
Calvin Rose
c0d2140d14 Begin net/ module in core.
Humble beginnings.
2020-02-01 20:39:54 -06:00