Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace
640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) 5047ae5a2 chore: make the source tarball exhibit the old behavior 14804a4b8 chore: Fix sonar-scan CI action. e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project. 3accade67 chore: Fix CI, disabling some tests that no longer run on CI. ef8d767e6 cleanup: Fix comment formatting errors. 34ec822da cleanup: Fix some clang-19 format warnings. 40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes. f81e30679 refactor: Use per-parameter nullability annotations. REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
@@ -122,8 +122,7 @@ size_t tcp_server_listen_count(const TCP_Server *tcp_server)
|
||||
* @retval -1 on failure
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int alloc_new_connections(TCP_Server *tcp_server, uint32_t num)
|
||||
static int alloc_new_connections(TCP_Server *_Nonnull tcp_server, uint32_t num)
|
||||
{
|
||||
const uint32_t new_size = tcp_server->size_accepted_connections + num;
|
||||
|
||||
@@ -149,8 +148,7 @@ static int alloc_new_connections(TCP_Server *tcp_server, uint32_t num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void wipe_secure_connection(TCP_Secure_Connection *con)
|
||||
static void wipe_secure_connection(TCP_Secure_Connection *_Nonnull con)
|
||||
{
|
||||
if (con->status != 0) {
|
||||
wipe_priority_list(con->con.mem, con->con.priority_queue_start);
|
||||
@@ -158,15 +156,13 @@ static void wipe_secure_connection(TCP_Secure_Connection *con)
|
||||
}
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void move_secure_connection(TCP_Secure_Connection *con_new, TCP_Secure_Connection *con_old)
|
||||
static void move_secure_connection(TCP_Secure_Connection *_Nonnull con_new, TCP_Secure_Connection *_Nonnull con_old)
|
||||
{
|
||||
*con_new = *con_old;
|
||||
crypto_memzero(con_old, sizeof(TCP_Secure_Connection));
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void free_accepted_connection_array(TCP_Server *tcp_server)
|
||||
static void free_accepted_connection_array(TCP_Server *_Nonnull tcp_server)
|
||||
{
|
||||
if (tcp_server->accepted_connection_array == nullptr) {
|
||||
return;
|
||||
@@ -185,22 +181,19 @@ static void free_accepted_connection_array(TCP_Server *tcp_server)
|
||||
* @return index corresponding to connection with peer on success
|
||||
* @retval -1 on failure.
|
||||
*/
|
||||
non_null()
|
||||
static int get_tcp_connection_index(const TCP_Server *tcp_server, const uint8_t *public_key)
|
||||
static int get_tcp_connection_index(const TCP_Server *_Nonnull tcp_server, const uint8_t *_Nonnull public_key)
|
||||
{
|
||||
return bs_list_find(&tcp_server->accepted_key_list, public_key);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int kill_accepted(TCP_Server *tcp_server, int index);
|
||||
static int kill_accepted(TCP_Server *_Nonnull tcp_server, int index);
|
||||
|
||||
/** @brief Add accepted TCP connection to the list.
|
||||
*
|
||||
* @return index on success
|
||||
* @retval -1 on failure
|
||||
*/
|
||||
non_null()
|
||||
static int add_accepted(TCP_Server *tcp_server, const Mono_Time *mono_time, TCP_Secure_Connection *con)
|
||||
static int add_accepted(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time, TCP_Secure_Connection *_Nonnull con)
|
||||
{
|
||||
int index = get_tcp_connection_index(tcp_server, con->public_key);
|
||||
|
||||
@@ -250,8 +243,7 @@ static int add_accepted(TCP_Server *tcp_server, const Mono_Time *mono_time, TCP_
|
||||
* @retval 0 on success
|
||||
* @retval -1 on failure
|
||||
*/
|
||||
non_null()
|
||||
static int del_accepted(TCP_Server *tcp_server, int index)
|
||||
static int del_accepted(TCP_Server *_Nonnull tcp_server, int index)
|
||||
{
|
||||
if ((uint32_t)index >= tcp_server->size_accepted_connections) {
|
||||
return -1;
|
||||
@@ -276,15 +268,17 @@ static int del_accepted(TCP_Server *tcp_server, int index)
|
||||
}
|
||||
|
||||
/** Kill a TCP_Secure_Connection */
|
||||
non_null()
|
||||
static void kill_tcp_secure_connection(TCP_Secure_Connection *con)
|
||||
static void kill_tcp_secure_connection(TCP_Secure_Connection *_Nullable con)
|
||||
{
|
||||
if (con == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
kill_sock(con->con.ns, con->con.sock);
|
||||
wipe_secure_connection(con);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int rm_connection_index(TCP_Server *tcp_server, TCP_Secure_Connection *con, uint8_t con_number);
|
||||
static int rm_connection_index(TCP_Server *_Nonnull tcp_server, TCP_Secure_Connection *_Nonnull con, uint8_t con_number);
|
||||
|
||||
/** @brief Kill an accepted TCP_Secure_Connection
|
||||
*
|
||||
@@ -315,9 +309,7 @@ static int kill_accepted(TCP_Server *tcp_server, int index)
|
||||
* @retval 1 if everything went well.
|
||||
* @retval -1 if the connection must be killed.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_tcp_handshake(const Logger *logger, TCP_Secure_Connection *con, const uint8_t *data, uint16_t length,
|
||||
const uint8_t *self_secret_key)
|
||||
static int handle_tcp_handshake(const Logger *_Nonnull logger, TCP_Secure_Connection *_Nonnull con, const uint8_t *_Nonnull data, uint16_t length, const uint8_t *_Nonnull self_secret_key)
|
||||
{
|
||||
if (length != TCP_CLIENT_HANDSHAKE_SIZE) {
|
||||
LOGGER_ERROR(logger, "invalid handshake length: %d != %d", length, TCP_CLIENT_HANDSHAKE_SIZE);
|
||||
@@ -380,8 +372,7 @@ static int handle_tcp_handshake(const Logger *logger, TCP_Secure_Connection *con
|
||||
* @retval 0 if we didn't get it yet.
|
||||
* @retval -1 if the connection must be killed.
|
||||
*/
|
||||
non_null()
|
||||
static int read_connection_handshake(const Logger *logger, TCP_Secure_Connection *con, const uint8_t *self_secret_key)
|
||||
static int read_connection_handshake(const Logger *_Nonnull logger, TCP_Secure_Connection *_Nonnull con, const uint8_t *_Nonnull self_secret_key)
|
||||
{
|
||||
uint8_t data[TCP_CLIENT_HANDSHAKE_SIZE];
|
||||
const int len = read_tcp_packet(logger, con->con.mem, con->con.ns, con->con.sock, data, TCP_CLIENT_HANDSHAKE_SIZE, &con->con.ip_port);
|
||||
@@ -399,9 +390,7 @@ static int read_connection_handshake(const Logger *logger, TCP_Secure_Connection
|
||||
* @retval 0 if could not send packet.
|
||||
* @retval -1 on failure (connection must be killed).
|
||||
*/
|
||||
non_null()
|
||||
static int send_routing_response(const Logger *logger, TCP_Secure_Connection *con, uint8_t rpid,
|
||||
const uint8_t *public_key)
|
||||
static int send_routing_response(const Logger *_Nonnull logger, TCP_Secure_Connection *_Nonnull con, uint8_t rpid, const uint8_t *_Nonnull public_key)
|
||||
{
|
||||
uint8_t data[2 + CRYPTO_PUBLIC_KEY_SIZE];
|
||||
data[0] = TCP_PACKET_ROUTING_RESPONSE;
|
||||
@@ -416,8 +405,7 @@ static int send_routing_response(const Logger *logger, TCP_Secure_Connection *co
|
||||
* @retval 0 if could not send packet.
|
||||
* @retval -1 on failure (connection must be killed).
|
||||
*/
|
||||
non_null()
|
||||
static int send_connect_notification(const Logger *logger, TCP_Secure_Connection *con, uint8_t id)
|
||||
static int send_connect_notification(const Logger *_Nonnull logger, TCP_Secure_Connection *_Nonnull con, uint8_t id)
|
||||
{
|
||||
uint8_t data[2] = {TCP_PACKET_CONNECTION_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
|
||||
return write_packet_tcp_secure_connection(logger, &con->con, data, sizeof(data), true);
|
||||
@@ -428,8 +416,7 @@ static int send_connect_notification(const Logger *logger, TCP_Secure_Connection
|
||||
* @retval 0 if could not send packet.
|
||||
* @retval -1 on failure (connection must be killed).
|
||||
*/
|
||||
non_null()
|
||||
static int send_disconnect_notification(const Logger *logger, TCP_Secure_Connection *con, uint8_t id)
|
||||
static int send_disconnect_notification(const Logger *_Nonnull logger, TCP_Secure_Connection *_Nonnull con, uint8_t id)
|
||||
{
|
||||
uint8_t data[2] = {TCP_PACKET_DISCONNECT_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
|
||||
return write_packet_tcp_secure_connection(logger, &con->con, data, sizeof(data), true);
|
||||
@@ -439,8 +426,7 @@ static int send_disconnect_notification(const Logger *logger, TCP_Secure_Connect
|
||||
* @retval 0 on success.
|
||||
* @retval -1 on failure (connection must be killed).
|
||||
*/
|
||||
non_null()
|
||||
static int handle_tcp_routing_req(TCP_Server *tcp_server, uint32_t con_id, const uint8_t *public_key)
|
||||
static int handle_tcp_routing_req(TCP_Server *_Nonnull tcp_server, uint32_t con_id, const uint8_t *_Nonnull public_key)
|
||||
{
|
||||
uint32_t index = -1;
|
||||
TCP_Secure_Connection *con = &tcp_server->accepted_connection_array[con_id];
|
||||
@@ -522,9 +508,7 @@ static int handle_tcp_routing_req(TCP_Server *tcp_server, uint32_t con_id, const
|
||||
* @retval 0 on success.
|
||||
* @retval -1 on failure (connection must be killed).
|
||||
*/
|
||||
non_null()
|
||||
static int handle_tcp_oob_send(TCP_Server *tcp_server, uint32_t con_id, const uint8_t *public_key, const uint8_t *data,
|
||||
uint16_t length)
|
||||
static int handle_tcp_oob_send(TCP_Server *_Nonnull tcp_server, uint32_t con_id, const uint8_t *_Nonnull public_key, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > TCP_MAX_OOB_DATA_LENGTH) {
|
||||
return -1;
|
||||
@@ -602,8 +586,7 @@ static IP_Port con_id_to_ip_port(uint32_t con_id, uint64_t identifier)
|
||||
* @retval true on success.
|
||||
* @retval false if ip_port is invalid.
|
||||
*/
|
||||
non_null()
|
||||
static bool ip_port_to_con_id(const TCP_Server *tcp_server, const IP_Port *ip_port, uint32_t *con_id)
|
||||
static bool ip_port_to_con_id(const TCP_Server *_Nonnull tcp_server, const IP_Port *_Nonnull ip_port, uint32_t *_Nonnull con_id)
|
||||
{
|
||||
*con_id = ip_port->ip.ip.v6.uint32[0];
|
||||
|
||||
@@ -612,8 +595,7 @@ static bool ip_port_to_con_id(const TCP_Server *tcp_server, const IP_Port *ip_po
|
||||
tcp_server->accepted_connection_array[*con_id].identifier == ip_port->ip.ip.v6.uint64[1];
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int handle_onion_recv_1(void *object, const IP_Port *dest, const uint8_t *data, uint16_t length)
|
||||
static int handle_onion_recv_1(void *_Nonnull object, const IP_Port *_Nonnull dest, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
TCP_Server *tcp_server = (TCP_Server *)object;
|
||||
uint32_t index;
|
||||
@@ -636,9 +618,7 @@ static int handle_onion_recv_1(void *object, const IP_Port *dest, const uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool handle_forward_reply_tcp(void *object, const uint8_t *sendback_data, uint16_t sendback_data_len,
|
||||
const uint8_t *data, uint16_t length)
|
||||
static bool handle_forward_reply_tcp(void *_Nonnull object, const uint8_t *_Nonnull sendback_data, uint16_t sendback_data_len, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
TCP_Server *tcp_server = (TCP_Server *)object;
|
||||
|
||||
@@ -677,8 +657,7 @@ static bool handle_forward_reply_tcp(void *object, const uint8_t *sendback_data,
|
||||
* @retval 0 on success
|
||||
* @retval -1 on failure
|
||||
*/
|
||||
non_null()
|
||||
static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint8_t *data, uint16_t length)
|
||||
static int handle_tcp_packet(TCP_Server *_Nonnull tcp_server, uint32_t con_id, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (length == 0) {
|
||||
return -1;
|
||||
@@ -693,7 +672,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling routing request for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling routing request for %u", con_id);
|
||||
return handle_tcp_routing_req(tcp_server, con_id, data + 1);
|
||||
}
|
||||
|
||||
@@ -702,7 +681,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling connection notification for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling connection notification for %u", con_id);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -711,7 +690,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling disconnect notification for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling disconnect notification for %u", con_id);
|
||||
return rm_connection_index(tcp_server, con, data[1] - NUM_RESERVED_PORTS);
|
||||
}
|
||||
|
||||
@@ -720,7 +699,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling ping for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling ping for %u", con_id);
|
||||
|
||||
uint8_t response[1 + sizeof(uint64_t)];
|
||||
response[0] = TCP_PACKET_PONG;
|
||||
@@ -734,7 +713,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling pong for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling pong for %u", con_id);
|
||||
|
||||
uint64_t ping_id;
|
||||
memcpy(&ping_id, data + 1, sizeof(uint64_t));
|
||||
@@ -755,14 +734,14 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling oob send for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling oob send for %u", con_id);
|
||||
|
||||
return handle_tcp_oob_send(tcp_server, con_id, data + 1, data + 1 + CRYPTO_PUBLIC_KEY_SIZE,
|
||||
length - (1 + CRYPTO_PUBLIC_KEY_SIZE));
|
||||
}
|
||||
|
||||
case TCP_PACKET_ONION_REQUEST: {
|
||||
LOGGER_TRACE(tcp_server->logger, "handling onion request for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling onion request for %u", con_id);
|
||||
|
||||
if (tcp_server->onion != nullptr) {
|
||||
if (length <= 1 + CRYPTO_NONCE_SIZE + ONION_SEND_BASE * 2) {
|
||||
@@ -778,7 +757,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
}
|
||||
|
||||
case TCP_PACKET_ONION_RESPONSE: {
|
||||
LOGGER_TRACE(tcp_server->logger, "handling onion response for %d", con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling onion response for %u", con_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -821,7 +800,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
}
|
||||
|
||||
const uint8_t c_id = data[0] - NUM_RESERVED_PORTS;
|
||||
LOGGER_TRACE(tcp_server->logger, "handling packet id %d for %d", c_id, con_id);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling packet id %u for %u", c_id, con_id);
|
||||
|
||||
if (c_id >= NUM_CLIENT_CONNECTIONS) {
|
||||
return -1;
|
||||
@@ -854,9 +833,7 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int confirm_tcp_connection(TCP_Server *tcp_server, const Mono_Time *mono_time, TCP_Secure_Connection *con,
|
||||
const uint8_t *data, uint16_t length)
|
||||
static int confirm_tcp_connection(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time, TCP_Secure_Connection *_Nonnull con, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
const int index = add_accepted(tcp_server, mono_time, con);
|
||||
|
||||
@@ -882,8 +859,7 @@ static int confirm_tcp_connection(TCP_Server *tcp_server, const Mono_Time *mono_
|
||||
* @return index on success
|
||||
* @retval -1 on failure
|
||||
*/
|
||||
non_null()
|
||||
static int accept_connection(TCP_Server *tcp_server, Socket sock)
|
||||
static int accept_connection(TCP_Server *_Nonnull tcp_server, Socket sock)
|
||||
{
|
||||
if (!sock_valid(sock)) {
|
||||
return -1;
|
||||
@@ -919,8 +895,7 @@ static int accept_connection(TCP_Server *tcp_server, Socket sock)
|
||||
return index;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static Socket new_listening_tcp_socket(const Logger *logger, const Memory *mem, const Network *ns, Family family, uint16_t port)
|
||||
static Socket new_listening_tcp_socket(const Logger *_Nonnull logger, const Memory *_Nonnull mem, const Network *_Nonnull ns, Family family, uint16_t port)
|
||||
{
|
||||
const Socket sock = net_socket(ns, family, TOX_SOCK_STREAM, TOX_PROTO_TCP);
|
||||
|
||||
@@ -1062,8 +1037,7 @@ TCP_Server *new_tcp_server(const Logger *logger, const Memory *mem, const Random
|
||||
}
|
||||
|
||||
#ifndef TCP_SERVER_USE_EPOLL
|
||||
non_null()
|
||||
static void do_tcp_accept_new(TCP_Server *tcp_server)
|
||||
static void do_tcp_accept_new(TCP_Server *_Nonnull tcp_server)
|
||||
{
|
||||
for (uint32_t sock_idx = 0; sock_idx < tcp_server->num_listening_socks; ++sock_idx) {
|
||||
|
||||
@@ -1078,8 +1052,7 @@ static void do_tcp_accept_new(TCP_Server *tcp_server)
|
||||
}
|
||||
#endif /* TCP_SERVER_USE_EPOLL */
|
||||
|
||||
non_null()
|
||||
static int do_incoming(TCP_Server *tcp_server, uint32_t i)
|
||||
static int do_incoming(TCP_Server *_Nonnull tcp_server, uint32_t i)
|
||||
{
|
||||
TCP_Secure_Connection *const conn = &tcp_server->incoming_connection_queue[i];
|
||||
|
||||
@@ -1087,12 +1060,12 @@ static int do_incoming(TCP_Server *tcp_server, uint32_t i)
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling incoming TCP connection %d", i);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling incoming TCP connection %u", i);
|
||||
|
||||
const int ret = read_connection_handshake(tcp_server->logger, conn, tcp_server->secret_key);
|
||||
|
||||
if (ret == -1) {
|
||||
LOGGER_TRACE(tcp_server->logger, "incoming connection %d dropped due to failed handshake", i);
|
||||
LOGGER_TRACE(tcp_server->logger, "incoming connection %u dropped due to failed handshake", i);
|
||||
kill_tcp_secure_connection(conn);
|
||||
return -1;
|
||||
}
|
||||
@@ -1106,7 +1079,7 @@ static int do_incoming(TCP_Server *tcp_server, uint32_t i)
|
||||
TCP_Secure_Connection *conn_new = &tcp_server->unconfirmed_connection_queue[index_new];
|
||||
|
||||
if (conn_new->status != TCP_STATUS_NO_STATUS) {
|
||||
LOGGER_ERROR(tcp_server->logger, "incoming connection %d would overwrite existing", i);
|
||||
LOGGER_ERROR(tcp_server->logger, "incoming connection %u would overwrite existing", i);
|
||||
kill_tcp_secure_connection(conn_new);
|
||||
}
|
||||
|
||||
@@ -1116,8 +1089,7 @@ static int do_incoming(TCP_Server *tcp_server, uint32_t i)
|
||||
return index_new;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int do_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_time, uint32_t i)
|
||||
static int do_unconfirmed(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time, uint32_t i)
|
||||
{
|
||||
TCP_Secure_Connection *const conn = &tcp_server->unconfirmed_connection_queue[i];
|
||||
|
||||
@@ -1125,7 +1097,7 @@ static int do_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_time, ui
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOGGER_TRACE(tcp_server->logger, "handling unconfirmed TCP connection %d", i);
|
||||
LOGGER_TRACE(tcp_server->logger, "handling unconfirmed TCP connection %u", i);
|
||||
|
||||
uint8_t packet[MAX_PACKET_SIZE];
|
||||
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet,
|
||||
@@ -1143,15 +1115,14 @@ static int do_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_time, ui
|
||||
return confirm_tcp_connection(tcp_server, mono_time, conn, packet, len);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool tcp_process_secure_packet(TCP_Server *tcp_server, uint32_t i)
|
||||
static bool tcp_process_secure_packet(TCP_Server *_Nonnull tcp_server, uint32_t i)
|
||||
{
|
||||
TCP_Secure_Connection *const conn = &tcp_server->accepted_connection_array[i];
|
||||
|
||||
uint8_t packet[MAX_PACKET_SIZE];
|
||||
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet,
|
||||
sizeof(packet), &conn->con.ip_port);
|
||||
LOGGER_TRACE(tcp_server->logger, "processing packet for %d: %d", i, len);
|
||||
LOGGER_TRACE(tcp_server->logger, "processing packet for %u: %d", i, len);
|
||||
|
||||
if (len == 0) {
|
||||
return false;
|
||||
@@ -1163,7 +1134,7 @@ static bool tcp_process_secure_packet(TCP_Server *tcp_server, uint32_t i)
|
||||
}
|
||||
|
||||
if (handle_tcp_packet(tcp_server, i, packet, len) == -1) {
|
||||
LOGGER_TRACE(tcp_server->logger, "dropping connection %d: data packet (len=%d) not handled", i, len);
|
||||
LOGGER_TRACE(tcp_server->logger, "dropping connection %u: data packet (len=%d) not handled", i, len);
|
||||
kill_accepted(tcp_server, i);
|
||||
return false;
|
||||
}
|
||||
@@ -1171,8 +1142,7 @@ static bool tcp_process_secure_packet(TCP_Server *tcp_server, uint32_t i)
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void do_confirmed_recv(TCP_Server *tcp_server, uint32_t i)
|
||||
static void do_confirmed_recv(TCP_Server *_Nonnull tcp_server, uint32_t i)
|
||||
{
|
||||
while (tcp_process_secure_packet(tcp_server, i)) {
|
||||
/* Keep reading until an error occurs or there is no more data to read. */
|
||||
@@ -1180,16 +1150,14 @@ static void do_confirmed_recv(TCP_Server *tcp_server, uint32_t i)
|
||||
}
|
||||
|
||||
#ifndef TCP_SERVER_USE_EPOLL
|
||||
non_null()
|
||||
static void do_tcp_incoming(TCP_Server *tcp_server)
|
||||
static void do_tcp_incoming(TCP_Server *_Nonnull tcp_server)
|
||||
{
|
||||
for (uint32_t i = 0; i < MAX_INCOMING_CONNECTIONS; ++i) {
|
||||
do_incoming(tcp_server, i);
|
||||
}
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void do_tcp_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
|
||||
static void do_tcp_unconfirmed(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time)
|
||||
{
|
||||
for (uint32_t i = 0; i < MAX_INCOMING_CONNECTIONS; ++i) {
|
||||
do_unconfirmed(tcp_server, mono_time, i);
|
||||
@@ -1197,8 +1165,7 @@ static void do_tcp_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_tim
|
||||
}
|
||||
#endif /* TCP_SERVER_USE_EPOLL */
|
||||
|
||||
non_null()
|
||||
static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
|
||||
static void do_tcp_confirmed(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time)
|
||||
{
|
||||
#ifdef TCP_SERVER_USE_EPOLL
|
||||
|
||||
@@ -1255,8 +1222,7 @@ static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
|
||||
}
|
||||
|
||||
#ifdef TCP_SERVER_USE_EPOLL
|
||||
non_null()
|
||||
static bool tcp_epoll_process(TCP_Server *tcp_server, const Mono_Time *mono_time)
|
||||
static bool tcp_epoll_process(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time)
|
||||
{
|
||||
#define MAX_EVENTS 16
|
||||
struct epoll_event events[MAX_EVENTS];
|
||||
@@ -1381,8 +1347,7 @@ static bool tcp_epoll_process(TCP_Server *tcp_server, const Mono_Time *mono_time
|
||||
return nfds > 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void do_tcp_epoll(TCP_Server *tcp_server, const Mono_Time *mono_time)
|
||||
static void do_tcp_epoll(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time)
|
||||
{
|
||||
while (tcp_epoll_process(tcp_server, mono_time)) {
|
||||
// Keep processing packets until there are no more FDs ready for reading.
|
||||
|
Reference in New Issue
Block a user