- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#include "../lib/u_async.h"
|
|
#include "../lib/debug_config.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "../lib/platform_compat.h"
|
|
|
|
|
|
|
|
static void test_callback(int fd, void* arg) {
|
|
(void)fd; (void)arg;
|
|
}
|
|
|
|
int main() {
|
|
debug_config_init();
|
|
debug_set_level(DEBUG_LEVEL_TRACE);
|
|
debug_set_categories(DEBUG_CATEGORY_ALL);
|
|
|
|
uasync_t* ua = uasync_create();
|
|
if (!ua) return 1;
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_SYS, "=== Simple Corruption Test ===");
|
|
|
|
// Create just one socket
|
|
int sock = socket(AF_INET, SOCK_DGRAM, 0);
|
|
DEBUG_INFO(DEBUG_CATEGORY_SYS, "Created socket with fd=%d", sock);
|
|
|
|
void* id = uasync_add_socket(ua, sock, test_callback, NULL, NULL, NULL);
|
|
DEBUG_INFO(DEBUG_CATEGORY_SYS, "Added socket: fd=%d, id=%p", sock, id);
|
|
|
|
// Check if fd is still correct (internal struct socket_node not exposed)
|
|
// struct socket_node* node = (struct socket_node*)id;
|
|
DEBUG_INFO(DEBUG_CATEGORY_SYS, "Node fd after add: %d", sock);
|
|
|
|
// Try to remove immediately (no polling)
|
|
int result = uasync_remove_socket(ua, id);
|
|
DEBUG_INFO(DEBUG_CATEGORY_SYS, "Remove result: %d", result);
|
|
|
|
close(sock);
|
|
uasync_destroy(ua, 0);
|
|
|
|
return 0;
|
|
}
|