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.
37 lines
955 B
37 lines
955 B
#include "../lib/u_async.h" |
|
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <unistd.h> |
|
#include <sys/socket.h> |
|
#include <fcntl.h> |
|
|
|
static void test_callback(int fd, void* arg) { |
|
(void)fd; (void)arg; |
|
} |
|
|
|
int main() { |
|
uasync_t* ua = uasync_create(); |
|
if (!ua) return 1; |
|
|
|
printf("=== Simple Corruption Test ===\n"); |
|
|
|
// Create just one socket |
|
int sock = socket(AF_INET, SOCK_DGRAM, 0); |
|
printf("Created socket with fd=%d\n", sock); |
|
|
|
void* id = uasync_add_socket(ua, sock, test_callback, NULL, NULL, NULL); |
|
printf("Added socket: fd=%d, id=%p\n", sock, id); |
|
|
|
// Check if fd is still correct |
|
struct socket_node* node = (struct socket_node*)id; |
|
printf("Node fd after add: %d\n", node->fd); |
|
|
|
// Try to remove immediately (no polling) |
|
int result = uasync_remove_socket(ua, id); |
|
printf("Remove result: %d\n", result); |
|
|
|
close(sock); |
|
uasync_destroy(ua, 0); |
|
|
|
return 0; |
|
}
|
|
|