Skip to content

Commit

Permalink
Fixes #1563: Delete corresponding connections optionally on deletion …
Browse files Browse the repository at this point in the history
…of tcpListener and tcpConnector
  • Loading branch information
ganeshmurthy committed Aug 26, 2024
1 parent eb3c6d0 commit 31c72f6
Show file tree
Hide file tree
Showing 8 changed files with 1,271 additions and 114 deletions.
7 changes: 7 additions & 0 deletions python/skupper_router/management/skrouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,13 @@
"required": false,
"default": "auto",
"create": true
},
"dropTcpConnections": {
"type": "boolean",
"default": false,
"description": "Terminate corresponding TCP connections when a tcpListener or a tcpConnector is deleted.",
"required": false,
"create": true
}
}
},
Expand Down
359 changes: 254 additions & 105 deletions src/adaptors/tcp/tcp_adaptor.c

Large diffs are not rendered by default.

31 changes: 23 additions & 8 deletions src/adaptors/tcp/tcp_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@
#include <proton/event.h>
#include <proton/ssl.h>

typedef struct qd_tcp_listener_t qd_tcp_listener_t;
typedef struct qd_tcp_connector_t qd_tcp_connector_t;
typedef struct qdr_tcp_stats_t qdr_tcp_stats_t;
typedef struct qd_tcp_adaptor_config_t qd_tcp_adaptor_config_t;
typedef struct qd_adaptor_listener_t qd_adaptor_listener_t;
typedef struct qd_tls_domain_t qd_tls_domain_t;

typedef struct qd_tcp_listener_t qd_tcp_listener_t;
typedef struct qd_tcp_connector_t qd_tcp_connector_t;
typedef struct qdr_tcp_stats_t qdr_tcp_stats_t;
typedef struct qd_tcp_adaptor_config_t qd_tcp_adaptor_config_t;
typedef struct qd_adaptor_listener_t qd_adaptor_listener_t;
typedef struct qd_tls_domain_t qd_tls_domain_t;
typedef struct qdr_tcp_connection_t qdr_tcp_connection_t;
typedef struct qdr_tcp_connection_ref_t qdr_tcp_connection_ref_t;
struct qd_tcp_adaptor_config_t {
qd_adaptor_config_t *adaptor_config; // Pointer to the common adaptor config used by all adaptors.
sys_atomic_t ref_count;
};

ALLOC_DECLARE(qd_tcp_adaptor_config_t);
ALLOC_DECLARE_SAFE(qdr_tcp_connection_t);
ALLOC_DECLARE(qdr_tcp_connection_ref_t);
DEQ_DECLARE(qdr_tcp_connection_t, qdr_tcp_connection_list_t);

struct qdr_tcp_stats_t {
// run time statistics updated by connections
Expand All @@ -72,7 +76,9 @@ struct qd_tcp_listener_t
qdr_tcp_stats_t *tcp_stats;
qd_adaptor_listener_t *adaptor_listener;
qd_tls_domain_t *tls_domain;

sys_mutex_t lock;
qdr_tcp_connection_list_t connections;
sys_atomic_t closing;
// must hold tcp_adaptor->listener_lock during list operations:
DEQ_LINKS(qd_tcp_listener_t);
};
Expand All @@ -90,12 +96,21 @@ struct qd_tcp_connector_t
vflow_record_t *vflow;
qdr_tcp_stats_t *tcp_stats;
qd_tls_domain_t *tls_domain;
sys_mutex_t lock;
qdr_tcp_connection_list_t connections;
sys_atomic_t closing;
DEQ_LINKS(qd_tcp_connector_t);
};

DEQ_DECLARE(qd_tcp_connector_t, qd_tcp_connector_list_t);
ALLOC_DECLARE(qd_tcp_connector_t);

struct qdr_tcp_connection_ref_t {
DEQ_LINKS(qdr_tcp_connection_ref_t);
qdr_tcp_connection_t *conn;
};
DEQ_DECLARE(qdr_tcp_connection_ref_t, qdr_tcp_connection_ref_list_t);

void qdra_tcp_connection_get_first_CT(qdr_core_t *core, qdr_query_t *query, int offset);
void qdra_tcp_connection_get_next_CT(qdr_core_t *core, qdr_query_t *query);
void qdra_tcp_connection_get_CT(qdr_core_t *core,
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ qd_error_t qd_dispatch_configure_router(qd_dispatch_t *qd, qd_entity_t *entity)
qd->timestamps_in_utc = qd_entity_opt_bool(entity, "timestampsInUTC", false); QD_ERROR_RET();
qd->timestamp_format = qd_entity_opt_string(entity, "timestampFormat", 0); QD_ERROR_RET();
qd->metadata = qd_entity_opt_string(entity, "metadata", 0); QD_ERROR_RET();

qd->terminate_tcp_conns = qd_entity_opt_bool(entity, "dropTcpConnections", false); QD_ERROR_RET();
if (! qd->sasl_config_path) {
qd->sasl_config_path = qd_entity_opt_string(entity, "saslConfigDir", 0); QD_ERROR_RET();
}
Expand Down
1 change: 1 addition & 0 deletions src/dispatch_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct qd_dispatch_t {
char *metadata;
bool timestamps_in_utc;
char *data_connection_count;
bool terminate_tcp_conns;
};

qd_dispatch_t *qd_dispatch_get_dispatch(void);
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ foreach(py_test_module
system_tests_http1_over_tcp
system_tests_tcp_adaptor
system_tests_tcp_adaptor_tls
system_tests_tcp_conns_terminate
system_tests_tcp_half_close
system_tests_http2_tls
system_tests_address_watch
Expand Down
Loading

0 comments on commit 31c72f6

Please sign in to comment.