diff --git a/src/ssb.c b/src/ssb.c index 9994aee7..ce82bdfa 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -785,6 +785,14 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou return false; } +void tf_ssb_close_all(tf_ssb_t* ssb) +{ + for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next) + { + _tf_ssb_connection_close(connection, "tf_ssb_close_all"); + } +} + void tf_ssb_send_close(tf_ssb_t* ssb) { for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next) diff --git a/src/ssb.h b/src/ssb.h index fc7a707a..1b6d41f9 100644 --- a/src/ssb.h +++ b/src/ssb.h @@ -97,6 +97,7 @@ void tf_ssb_connect_str(tf_ssb_t* ssb, const char* address); void tf_ssb_server_open(tf_ssb_t* ssb, int port); void tf_ssb_server_close(tf_ssb_t* ssb); +void tf_ssb_close_all(tf_ssb_t* ssb); void tf_ssb_send_close(tf_ssb_t* ssb); bool tf_ssb_id_str_to_bin(uint8_t* bin, const char* str); diff --git a/src/ssb.tests.c b/src/ssb.tests.c index 4db08cd4..28d7db0b 100644 --- a/src/ssb.tests.c +++ b/src/ssb.tests.c @@ -441,15 +441,26 @@ void tf_ssb_test_rooms(const tf_test_options_t* options) printf("Done.\n"); + uv_run(&loop, UV_RUN_NOWAIT); + tf_ssb_connection_close(tun0); - tf_ssb_send_close(ssb0); - tf_ssb_send_close(ssb1); - tf_ssb_send_close(ssb2); + + uv_run(&loop, UV_RUN_NOWAIT); uv_close((uv_handle_t*)&idle0, NULL); uv_close((uv_handle_t*)&idle1, NULL); uv_close((uv_handle_t*)&idle2, NULL); + tf_ssb_send_close(ssb0); + tf_ssb_send_close(ssb1); + tf_ssb_send_close(ssb2); + + tf_ssb_close_all(ssb0); + tf_ssb_close_all(ssb1); + tf_ssb_close_all(ssb2); + + uv_run(&loop, UV_RUN_DEFAULT); + tf_ssb_destroy(ssb0); tf_ssb_destroy(ssb1); tf_ssb_destroy(ssb2);