Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The checks for -ipv6, -async broke 'socket -commands'
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
And also fix a minor bug that if unable to format the socket address
the file descriptor would be left open.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
socket ?-noclose? ...
open filename ?-noclose? ...
Normally Jim will set O_CLOEXEC on all files and sockets that are opened
however sometimes it is desirable to keep file descriptors open for
child processes. The -noclose flags does this (on supported platforms).
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This changes especially makes buffered I/O work
with non-blocking channels.
- separate read and write buffering
- support for timeout on blocking read
- read/write on same channel in event loop with buffering
- read buffer is the same across read, gets, copyto
- autoflush non-blocking writes via event loop
- copyto can now copy to any filehandle-like command
- add some copyto tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
AIO_KEEPOPEN won't close a channel (such as stdin, stdout)
when the command is deleted/replaced, but an explicit close
will still close the channel.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This changes especially makes buffered I/O work
with non-blocking channels.
- separate read and write buffering
- support for timeout on blocking read
- read/write on same channel in event loop with buffering
- read buffer is the same across read, gets, copyto
- autoflush non-blocking writes via event loop
- copyto can now copy to any filehandle-like command
- add some copyto tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Not in source files
See https://ariadne.space/2021/12/21/stop-defining-feature-test-macros-in-your-code/
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Go through the Jim versions where it makes sense so we can add debugging
or other features as required.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Rather than continuing to use a small buffer for large copies,
if the size exceeds a certain threshold (currently 16kB) switch
to a larger, allocated buffer (currently 64kB).
This should speed up large copies without penalising small copies.
Note that these are simply heuristics and may not be appropriate
on all systems.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
For socket types that take an address, it would be useful to return
that with 'filename'. If not, we can continue to return the
socket type.
|
|
$handle filename will now return the replica filename
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Very similar to Tcl except that read/write can't be done until
writable indicates the socket is connected.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Documentation fixes -
Co-authored-by: Adrian Ho <the.gromgit@gmail.com>
|
|
Although the interface is different ('$handle stat' vs 'chan configure -stat')
the behaviour is the same.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Once we determine the number of pending bytes to read,
there is no need to read one at a time.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Detection of eof takes precedence over detection of error.
Fixes #207
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Previously calling gets on a non-blocking stream could easily
result in a partial line. Now if a partial line is read, return zero/empty
to indicate that nothing is available while storing the partial line.
The next call to gets (typically within a readable script) will continue
appending to the previous partial line until a complete line can be returned.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The name of the subcommand was inadvertently "lock ?-wait?" rather than "lock"
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Some old systems are not happy with a numeric service and no socktype.
Fixes #196
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
In preparation for support of posix mode flags to open
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Add Jim_CreateScriptFileHandler() to create a standard script filehandler
event that evaluates the given script with Jim_EvalObjBackground()
when the event occurs.
Also add Jim_FindFileHandler() to find a registered event handler.
Simplify aio by using these.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
A return code of SSL_ERROR_ZERO_RETURN means the connection was closed.
It isn't an error.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The hash table used to store commands now uses Jim_Obj keys rather
than allocated char *, so embedded nulls are supported.
This means that some API function such as Jim_RenameCommand()
now take Jim_Obj * rather than const char *, however Jim_CreateCommand()
is retained with const char * for convenience and the new Jim_CreateCommandObj()
is added.
This is generally a performance win as the existing Jim_Obj can be used
as the key.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Allows a psuedo-tty pair to be created.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
For some SSL connections it is necessary to set the Server Name
Indication in the connection in order to receive the correct
certificate. Allow this as part of the client ssl call with:
$sock ssl -sni $servername
Also for -server mode, allow the certificate and private key to be
stored in a single file and only be specified once.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
We can't use feof() and 'buffering none' on ssl connections.
Instead we have to get eof from the ssl layer, and provide
special handling for buffering in the eventloop.
For eof, add ssl_eof() and detect SSL_read() results that indicate
eof to set AIO_EOF in flags.
For buffering, add 'read -pending' that will read, and then immediately
read any buffered data so that the 'readable' event will trigger next
time.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Mostly just avoiding running certain tests, but also:
- rename() won't overwrite an existing file on Windows
- ensure that eof returns 0 or 1
- in aio.test, create and read the file in binary mode
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
To show both the host and port
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
set-only
e.g. to disable echo on stdin: stdin tty echo 0
This allows disabling echo while otherwise keeping cooked mode.
Setting input to cooked or raw will overwrite this setting
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Move some remaining data to the read-only segment
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Commit fe8bab1cc313d0049bbb839589c68059807518c8 accidentally
moved the SO_REUSEADDR after bind() where it does no good.
Move it back to before bind()
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Copying 1 byte at a time can be very slow for large transfers.
Use a 256 byte buffer instead.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Sometimes it is useful to wait for a lock to become available.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Also add support for sockname and peername
And remove unix domain sockets when the socket is closed
And generally clean up the socket support
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
To avoid a deprecation warning
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Bootstrap jimsh sets JIM_ANSIC but FD_CLOEXEC is enabled.
This causes FD_CLOEXEC to be set on fd 0 (stdin), thus closing the default fd 0
in the child process during exec.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Conditions such as ECONNRESET may result in a failed ssl connection
with no ssl error, so return the stdio error in this case rather than
just "unknown SSL error"
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Some operations that failed (such as read) would leave an empty
error result.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Just "promote" the current channel to ssl
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
- fix popen [open "|pipeline ..."] to return meaningful status in close
(but note that stderr is not captured)
- popen pipelines can now be used as the target of exec redirection
- overally improvements to exec on windows. Now crt file descriptors
are used throughout
- add support for [pid], [wait] and popen on windows
- os.wait is now wait, and integrates with [exec ... &] to be able
to wait for running background tasks
- [socket pipe] is now also [pipe] and is supported on windows
- [file tempfile] is supported on windows
- move duplicated code between jim-aio.c and jim-exec.c to jimiocompat.c
- Fix [exec] on windows to match unix semantics wrt sharing the parent stream
unless redirected rather than using /dev/null
- On windows redirect to or from /dev/null is automatically converted to NUL:
- If signal support is disabled, implement a minimal Jim_SignalId() for exec and wait
- aio now supports getfd, to return the underlying file descriptor.
This is used by exec to support redirection, and allows popen channels
to support exec redirection.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Add aio sockopt to get and set various socket options
via setsockopt()/getsockopt()
And remove 'aio tcp_nodelay' in favour of 'aio sockopt tcp_nodelay'
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Sockets need extra work on Windows, so not supported there yet.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Enable or disable Nagle's algorigthm
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The test for ECONNABORTED was reversed such that errors such as ENXIO
did not correctly return an error.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|