sending.
When a peer leaves a group, they send a packet to the group
indicating that they're leaving. However if this packet is sent
via TCP, it gets put in a packet queue, which is then destroyed
on the rest of the group cleanup process before ever being able
to send.
This pr allows do_gc() to finish an iteration before cleaning the
group up, which allows the TCP packet queue to be emptied. However
this bug still exists on a tox_kill() event because we don't have
a chance to do another do_gc() iteration.
We really don't support it. I tried for half an hour to get some kind of
plan9 cross compilation to work, but it's not working. If anyone wants
to bring it back, they are welcome to send a PR including a CI check for
it. Until then, these 5 lines of unused code are gone.
There will be more object arrays that need to be packed. This function
takes care of NULL (creating an empty array), and putting the correct
array size and calling the per-element callback the right amount of
times.
- We no longer assert peer roles in the mod event callback
because this causes an issue with the new events implementation,
which triggers the events after all the packets from the
current tox_iterate() are processed, rather than as the
packets are received. These checks were superfluous and shouldn't
reduce code coverage.
- A moderator now sets the topic before the founder kicks him in
order to increase internal code coverage.
These are quite expensive, because they go through all events to index
in a typed array that no longer exists. Clients should index in the
union array and find the event they want themselves, or use dispatch.
We allow non-null data pointers to be passed to functions
alongside 0-length data. For example when creating a data
buffer that has room for the entire packet, including ignored
header data.
This error broke a rare but legitimate case where we miss
packets during a handshake attempt and need to store empty
handshake packets in the packet array.
So we don't need to write so many edge case tests ourselves for things
like parsers, which really don't need those manual tests, as long as we
can check for some properties like "can output the parsed data and it'll
be the same as the input".
commit 5b9c420c introduced some undesirable behaviour with packet send
functions returning error when they shouldn't. We now only return an
error if the packet fails to be added to the send queue or cannot
be wrapped/encrypted. We no longer error if we fail to send the packet
over the wire, because toxcore will keep trying to re-send the packet
until the connection times out.
Additionally, we now make sure that our packet broadcast functions
aren't returning an error when failing to send packets to peers
that we have not successfully handshaked with yet, since this is
expected behaviour.
We always assumed that create_array_entry() would only be called
with an empty array entry and wouldn't modify entries on error.
We now explicitly require both conditions, and also give an
error in the case of a non-null data pointer with a zero
length field, as this indicates a logic error.
Checks for an empty array entry that precede a call to
create_array_entry() are now redundant. It should be noted that
a non-empty entry doesn't necessarily indicate an error. This
condition can be triggered if packets are being sent or
received faster than they can be processed/acknowledged,
which is common when spamming messages on poor connections.
Avoiding passing down the entire DHT struct pointer to the inner
functions makes it possible in the future to write unit tests without
having to construct a full DHT object.
None of the others use out parameters. Also no toxcore function uses out
parameters for anything other than arrays and errors. This would be a
first, for no good reason.
This fetches it from github, so we don't need to build it locally.
Not super ideal, because devs are supposed to build it locally to prove
reproducibility, but we can keep that diligence on the dev to do once
when actually merging the PR.