agent: avoid double SSL_free(), SSL_shutdown() only when needed

This commit is contained in:
2019-01-24 00:16:29 +02:00
parent f7f02899b3
commit d4a222ef6d

View File

@@ -83,7 +83,8 @@ static void signal_handler(int sig)
static void agent_shutdown(void)
{
printf("Shutting down agent...\n");
if (ssl) SSL_shutdown(ssl);
if (ssl && !SSL_get_shutdown(ssl))
SSL_shutdown(ssl);
if (ssl) SSL_free(ssl);
if (ctx) SSL_CTX_free(ctx); /* release context */
close(server); /* close socket */
@@ -283,9 +284,6 @@ int main(int count, char *strings[])
memcpy(&args[index].buf, &buf, sizeof(struct msg_t));
}
}
SSL_shutdown(ssl);
SSL_free(ssl); /* release connection state */
} while (bytes);
if (SSL_get_shutdown(ssl)) {
printf("RMPS server has shutdown, trying to reconnect...\n");