mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 05:25:29 +00:00
Added mbedtls_net_close and use it in ssl_fork_server to correctly
disassociate the client socket from the parent process and the server socket from the child process.
This commit is contained in:
parent
beec142010
commit
df8e511381
|
@ -257,6 +257,13 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
|
|||
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
|
||||
uint32_t timeout );
|
||||
|
||||
/**
|
||||
* \brief Closes down the connection and free associated data
|
||||
*
|
||||
* \param ctx The context to close
|
||||
*/
|
||||
void mbedtls_net_close( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Gracefully shutdown the connection and free associated data
|
||||
*
|
||||
|
|
|
@ -651,6 +651,19 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
|
|||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the connection
|
||||
*/
|
||||
void mbedtls_net_close( mbedtls_net_context *ctx )
|
||||
{
|
||||
if( ctx->fd == -1 )
|
||||
return;
|
||||
|
||||
close( ctx->fd );
|
||||
|
||||
ctx->fd = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gracefully close the connection
|
||||
*/
|
||||
|
|
|
@ -254,6 +254,7 @@ int main( void )
|
|||
if( pid != 0 )
|
||||
{
|
||||
mbedtls_printf( " ok\n" );
|
||||
mbedtls_net_close( &client_fd );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_reseed( &ctr_drbg,
|
||||
(const unsigned char *) "parent",
|
||||
|
@ -266,7 +267,7 @@ int main( void )
|
|||
continue;
|
||||
}
|
||||
|
||||
mbedtls_net_init( &listen_fd );
|
||||
mbedtls_net_close( &listen_fd );
|
||||
|
||||
pid = getpid();
|
||||
|
||||
|
|
Loading…
Reference in a new issue