| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* glob.c (glob_wrap): Perform argument conversions
that might throw before allocating UTF-8 string.
* parser.y (text): In the action for SPACE, the lexeme
is not needed so free($1) right away. If regex_compile
were to throw an exception, that lexeme will leak.
* socket.c (getaddrinfo_wrap): Harden against leakage of
node_u8 and service_u8 strings with an unwind block.
For instance, the hints structure could contain
bad values which cause addrinfo_in to throw.
* stream.c (make_string_byte_input_stream): Perform
possibly throwing argument conversions before allocating
resources.
* sysif.c (mkdir_wrap, mknod_wrap, chmod_wrap, symlink_wrap,
link_wrap, setenv_wrap, crypt_wrap): Likewise.
* syslog.c (openlog_wrap, syslog_wrapv): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (ead_until_match): Use rcyc_pop instead of pop
to move the conses to the recycle list. We know these
are not shared with anything. Adding additional logic
to completely recycle the stack.
* socket.c (dgram_get_char): Use rcyc_pop to
get the character from the push-back list.
* stream.c (stdio_get_char): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixing read_until_match will require this feature.
* socket.c (dgram_get_char): Treat unget_c as a
cons-based stack; pop a character from it if
available.
(dgram_unget_char): Push the character onto unget_c
rather than storing the characer into unget_c.
* stream.c (stdio_get_char, stdio_unget_char): Closely
analogous changes to the ones in dgram_get_char
and dgram_unget_char, respectively.
* txr.1: Documentation improved and updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (sock_set_entries): Add auto-load entry
for open-socket.
* socket.c (open_socket): Change to static.
(sock_load_init): Register open-socket intrinsic
here rather than in stream.c.
* stream.c (stream_init): Remove registration of
open-socket intrinsic.
* stream.h (open_socket): Declaration removed.
|
|
|
|
|
|
|
|
|
| |
The open_sockfd function is only called within socket.c
* socket.c (open_sockfd): More function up and
change to static.
* stream.h (open_sockfd): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (sock_set_entries): Add open-socket-pair to
autoload list.
* socket.c (sock_mark_connected, socketpair_wrap): New static
functions.
(sock_load_init): Register open-socket-pair intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
| |
* socket.c (sockaddr_unpack): New static function.
(sock_accept): Use sockaddr_unpack instead of two
copies of if/else code.
|
|
|
|
|
|
|
| |
* socket.c (sock_accept): Reduce scope of unwind catch around
recvfrom call. Add missing check nbytes == -1. Branch to
failed label in dup failed case, instead of throwing
exception with truncated "unable to" message.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Making it work as already documented.
* socket.c (MIN): New macro.
(sockaddr_pack): Use utf8_dup_to_buf to convert
Unix socket path to a buffer of UTF-8 bytes, possibly with one
or more embedded null bytes. Copy as much of this as fits into
the sun_path member of struct sockaddr_un.
* txr.1: Improve documentation about the abstract names
on Linux.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Merely setting a peer doesn't actually connect the socket,
so it must not be marked connected. If it is wrongly
marked connected, then dgram_flush will wrongly use
send rather than sendto.
* socket.c (dgram_set_sock_peer): Don't set sock_connected
flag.
(sock_connect): Set the sock_connected flag here, for dgram
sockets.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Also rename its related functions for consistency.
* socket.c (sockaddr_in_out): Renamed to sockaddr_in_unpack.
The "in" stands for internet, and is juxtaposed to "out".
(sockaddr_in6_out): Renamed to sockaddr_in6_unpack.
(unix_sockaddr_out): Renamed to sockaddr_un_unpack.
(getaddrinfo_wrap): Calls to *_out functions renamed
to *_unpack.
(sockaddr_in): Renamed to sockaddr_pack. Original name is
confusing against the struct tag name in struct sockaddr_in.
(dgram_set_sock_peer, sock_bind, sock_connect, sock_accept):
Calls updated to sockaddr_pack.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is more to this patch than just more permissive
mode strings. Now if a socket can be opened with mode
"l2" for instance, and these options are effectively applied
to the socket-specific "r+b" default, not to "r".
* stream.c (parse_mode): New argument specifying a default
mode. The syntax is relaxed, allowing previously required
elements to be omitted.
(normalize_mode): New argument specifying a default mode.
Format mode is always called now, because an input string
is no longer necessarily a valid fopen string even in cases
when it doesn't specify any extensions.
(open_file, open_fileno, open_tail, open_command,
open_process): Use new normalize_mode argument for defaulting;
normalize_mode no longer defaults to "r".
* stream.h (stdio_mode_init_trivial): Macro removed.
(stdio_mode_init_blank, stdio_mode_init_r,
stdio_mode_init_rpb): New initializer macros.
(parse_mode, normalize_mode): Declarations updated.
* socket.c (sock_accept): In datagram socket case, use new
parse_mode argument for defaulting using stdio_mode_init_rpb,
rather than overriding a missing string with "r+b".
(open_sockfd): Likewise, and use new normalize_mode
argument similarly for defaulting the mode on a stream socket.
* txr.1: Documented mode string permissiveness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): new rx_max member.
(make_dgram_sock_stream): New arguments: a struct stdio_mode,
and pointer to prototype dgram socket. If a size is specified
in the mode, then use that as rx_max. Otherwise if a prototype
socket is specified, use its rx_max as the new socket's rx_max.
Otherwise default on 65536.
(dgram_get_byte_callback): Use d->rx_max as the capture size,
rather than a hard-coded 65536.
(sock_accept): Use d->rx_max as capture size for datagram.
Parse the mode. Pass the parsed mode to make_dgram_sock_stream,
as well as the accepting socket, so it can set up the rx_max
for the new socket.
(open_sockfd): Parse the mode and pass to make_dgram_sock_stream.
* stream.c (parse_mode): Static function becomes extern.
* stream.h (parse_mode): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* socket.c: Inadvertently introduced tabs recently
while working on Solaris. Grr!
|
|
|
|
|
|
| |
* socket.c (open_sockfd): Default mode string is "r+b".
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (sock_accept): New third parameter specifying
timeout. If a timeout is specified, use the select function to
select socket for reading, datagram or stream.
(sock_load_init): Update registration of sock-accept
intrinsic to three arguments, one optional.
* txr.1: Documented sock-accept's timeout parameter.
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (to_connect): New static function.
(sock_connect): Use to_connect instead of calling
connect directly.
(lock_load_init): sock-connect intrinsic registration
updated to three arguments, one optional.
* txr.1: Documented sock-connect timeout.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (timeout_error_s): New symbol variable.
(obj_init): Intern timeout-error, init new variable.
* lib.h (timeout_error_s): Declared.
* socket.c (sock_timeout, sock_send_timeout,
sock_recv_timeout): New static functions.
(sock_load_init): Register sock-send-timeout and
sock-recv-timeout intrinsics.
* stream.c (stdio_maybe_read_error, stdio_maybe_error):
Convert EAGAIN into timeout_error_s.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* socket.c (sock_connect): return a useful value rather than
t, namely the socket.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (open_sockfd): We no longer need to set
stream sockets to line buffered mode here;
it's done in set_mode_props.
* stream.c (set_mode_props): If the mode specifies interactive,
streams open for writing are also switched to line buffering.
* txr.1: Documented under open-file, and open-socket.
|
|
|
|
|
|
|
|
|
|
| |
Undocumented members in struct sockaddr_in, and possibly
sockaddr_in6 also, must be cleared to all zero bits, otherwise
bind fails for the loopback address, even if the relevant
addressing members are correctly set.
* socket.c (sockaddr_in): memset the IPv4 or IPv6 address
to zero before filing it.
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New member, sock_connected.
(make_dgram_sock_stream): Initialize sock_connected to zero.
(dgram_flush): Use send if sock_connected is nonzero, otherwise
sendto.
(dgram_set_sock_peer): Set sock_connected to 1.
|
|
|
|
|
| |
* socket.c (sock_bind, sock_connect, sock_listen,
sock_accept): If the socket is closed, throw an error.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New member, addr.
(make_dgram_sock_stream): Initialize addr to nil.
(dgram_print): Instead of printing the numeric fd, print the
stream description, obtained from the name_k property.
(dgram_mark): Mark the addr member.
(dgram_get_prop): Calculate a descriptive string from the
dgram stream state for the name_k property.
(dgram_set_prop): New static function.
(dgram_strm_ops): Name change to dgram-sock. Wire in
dgram_set_prop function.
(sock_bind): Set the addr_k property of the stream
to the local address that was just bound.
* stream.c (addr_k): New keyword symbol variable.
(stdio_handle): New member, addr.
(stdio_stream_print): Obtain descr by calling get_prop
method rather than directly from h->descr, in case it is
dynamically computed. Use ~a rather than ~s for incorporating
string properties into printed form, to eliminate quotes.
(stdio_stream_mark): Mark new addr member.
(sock_get_prop, sock_set_prop): New static functions.
(stdio_set_sock_peer): Invalidate h->descr by setting
it to nil.
(make_stdio_stream_common): Initialize h->addr to nil.
(make_sock_stream): Specify description as nil rather
than "socket".
(stream_init): Intern the addr keyword, and initialize
the addr_k variable.
Set the name of stdio_sock_ops to "stream-sock"
rather than leaving it inherited as "file-stream".
Wire in the sock_get_prop and sock_set_prop functions into
stdio_sock_ops.
* stream.h (addr_k): Declared.
|
|
|
|
|
| |
* socket.c (sock_accept): The address length passed to
recvfrom was not initialized to the storage length.
|
|
|
|
|
|
|
|
| |
* socket.c (dgram_set_sock_peer): Assign to struct
dgram_stream using using set macro.
* stream.c (stdio_set_sock_peer): Assign to struct
stdio_handle peer using set macro.
|
|
|
|
|
| |
* socket.c (sock_connect): If connect fails, show socket and
address in error message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New struct.
(make_dgram_sock_stream, dgram_print, dgram_mark,
dgram_destroy, dgram_overflow, dgram_put_byte_callback,
dgram_put_string, dgram_put_char, dgram_put_byte,
dgram_get_byte_callback, dgram_get_char, dgram_get_byte,
dgram_unget_char, dgram_unget_byte, dgram_flush, dgram_close,
dgram_get_prop, dgram_get_fd, dgram_get_sock_family,
dgram_get_sock_type, dgram_get_sock_peer,
dgram_set_sock_peer, dgram_get_error, dgram_get_error_str,
dgram_clear_error): New static functions.
(dgram_strm_ops): New static structure.
(sock_listen): Check against datagram sockets which have
a peer; otherwise a no-op for datagram sockets.
(sock_accept): Special logic for dgram sockets.
(open_sockfd): Function moved here from stream.c, and
augmented to open dgram stream for dgram sockets.
(open_socket): Function moved here from stream.c.
(sock_load_init): Fill in some operations in dgram_strm_ops.
* stream.c (generic_get_line, make_sock_stream,
errno_to_string): Statics become external.
(open_sockfd, open_socket): Functions removed from here,
moved to socket.c.
* stream.h (generic_get_line, make_sock_stream,
errno_to_string): Declared.
|
|
|
|
|
|
| |
* socket.c (sock_bind, sock_connect, sock_listen): Report
function name as sock-bind, sock-connect and sock-listen,
rather than bind, connect and listen.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.c (struct stdio_handle): New member, peer.
(stdio_stream_mark): Mark the new member.
(sock_peer, sock_set_peer): New functions.
(stream_init): Registered sock-peer intrinsic.
* stream.h (sock_peer, sock_set_peer): Declared.
* socket.c (sock_connect): If the connect is successful,
then store the address into the stream as the peer.
|
|
|
|
|
| |
* socket.c (sock_bind): Set the SO_REUSEADDR option before
binding the socket, to thwart the EADDRINUSE nuisance.
|
|
* socket.c, socket.h: New files.
* Makefile: include new socket.o among objects if have_objects
variable is defined to 'y'.
* configure (have_sockets): New variable. New configure test
for socket-related functionality.
(HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration
preprocessor symbols.
Also, reordering the shell probing so that /usr/xpg4/bin/sh
is the last fallback. On Solaris, it chokes on some code
that is needed for Solaris.
* lisplib.c (sock_set_entries, sock_instantiate): New static
functions.
(lisplib_init): Register new functions as autoload hooks.
* share/txr/stdlib/socket.tl: New file.
* stream.c (socket_error_s): New symbol variable.
(struct stdio_handle): New members, family and type, helping
stdio streams represent sockets too.
(stdio_stream_mark): Mark new members of struct stdio_handle.
(make_stdio_stream_common): Initialize new members.
(make_sock_stream, stream_fd, sock_family, sock_type,
open_socket, open_sockfd): New functions.
(stream_init): Initialize socket_error_s variable. Register
sock-family, sock-type and open-socket intrinsic functions.
Register socket-error subtype.
* stream.h (socket_error_s, make_sock_stream, stream_fd,
sock_family, sock_type, open_socket, open_sockfd):
Declared.
|