From 20557e8ce482fbb31aab890950b6bb058fcfec9c Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 17 Aug 2023 16:54:33 +0000 Subject: [PATCH] Respond better when somebody disconnects from us with a tunnel. Trying to robustify tunnels. This is largely untested. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4407 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.rpc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 55f64264..9fd3995f 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -281,7 +281,23 @@ typedef struct tunnel_t void _tf_ssb_rpc_tunnel_callback(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data) { tunnel_t* tun = user_data; - tf_ssb_connection_rpc_send(tun->connection, flags, tun->request_number, message, size, NULL, NULL, NULL); + if (flags & k_ssb_rpc_flag_end_error) + { + tf_ssb_connection_rpc_send( + connection, + flags, + -request_number, + (const uint8_t*)"false", + strlen("false"), + NULL, + NULL, + NULL); + tf_ssb_connection_close(tun->connection); + } + else + { + tf_ssb_connection_rpc_send(tun->connection, flags, tun->request_number, message, size, NULL, NULL, NULL); + } } void _tf_ssb_rpc_tunnel_cleanup(tf_ssb_t* ssb, void* user_data)