Skip to content

Commit

Permalink
close socket immediately without waiting for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Jan 6, 2025
1 parent f6eb198 commit 3c49f4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/tcp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void handle_new_client(int client_socket, tcp_server *server) {
fprintf(stderr, "<3>[%d] requested out of band frequency: %d\n", server->client_counter, config->band_freq);
pthread_mutex_unlock(&server->mutex);
// this will shutdown the thread
close(tcp_node->config->client_socket);
shutdown(tcp_node->config->client_socket, SHUT_RDWR);
// this one will close any remaning resources
tcp_node_final_cleanup(tcp_node);
return;
Expand Down Expand Up @@ -408,7 +408,7 @@ static void *acceptor_worker(void *arg) {
struct linked_list_tcp_node *cur_node = server->tcp_nodes;
while (cur_node != NULL) {
struct linked_list_tcp_node *next = cur_node->next;
close(cur_node->config->client_socket);
shutdown(cur_node->config->client_socket, SHUT_RDWR);
uint32_t node_id = cur_node->config->id;
while (cur_node->config->is_running) {
pthread_cond_wait(&server->terminated_condition, &server->mutex);
Expand Down
4 changes: 2 additions & 2 deletions test/hackrf_lib_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void* hackrf_worker(void* ctx) {
hackrf_transfer transfer = {
.rx_ctx = ctx,
.device = NULL,
.buffer = hackrf_mock.buffer,
.buffer = (uint8_t *)hackrf_mock.buffer,
.buffer_length = hackrf_mock.len};
hackrf_mock.callback(&transfer);
hackrf_mock.buffer = NULL;
Expand All @@ -64,7 +64,7 @@ const char* hackrf_error_name(enum hackrf_error errcode) {
return "unknown";
}
int hackrf_version_string_read(hackrf_device* device, char* version, uint8_t length) {
snprintf(version, length, "test\0");
snprintf(version, length, "test");
return 0;
}
int hackrf_usb_api_version_read(hackrf_device* device, uint16_t* version) {
Expand Down

0 comments on commit 3c49f4c

Please sign in to comment.