Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion build/build_for_release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
rm -f CMakeCache.txt
rm -rf CMakeFiles
rm -rf cmake
rm -f Makefile
rm -f cmake_install.cmake

cmake ../src -DCMAKE_BUILD_TYPE=Release -DSANITIZER=none
cmake ../src -DCMAKE_BUILD_TYPE=Release -DSANITIZER=none -B .
make -B -j8
5 changes: 4 additions & 1 deletion build/build_for_testing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
rm -f CMakeCache.txt
rm -rf CMakeFiles
rm -rf cmake
rm -f Makefile
rm -f cmake_install.cmake

cmake ../src -DCMAKE_BUILD_TYPE=Debug -DSANITIZER=thread -DSWIFT_NET_INTERNAL_TESTING=ON
cmake ../src -DCMAKE_BUILD_TYPE=Debug -DSANITIZER=thread -DSWIFT_NET_INTERNAL_TESTING=ON -B .
make -B -j8
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ include(GNUInstallDirs)

set(CMAKE_C_STANDARD 99)

option(SWIFT_NET_INTERNAL_TESTING "Enable internal testing features" OFF)

set(SOURCE_FILES
initialize_swiftnet.c
send_packet.c
Expand Down Expand Up @@ -52,6 +50,8 @@ endif()
add_library(swiftnet STATIC ${SOURCE_FILES})
add_library(swiftnet_shared SHARED ${SOURCE_FILES})

option(SWIFT_NET_INTERNAL_TESTING "Enable internal testing" OFF)

if (SWIFT_NET_INTERNAL_TESTING)
message("Internal Testing Enabled")

Expand Down
12 changes: 6 additions & 6 deletions src/cleanup_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ static inline void cleanup_connection_resources(const enum ConnectionType connec
if (connection_type == CONNECTION_TYPE_CLIENT) {
struct SwiftNetClientConnection* const client = (struct SwiftNetClientConnection*)connection;

allocator_destroy(&client->packets_sending_memory_allocator);
allocator_destroy(&client->pending_messages_memory_allocator);
allocator_destroy(&client->packets_completed_memory_allocator);
allocator_destroy(&client->packets_sending_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&client->pending_messages_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&client->packets_completed_memory_allocator DISABLE_INTERNAL_CHECK);

hashmap_destroy(&client->pending_messages);
hashmap_destroy(&client->packets_sending);
hashmap_destroy(&client->packets_completed);
} else {
struct SwiftNetServer* const server = (struct SwiftNetServer*)connection;

allocator_destroy(&server->packets_sending_memory_allocator);
allocator_destroy(&server->pending_messages_memory_allocator);
allocator_destroy(&server->packets_completed_memory_allocator);
allocator_destroy(&server->packets_sending_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&server->pending_messages_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&server->packets_completed_memory_allocator DISABLE_INTERNAL_CHECK);

hashmap_destroy(&server->pending_messages);
hashmap_destroy(&server->packets_sending);
Expand Down
26 changes: 13 additions & 13 deletions src/cleanup_swiftnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ static inline void close_background_service() {
}

void swiftnet_cleanup() {
allocator_destroy(&packet_queue_node_memory_allocator);
allocator_destroy(&packet_callback_queue_node_memory_allocator);
allocator_destroy(&server_packet_data_memory_allocator);
allocator_destroy(&client_packet_data_memory_allocator);
allocator_destroy(&packet_buffer_memory_allocator);
allocator_destroy(&hashmap_item_memory_allocator);
allocator_destroy(&packet_queue_node_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&packet_callback_queue_node_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&server_packet_data_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&client_packet_data_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&packet_buffer_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&hashmap_item_memory_allocator ENABLE_INTERNAL_CHECK);

#ifdef SWIFT_NET_REQUESTS
allocator_destroy(&requests_sent_memory_allocator);
allocator_destroy(&requests_sent_memory_allocator ENABLE_INTERNAL_CHECK);

hashmap_destroy(&requests_sent);
#endif

close_listeners();

allocator_destroy(&server_memory_allocator);
allocator_destroy(&client_connection_memory_allocator);
allocator_destroy(&server_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&client_connection_memory_allocator ENABLE_INTERNAL_CHECK);

allocator_destroy(&listener_memory_allocator);
allocator_destroy(&uint16_memory_allocator);
allocator_destroy(&packet_completed_key_allocator);
allocator_destroy(&pending_message_key_allocator);
allocator_destroy(&listener_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&uint16_memory_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&packet_completed_key_allocator ENABLE_INTERNAL_CHECK);
allocator_destroy(&pending_message_key_allocator ENABLE_INTERNAL_CHECK);

#ifdef SWIFT_NET_INTERNAL_TESTING
printf("Bytes leaked: %d\nItems leaked: %d\n", bytes_leaked, items_leaked);
Expand Down
Loading
Loading