You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.2 KiB

#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_UASYNC, "=== Simple Corruption Test ===");
// Create just one socket
int sock = socket(AF_INET, SOCK_DGRAM, 0);
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Created socket with fd=%d", sock);
void* id = uasync_add_socket(ua, sock, test_callback, NULL, NULL, NULL);
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "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_UASYNC, "Node fd after add: %d", sock);
// Try to remove immediately (no polling)
int result = uasync_remove_socket(ua, id);
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Remove result: %d", result);
close(sock);
uasync_destroy(ua, 0);
return 0;
}