Matthias Kruk [Sat, 26 Nov 2022 03:41:25 +0000 (12:41 +0900)]
include/inst: Allow terminated instances to be cleaned up properly
The signal handler that is registered by `_inst_run()' catches the
EXIT and QUIT signals, which causes the handler to be executed one
more time before the process ends. The semaphore that the handler
will attempt to manipulate at that point will have already been
removed, causing the handler to end up in an infinite loop.
This commit changes the trap call so that the EXIT and QUIT signals
are not handled, preventing the signal handler from being executed
more than once.
Matthias Kruk [Sat, 19 Nov 2022 11:49:03 +0000 (20:49 +0900)]
include/ipc: Adjust permissions to allow inter-user IPC
Because the sgid bit is not set on the IPC directory, endpoints do
not inherit the group ownership from the parent directory. Thus,
endpoints are created with a user's primary group instead of the IPC
group, making inter-user IPC communication impossible.
This commit modifies the IPC module and the post-install script of
the debian package so that the sgid bit is set on the IPC directory
and endpoints are created with the correct permissions for IPC
communication between users.
Matthias Kruk [Sat, 19 Nov 2022 10:49:41 +0000 (19:49 +0900)]
include/queue: Create data file when queue is created
The data file that contains the queue data is not created when a
queue is created, but rather when data is inserted into the queue.
This causes issues in applications that use queues to share between
users because they need so set permissions on the entire queue at
the time of initialization. However, because the data file is not
created at that time, its permissions cannot be set.
This commit modifies `queue_init()' so that the data file is created
together with the queue.
Matthias Kruk [Sat, 19 Nov 2022 10:44:16 +0000 (19:44 +0900)]
include/queue: Base64-encoded data in queues
Queues are line-oriented, but the queue functions do not make sure
that user data does not contain newlines, causing data corruption
if the user inserts data that contains newlines.
This commit modifies the queue to store data in base64 format,
avoiding data-dependent behavior.
Matthias Kruk [Sat, 19 Nov 2022 10:38:00 +0000 (19:38 +0900)]
include/queue: Turn queue into a simple FIFO
The queue module contains functions for file queues and queues with
unique contents, which should be used into separate modules to keep
modules simple and avoid mistakes such as using functions for normal
queues on file-queues.
This commit removes functions for file and unique queues from the
queue module, turning queues into simple FIFO data structures.
Matthias Kruk [Sat, 19 Nov 2022 04:34:26 +0000 (13:34 +0900)]
include/inst: Move instance root to /tmp
Instance data is currently kept in the user's home directory, which
has the side-effect that data from crashed instances is not removed
when the machine reboots. Such instances will be shown by `--list',
and prevent singleton instances to be started.
This commit addresses the issue by moving the instance root to /tmp,
which *should* be a non-persistent filesystem.
Matthias Kruk [Sat, 19 Nov 2022 04:23:51 +0000 (13:23 +0900)]
include/inst: Store the instance root directory in a variable
The directory that all instance directories are contained within is
not kept in a variable, causing several functions to construct the
path from TOOLBOX_HOME. Hence, the root directory is effectively
declared in more than one place.
This commit introduces the global variable `__inst_root', which
points to the directory that contains all instance data, making it
unnecessary to construct the path from TOOLBOX_HOME.
Matthias Kruk [Sun, 9 Oct 2022 03:41:17 +0000 (12:41 +0900)]
README: Use uipc in PubSub example instead of ipc
The readme uses the ipc module to explain how to implement simple
pubsub-based messaging using toolbox. However, the ipc module is
somewhat awkward to configure because it uses GPG and requires the
user to generate unencrypted keys.
This commit modifies the readme to introduce the uipc module instead
of the ipc module, since the former is easier to set up.
Matthias Kruk [Sat, 8 Oct 2022 08:24:47 +0000 (17:24 +0900)]
include/mutex: Don't write to stderr when mutex_unlock() fails
When a mutex could not be unlocked, the rm call in mutex_unlock()
writes an error message directly to stderr. However, the function
should only return an error without writing to stderr.
This commit modifies mutex_unlock() so that it does not write to
stderr.
Matthias Kruk [Sat, 8 Oct 2022 08:21:45 +0000 (17:21 +0900)]
include/wmutex: Don't write to stderr when wmutex_unlock() fails
When a wmutex could not be unlocked, the rm call in wmutex_unlock()
writes an error message directly to stderr. However, the function
should only return an error without writing to stderr.
This commit modifies wmutex_unlock() so that it does not write to
stderr.
Matthias Kruk [Sat, 8 Oct 2022 07:38:57 +0000 (16:38 +0900)]
utils/ipc-ssltunnel: Initialize global variables
In ipc-ssltunnel, global variables are used to store the topics and
hooks that are passed to ipc-tap and ipc-inject. These variables are
declared in main(), however not all of them are initialized. While
this is not a bug, the function should either initialize all of the
arrays or none at all.
This commit modifies ipc-ssltunnel to initialize all of the arrays
in main().
Matthias Kruk [Sat, 8 Oct 2022 06:36:51 +0000 (15:36 +0900)]
utils/ipc-sshtunnel: Merge local_to_remote() and remote_to_local()
Except for the position of the call to ssh, the local_to_remote()
and remote_to_local() functions in ipc-sshtunnel are completely
identical.
This commit merges the two functions into one. The new function
expects the caller to pass the direction of the tunnel to be
established in the first argument.
Matthias Kruk [Sat, 8 Oct 2022 06:18:15 +0000 (15:18 +0900)]
utils/ipc-sshtunnel: Allow hooks to be passed on the command line
The ipc-tap and ipc-inject utility scripts allow hooks to be passed
on the command line that implement custom behavior upon receipt of
certain topics or tags. However, because ipc-sshtunnel does not take
hooks as command line arguments, this functionality cannot be used
with tunnels established using ipc-sshtunnel.
This commit modifies ipc-sshtunnel so that users may specify hooks
that will be passed on to ipc-tap and ipc-inject.
Matthias Kruk [Sat, 8 Oct 2022 04:41:40 +0000 (13:41 +0900)]
utils/ipc-sshtunnel: Add script for establishing IPC-over-SSH tunnels
This commit adds ipc-sshtunnel, a utility script for establishing a
bi-directional tunnel for IPC PubSub messages over SSH. This allows
scripts on separate machines to communicate even without a shared
file system.
Matthias Kruk [Thu, 6 Oct 2022 06:21:44 +0000 (15:21 +0900)]
toolbox.sh: Suppress errors in command_not_found_handle()
When the user enters an unknown command, or a script contains an
unknown command, the command_not_found_handle() function provides
suggestions if the unknown command appears to be in a module.
However, because the function does not suppress errors when looking
for modules in the module search paths, it emits errors if any of
the search paths do not exist.
This commit makes the command_not_found_handle() function suppress
errors if any of the module search paths do not exist.
Matthias Kruk [Sun, 2 Oct 2022 05:53:59 +0000 (14:53 +0900)]
utils/ipc-inject: Don't inject messages with header
When ipc-inject injects a message, it uses ipc_endpoint_publish()
to re-publish it in its entirety, including the wrapper it was
received in, causing it to be double-wrapped.
This commit modifies ipc-inject so that it re-publishes only the
data of the received message, instead of the entire message.
Matthias Kruk [Sat, 1 Oct 2022 12:47:33 +0000 (21:47 +0900)]
utils: Implement hooks in ipc-tap and ipc-inject
To correctly forward foundry messages using ipc-tap and ipc-inject,
it is necessary to move data that is usually not transferred over
IPC messages. In order to transfer this data over ipc-tap and
ipc-inject, hooks are necessary that allow user-data to be generated
on the ipc-tap side and consumed on the ipc-inject side.
This commit implements a simple mechanism that allows the user to
specify hooks that are called by ipc-tap whenever a message on a
user-defined topic is encountered. The hook can then inject
messages into ipc-tap's data stream. On the ipc-inject side, the
user may define hooks that are called when a user-message with a
application-defined tag is encountered, allowing the injected
message to be handled on the ipc-inject side.
Matthias Kruk [Sat, 1 Oct 2022 06:02:45 +0000 (15:02 +0900)]
utils: Add interceptor and injector for IPC PubSub messages
Because the IPC module uses the file system to exchange messages,
remote systems cannot communicate without a shared file system such
as NFS. However, NFS may not be an option due to resource and
security constraints.
This commit adds the ipc-tap and ipc-inject utilities, which can be
used to bridge messages over an SSH connection. As the name suggests,
the ipc-tap utility taps into topics and outputs messages published
on those topics to standard output.
The ipc-inject reads messages from standard input and injects them
into local PubSub topics.
include/sem: Implement sem_trywait() using sem_wait() with 0 timeout
Because sem_trywait() does not unlock the waitlock if the counter is
greater than 1, the next caller will be left waiting until sem_post()
is executed.
This commit changes sem_trywait() to call sem_wait() with a timeout
of 0 seconds, since this issue does not affect sem_wait().
include/uipc: Add "topic" field to pubsub UIPC messages
Messages that were sent with uipc_endpoint_publish() don't contain
information about the topic that they were published on, making it
impossible for the receiver to determine what topic a message was
published on if they are subscribed to more than one topic.
This commit adds a new field "topic" to UIPC messages and modifies
uipc_endpoint_publish() so that it sets the field appropriately. This
further adds the function uipc_msg_get_topic() that may be used to
determine the topic a UIPC message was published on.
include/ipc: Add "topic" field to pubsub IPC messages
Messages that were sent with ipc_endpoint_publish() don't contain
information about the topic that they were published on, making it
impossible for the receiver to determine what topic a message was
published on if they are subscribed to more than one topic.
This commit adds a new field "topic" to IPC messages and modifies
ipc_endpoint_publish() so that it sets the field appropriately. This
further adds the function ipc_msg_get_topic() that may be used to
determine the topic an IPC message was published on.
test/ipc: Fix comparisons in test cases for ipc_endpoint_recv()
In the test cases for ipc_endpoint_recv(), the comparisons used to
check the correctness of the received data are inverted, causing the
tests to fail when they should succeed and vice-versa.
test/ipc: Fix return values in test case for ipc_endpoint_open()
When testing whether ipc_endpoint_open() correctly opens a private
endpoint, the return values of the test case are inverted, causing
the test to fail when it should succeed and vice-versa.
This commit inverts the return values of the test case.
Matthias Kruk [Thu, 11 Aug 2022 18:21:40 +0000 (03:21 +0900)]
include/opt: Add a default regex and action
The regex and action of an option may be unset, making it necessary
to check their value before using them.
This commit modifies the opt module to define a default regex and
action in case the user didn't provide one, allowing the parser to
omit checks if the two are unset.
Matthias Kruk [Thu, 11 Aug 2022 18:14:19 +0000 (03:14 +0900)]
include/opt: Initialize value of options that don't have a value
The opt module uses the value of options that aren't followed by a
parameter to count how often the option was on the command line.
However, in this case it never initializes the value.
This commit modifies the opt module so that it initializes the
value of options that are not followed by a parameter to 0.
Matthias Kruk [Thu, 11 Aug 2022 18:04:19 +0000 (03:04 +0900)]
include/opt: Remove summary of short options from help text
The help text displayed by the opt module contains a summary of all
short options in the title. However, a cursory search showed that
most commandline tools don't do that. Thus, this "feature" may be
removed.
This commit removes the summary of short options from the title of
the help text.
Matthias Kruk [Thu, 11 Aug 2022 17:57:48 +0000 (02:57 +0900)]
include/opt: Improve code readability
There are several functions in the opt module where local variables
are not declared in the most narrow block possible, statements are
needlessly spread over multiple lines, and values used only once
are assigned to variables; all of which impeding readability.
This commit modifies the opt module to remove cases of assign-once-
read-once variables, remove integer increments on separate lines,
make the "scope" of variables narrower, and declare variables
with a type, where possible.
Matthias Kruk [Thu, 11 Aug 2022 17:48:34 +0000 (02:48 +0900)]
include/opt: Remove unnecessary array __opt_long
The data that is stored in opt's __opt_long array is a subset of
the data stored in __opt_map. The operations that the module does
on __opt_long might just as well be performed on __opt_map without
affecting the behavior of the module.
This commit removes the __opt_long array from the module and
changes the affected functions to use __opt_map instead.
Matthias Kruk [Thu, 11 Aug 2022 17:46:52 +0000 (02:46 +0900)]
include/opt: Show default values in help text
The opt module does not show the default values of options in the
help text, leaving the user guessing what the values of options are
if they are not specified on the command line.
This commit modifies `opt_print_help()` so that it displays the
default values of options that have a value and a default set.
Matthias Kruk [Thu, 11 Aug 2022 17:09:07 +0000 (02:09 +0900)]
include/opt: Use associative array to track missing options
The opt module does not track missing options, but instead checks
on demand if required options are missing by inspecting all options'
flags and value. This approach is needlessly complicated and slow.
This commit changes the opt module to track required options using
an associative array, allowing the check for missing options to be
performed in constant time.
Matthias Kruk [Thu, 11 Aug 2022 16:54:00 +0000 (01:54 +0900)]
include/opt: Use an associative array to simplify flag parsing
When parsing the flags of an option, the opt module uses a case
construct, which looks clumsy, isn't very easy to read, and makes
adding new flags more complicated than need be.
This commit modifies the opt module to use an associative array
to simplify flag parsing. This way, the parser only has to use a
flag as index into the array in order to find out its internal
value.
Matthias Kruk [Thu, 11 Aug 2022 13:06:36 +0000 (22:06 +0900)]
include/opt: Make return values of opt_get() more helpful
The function `opt_get()` returns 0 when an option is valid but was
not set. This makes it impossible to distinguish if the value of
the option is the empty string or it does not have a value at all.
Further, it does not return an error if an invalid option's value
was requested.
This commit fixes the behavior of `opt_get()` so that it returns 0
if an option is valid and has a value (default or user-defined), 1
in case that the option name is invalid, and 2 in case that the
option name is valid but it does not have a value.
Matthias Kruk [Thu, 11 Aug 2022 12:27:49 +0000 (21:27 +0900)]
include/opt: Emit an error message when an option is redefined
When the caller attempts to redefine an option, `opt_add_arg()` fails
without printing an error message, leaving the situation undetected
if the caller does not check the return value of the call.
This commit modifies `opt_add_arg()` to print an error message when
a caller attempts to redefine an option.
Matthias Kruk [Thu, 11 Aug 2022 11:48:17 +0000 (20:48 +0900)]
include/opt: Use column command to align help text
When printing the help text, the opt module aligns columns manually
by tracking the longest option name and inserting the required amount
of spaces into the output. This is needlessly complicated considering
there are simpler ways to align output.
This commit modifies the opt module to use the column command to
align the table of options in the help text.
Matthias Kruk [Thu, 11 Aug 2022 11:18:02 +0000 (20:18 +0900)]
include/opt: Print correct script name on older bash versions
The opt module references $BASH_ARGV0 to get the name of the running
script. However, the variable does not exist on older bash versions,
causing a gap in the help text.
This commit modifies the opt module to access the script name from
$0, which should be available on all bash versions.
toolbox.sh: Make command-not-found errors more helpful
Command-not-found errors often occur because the user forgot to
include a module. In such cases, it would be helpful if the default
error message included suggestions for modules to include.
This commit adds a `command_not_found_handle()` function that
overrides bash's default behavior: aside of the usual error message,
this function will print all module names that the missing function
may be part of (as determined by its name) to stderr.
Matthias Kruk [Sun, 27 Feb 2022 09:02:18 +0000 (18:02 +0900)]
include/inst: Expect arguments from opt_get_argv() in multiple lines
The inst module expects `opt_get_argv()` to print all command line
arguments in one line, however the behavior of `opt_get_argv()` has
been changed to print arguments line-by-line.
This commit modifies the inst module so that it expects arguments to
be returned one per line by `opt_get_argv()`.
Matthias Kruk [Mon, 14 Feb 2022 10:52:14 +0000 (19:52 +0900)]
include/mutex: Use $$ instead of $BASHPID to identify the owner
The mutex module uses $BASHPID to identify the owner of a mutex,
causing scripts to be unable to unlock a mutex that was created in a
subshell (which is what happens when using the ipc module).
This commit changes the mutex module to use $$ to identify the owner
of a mutex, allowing child processes to unlock their parent's mutexes
and vice-versa.
Matthias Kruk [Mon, 14 Feb 2022 10:42:56 +0000 (19:42 +0900)]
include/ipc: Fix bug in unsubscribe logic when closing an endpoint
When `ipc_endpoint_close()` attempts to remove all subscriptions of
an endpoint, the list that it iterates over includes the directory
containing the subscriptions, causing the function to emit an error.
This commit fixes the way that `ipc_endpoint_close()` determines the
list of subscriptions to be removed.
Matthias Kruk [Sat, 22 Jan 2022 07:48:46 +0000 (16:48 +0900)]
debian: Don't create/remove groups during upgrades/downgrades
The debian maintainer scripts remove and create group during upgrades
and downgrades, causing the group ids to change, locking users out of
/var/lib/toolbox.
This commit modifies the debian maintainer scripts so that they only
remove groups during package removals.
Matthias Kruk [Fri, 21 Jan 2022 09:55:39 +0000 (18:55 +0900)]
debian: Add/remove groups during installation/removal
When installing toolbox from debian packages, the toolbox and
toolbox_ipc groups are not created, and the permissions and
ownership of /var/lib/toolbox are incorrect.
This commit adds postinst and postrm scripts that create and remove
the toolbox and toolbox_ipc groups during installation/removal, and
set the permissions on /var/lib/toolbox appropriately.
Matthias Kruk [Thu, 2 Dec 2021 03:00:24 +0000 (12:00 +0900)]
include/is: Add is_int() function
The is_digits() function provided by the "is" module can be used to
determine if an input consists of only digits. However, it cannot be
used to validate inputs that may be prefixed with a sign.
This commit adds the is_int() function, which can be used to validate
numeric inputs that may be prefixed with a sign.
Matthias Kruk [Wed, 1 Dec 2021 09:40:28 +0000 (18:40 +0900)]
include/ipc: Use the endpoint name as name for pubsub subscriptions
When subscribing to a pubsub channel, a name constructed from the
hostname and pid is used for the subscription name. When multiple
processes subscribe to the same topic using the same endpoint, this
causes the endpoint to be subscribed multiple times, and multiple
messages to be received by the endpoint, when it should only receive
one message (this usage is intended for load-balancing over pubsub
channels).
This commit modifies the ipc module so that the name of the endpoint
is used for the subscription name, preventing an endpoint from being
subscribed multiple times to the same topic.
Matthias Kruk [Tue, 30 Nov 2021 13:07:29 +0000 (22:07 +0900)]
include/ipc: Don't dereference symlinks when subscribing to a topic
The `_ipc_endpoint_topic_subscribe()' function dereferences symbolic
links when subscribing to a topic, causing symbolic links to be
created in the wrong directory if the topic already exists.
This commit changes the flags that `_ipc_endpoint_topic_subscribe()'
passes to `ln' so that the target won't be dereferenced if it refers
to a symbolic link.
Matthias Kruk [Thu, 25 Nov 2021 05:25:08 +0000 (14:25 +0900)]
Makefile: Disable tests during build process
The test suite is executed automatically by dpkg-buildpackage during
the build process. However, because the test framework is not set up
on the build machine, this causes the packaging process to fail.
This commit removes the test rule from the Makefile to avoid issues
with the build system until the test framework is set up.
Matthias Kruk [Thu, 25 Nov 2021 04:45:42 +0000 (13:45 +0900)]
include/ipc: Add GPLv3 notice
The ipc module does not have a license header, making it hard to tell
what license the code was published under if the file ever gets separated.
This commit adds a license header to the ipc module.
Matthias Kruk [Sun, 8 Aug 2021 06:30:36 +0000 (15:30 +0900)]
include/git: Add module for interaction with git repositories
This commit adds a module that can be used to perform operations such
as cloning, merging, pushing, etc on a git repository without having
to change directories.
include/conf: Add function to get available configuration entries
The conf module currently does not provide a means to figure out what
configuration entries are available.
This commit adds a method that allows the caller to figure out what
configuration settings are available in a given configuration domain.
include/ipc: Add ipc_endpoint_foreach_message() function
The IPC module currently does not provide an API that can be used
to enquire the state of the queue of an endpoint. This makes it
unnecessarily complicated to implement monitoring of IPC endpoints.
This commit adds the ipc_endpoint_foreach_message() function that
may be used to enquire about messages that are stored in the internal
queue of an IPC endpoint. The semantics of this function are similar
to those of queue_foreach(), with the exception that the endpoint
name is passed in the first parameter of the callback and the message
in the second parameter. The remaining parameters are passed on from
ipc_endpoint_foreach_message().
include/conf: Add support for multiple configuration files
The current conf implementation does not permit processes to use
more than one configuration file.
This commit modifies the conf module so that each process may use
an arbitrary number of configuration files by appending the name of
a config domain to the commandline of commands such as conf_get()
and conf_set(), falling back to "default" if the config domain was
omitted.
This commit further adds the conf_get_domains() method that may be
used to query the names of known configuration domains.
Instances don't handle signals, causing them not to get cleaned up
properly when terminated by a signal.
This commit adds a signal handler to the inst module, making sure
instances are properly cleaned up when terminated by a signal.
include/inst: Make subsequent calls to inst_running() return false
When an instance is instructed to stop, a semaphore is increased to
signal this condition. The inst_running() function uses sem_trywait()
on this semaphore, returning false if the semaphore could be passed,
thus telling the caller that the instance should be stopped.
However, since sem_trywait() decreases the semaphore, subsequent calls
to inst_running() will return true again.
This commit changes inst_running() to increase the semaphore in case
it was decreased by sem_trywait(). However, there remains a small
window of opportunity where the function may return different values
to different callers if multiple processes from the same instance call
the function at the same time.
include/inst: Allow functions to be used on foreign instances
Functions of the inst module assume that instances of the current
script are supposed to be manipulated. This makes it impossible for
the functions to be used to enquire or manipulate instances of other
scripts.
This commit changes the functions (where it makes sense) so they can
be used to operate on instances of scripts other than the one that is
executing them.
Several of the test cases for the json module are calling the wrong
functions. Further, there are no test cases for type specifiers in
json_object() and json_array().
This commit fixes test cases that are calling the wrong functions and
adds test cases for type specifiers.
When constructing JSON objects and arrays, there are cases where the
json_object() and json_array() functions cannot correctly determine
the type of a variable (for example, "true" could be string or bool).
This commit introduces type specifiers that allow the user to declare
the type of a value that is passed to the json functions.
Specifiers are prepended to the value when passing it to the
json_object() json_array() functions. The following specifiers are
understood:
For backwards compatibility, the specifiers may be omitted. In that
case, a best-effort guess will be made. Omitting type specifiers will
make it impossible to pass certain values in strings.
include/json: Allow false booleans to be retrieved from JSON types
Because of the way the return value of jq is checked in
json_object_get() and json_array_head(), the functions will fail if a
value of (boolean) "false" was retrieved from the JSON type.
This commit fixes the behavior of json_object_get() and
json_array_head() so that false booleans can be retrieved.
There are issues with bats when accessing device files such as
/dev/urandom, making it hard to implement tests that require randomness.
This commit modifies test.sh to use shellspec as the default test
framework.
To avoid the dependency on ssh, this commit removes the ssh module
from the toolbox core package. The module will be moved to a separate
repository, presumably something along the lines of toolbox-goodies.
The json module doesn't provide any functions to retrieve data from
within JSON types, requiring users to call jq (or other parsers)
directly.
This commit adds the json_object_get() function, which allows the user
to retrieve the value of a field in a JSON object.
Matthias Kruk [Wed, 30 Jun 2021 22:36:10 +0000 (07:36 +0900)]
include/queue: Correctly handle omitted timeout in queue_get_file()
The queue_get_file() function does not correctly interpret the timeout
as infinity if the parameter is omitted.
This commit adds a check to queue_get_file() so that the timeout is
set correctly if the parameter is omitted.
Matthias Kruk [Wed, 30 Jun 2021 22:27:39 +0000 (07:27 +0900)]
include/queue: Don't allow passing data along with files
The queue implementation allows data to be passed along with files in
a queue. This increases the complexity of the queue implementation and
taints the API since the return value from queue_get_file() can't be
used without splitting it first.
This commit removes user-data passing from queue_put_file() and
queue_get_file().
Matthias Kruk [Tue, 29 Jun 2021 00:26:08 +0000 (09:26 +0900)]
test/queue: Add test cases for several queue functions
To ensure that the queue module behaves as intended, test cases are
needed.
This commit adds test cases to test the behavior of the following
functions.
- queue_init()
- queue_destroy()
- queue_put()
- queue_put_unique()
- queue_put_file()
- queue_get()
- queue_foreach()
Matthias Kruk [Mon, 28 Jun 2021 23:28:23 +0000 (08:28 +0900)]
include/queue: Prevent queue_put_unique() from adding duplicates
There are several issues in _queue_contains(), causing the
queue_put_unique() function to hang (waiting for input from stdin) or
add duplicate items to the queue.
This commit addresses these issues so that queue_put_unique() does not
hang or add duplicate items.
Matthias Kruk [Mon, 28 Jun 2021 21:57:38 +0000 (06:57 +0900)]
include/array: Add functions for comparing two arrays
This commit adds the array_same() and array_identical() functions to
the array module. The former allows the caller to determine if two
arrays contain the same elements (i.e. permutations are accepted)
while the latter function does not permit permutations.
To avoid dependencies on packages such as X11 in the toolbox core
package, several packages need to be moved into separate repositories.
This commit removes the following modules from this repository:
- acpi/ac => toolbox-linux
- acpi/battery => toolbox->linux
- clip => toolbox-x11
- gitlab => toolbox-restapis
- iruca => toolbox-restapis
- net/iface => toolbox-linux
- xrandr => toolbox-x11
Matthias Kruk [Sun, 27 Jun 2021 07:35:28 +0000 (16:35 +0900)]
include/queue: Fix missing arrowheads in documentation
The petri net in the comment explaining the queue internals are
missing arrowheads. This may cause confusion since edges in petri
nets are usually directed.
This commit adds the missing arrowheads to the petri net.