[core,transport] document and fix transport_attach
* [transport_default_attach] Only attach provided socket once the function can no longer fail * [transport_attach] document behaviour
This commit is contained in:
parent
3c2c6cc1d5
commit
4b2d877bf3
@ -197,8 +197,6 @@ static BOOL transport_default_attach(rdpTransport* transport, int sockfd)
|
||||
|
||||
if (!socketBio)
|
||||
goto fail;
|
||||
|
||||
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
|
||||
}
|
||||
|
||||
bufferedBio = BIO_new(BIO_s_buffered_socket());
|
||||
@ -206,8 +204,18 @@ static BOOL transport_default_attach(rdpTransport* transport, int sockfd)
|
||||
goto fail;
|
||||
|
||||
if (socketBio)
|
||||
{
|
||||
bufferedBio = BIO_push(bufferedBio, socketBio);
|
||||
WINPR_ASSERT(bufferedBio);
|
||||
if (!bufferedBio)
|
||||
goto fail;
|
||||
|
||||
/* Attach the socket only when this function can no longer fail.
|
||||
* This ensures solid ownership:
|
||||
* - if this function fails, the caller is responsible to clean up
|
||||
* - if this function is successful, the caller MUST NOT close the socket any more.
|
||||
*/
|
||||
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
|
||||
}
|
||||
transport->frontBio = bufferedBio;
|
||||
return TRUE;
|
||||
fail:
|
||||
|
@ -58,6 +58,21 @@ FREERDP_LOCAL wStream* transport_send_stream_init(rdpTransport* transport, size_
|
||||
FREERDP_LOCAL BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port,
|
||||
DWORD timeout);
|
||||
FREERDP_LOCAL BOOL transport_connect_childsession(rdpTransport* transport);
|
||||
|
||||
/**! \brief Attach a socket to the transport layer
|
||||
*
|
||||
* The ownership of the socket provided by \b sockfd is taken if and only if the function is
|
||||
* successful. In such a case the caller must no longer close or otherwise use the socket. If the
|
||||
* function fails it is up to the caller to close the socket.
|
||||
*
|
||||
* The implementation can be overridden by
|
||||
* transport_set_io_callbacks(rdpTransportIo::TransportAttach)
|
||||
*
|
||||
* \param transport The transport instance to attach the socket to
|
||||
* \param sockfd The socket to attach to the transport
|
||||
*
|
||||
* \return \b TRUE in case of success, \b FALSE otherwise.
|
||||
*/
|
||||
FREERDP_LOCAL BOOL transport_attach(rdpTransport* transport, int sockfd);
|
||||
FREERDP_LOCAL BOOL transport_disconnect(rdpTransport* transport);
|
||||
FREERDP_LOCAL BOOL transport_connect_rdp(rdpTransport* transport);
|
||||
|
Loading…
Reference in New Issue
Block a user