mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
tcptls.c: refactor client connection to be more robust
The current TCP client connect code, blocks and does not handle EINTR error case. This patch makes the client socket non-blocking while connecting, ensures a connect does not immediately fail due to EINTR "errors", and adds a connect timeout option. The original client start call sets the new timeout option to "infinite", thus making sure old, orginal behavior is retained. ASTERISK-29746 #close Change-Id: I907571843a83e43c0742b95a64785f4411f02671
This commit is contained in:
committed by
Friendly Automation
parent
584118c7f0
commit
935b8cb04e
@@ -164,8 +164,30 @@ struct ast_tcptls_session_instance {
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief attempts to connect and start tcptls session, on error the tcptls_session's
|
||||
* ref count is decremented, fd and file are closed, and NULL is returned.
|
||||
* \brief Attempt to connect and start a tcptls session within the given timeout
|
||||
*
|
||||
* \note On error the tcptls_session's ref count is decremented, fd and file
|
||||
* are closed, and NULL is returned.
|
||||
*
|
||||
* \param tcptls_session The session instance to connect and start
|
||||
* \param timeout How long (in milliseconds) to attempt to connect (-1 equals infinite)
|
||||
*
|
||||
* \return The tcptls_session, or NULL on error
|
||||
*/
|
||||
struct ast_tcptls_session_instance *ast_tcptls_client_start_timeout(
|
||||
struct ast_tcptls_session_instance *tcptls_session, int timeout);
|
||||
|
||||
/*!
|
||||
* \brief Attempt to connect and start a tcptls session
|
||||
*
|
||||
* Blocks until a connection is established, or an error occurs.
|
||||
*
|
||||
* \note On error the tcptls_session's ref count is decremented, fd and file
|
||||
* are closed, and NULL is returned.
|
||||
*
|
||||
* \param tcptls_session The session instance to connect and start
|
||||
*
|
||||
* \return The tcptls_session, or NULL on error
|
||||
*/
|
||||
struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session);
|
||||
|
||||
|
Reference in New Issue
Block a user