libfreerdp-core: remove ineffective full duplex locks

This commit is contained in:
Marc-André Moreau 2014-06-01 11:20:13 -04:00
parent 2c8670d7b3
commit a8be174e03
5 changed files with 4 additions and 50 deletions

View File

@ -1612,11 +1612,6 @@ rdpTsg* tsg_new(rdpTransport* transport)
if (!tsg->rpc) if (!tsg->rpc)
goto out_free; goto out_free;
if (!InitializeCriticalSectionAndSpinCount(&(tsg->DuplexLock), 4000))
goto out_free;
tsg->FullDuplex = FALSE;
tsg->PendingPdu = FALSE; tsg->PendingPdu = FALSE;
return tsg; return tsg;
@ -1629,9 +1624,6 @@ void tsg_free(rdpTsg* tsg)
{ {
if (tsg) if (tsg)
{ {
if (!tsg->FullDuplex)
DeleteCriticalSection(&(tsg->DuplexLock));
free(tsg->MachineName); free(tsg->MachineName);
rpc_free(tsg->rpc); rpc_free(tsg->rpc);
free(tsg); free(tsg);

View File

@ -70,8 +70,6 @@ struct rdp_tsg
rdpTransport* transport; rdpTransport* transport;
CONTEXT_HANDLE TunnelContext; CONTEXT_HANDLE TunnelContext;
CONTEXT_HANDLE ChannelContext; CONTEXT_HANDLE ChannelContext;
CRITICAL_SECTION DuplexLock;
BOOL FullDuplex;
}; };
typedef WCHAR* RESOURCENAME; typedef WCHAR* RESOURCENAME;

View File

@ -78,9 +78,6 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num)
int nchunks, committedBytes, i; int nchunks, committedBytes, i;
DataChunk chunks[2]; DataChunk chunks[2];
if (!tcp->fullDuplex)
EnterCriticalSection(&(tcp->duplexLock));
ret = num; ret = num;
tcp->writeBlocked = FALSE; tcp->writeBlocked = FALSE;
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
@ -91,10 +88,6 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num)
if (buf && num && !ringbuffer_write(&tcp->xmitBuffer, (const BYTE*) buf, num)) if (buf && num && !ringbuffer_write(&tcp->xmitBuffer, (const BYTE*) buf, num))
{ {
fprintf(stderr, "%s: an error occured when writing(toWrite=%d)\n", __FUNCTION__, num); fprintf(stderr, "%s: an error occured when writing(toWrite=%d)\n", __FUNCTION__, num);
if (!tcp->fullDuplex)
LeaveCriticalSection(&(tcp->duplexLock));
return -1; return -1;
} }
@ -131,10 +124,6 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num)
out: out:
ringbuffer_commit_read_bytes(&tcp->xmitBuffer, committedBytes); ringbuffer_commit_read_bytes(&tcp->xmitBuffer, committedBytes);
if (!tcp->fullDuplex)
LeaveCriticalSection(&(tcp->duplexLock));
return ret; return ret;
} }
@ -143,9 +132,6 @@ static int transport_bio_buffered_read(BIO* bio, char* buf, int size)
int status; int status;
rdpTcp* tcp = (rdpTcp*) bio->ptr; rdpTcp* tcp = (rdpTcp*) bio->ptr;
if (!tcp->fullDuplex)
EnterCriticalSection(&(tcp->duplexLock));
tcp->readBlocked = FALSE; tcp->readBlocked = FALSE;
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
@ -158,9 +144,6 @@ static int transport_bio_buffered_read(BIO* bio, char* buf, int size)
tcp->readBlocked = TRUE; tcp->readBlocked = TRUE;
} }
if (!tcp->fullDuplex)
LeaveCriticalSection(&(tcp->duplexLock));
return status; return status;
} }
@ -529,8 +512,10 @@ int tcp_attach(rdpTcp* tcp, int sockfd)
if (!tcp->bufferedBio) if (!tcp->bufferedBio)
{ {
tcp->bufferedBio = BIO_new(BIO_s_buffered_socket()); tcp->bufferedBio = BIO_new(BIO_s_buffered_socket());
if (!tcp->bufferedBio) if (!tcp->bufferedBio)
return FALSE; return FALSE;
tcp->bufferedBio->ptr = tcp; tcp->bufferedBio->ptr = tcp;
tcp->bufferedBio = BIO_push(tcp->bufferedBio, tcp->socketBio); tcp->bufferedBio = BIO_push(tcp->bufferedBio, tcp->socketBio);
@ -566,10 +551,8 @@ rdpTcp* tcp_new(rdpSettings* settings)
tcp->sockfd = -1; tcp->sockfd = -1;
tcp->settings = settings; tcp->settings = settings;
if (!InitializeCriticalSectionAndSpinCount(&(tcp->duplexLock), 4000)) if (0)
goto out_ringbuffer; goto out_ringbuffer; /* avoid unreferenced label warning on Windows */
tcp->fullDuplex = FALSE;
#ifndef _WIN32 #ifndef _WIN32
tcp->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, tcp->sockfd); tcp->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, tcp->sockfd);
@ -591,9 +574,6 @@ void tcp_free(rdpTcp* tcp)
if (!tcp) if (!tcp)
return; return;
if (!tcp->fullDuplex)
DeleteCriticalSection(&(tcp->duplexLock));
ringbuffer_destroy(&tcp->xmitBuffer); ringbuffer_destroy(&tcp->xmitBuffer);
CloseHandle(tcp->event); CloseHandle(tcp->event);
free(tcp); free(tcp);

View File

@ -56,10 +56,6 @@ struct rdp_tcp
RingBuffer xmitBuffer; RingBuffer xmitBuffer;
BOOL writeBlocked; BOOL writeBlocked;
BOOL readBlocked; BOOL readBlocked;
BOOL fullDuplex;
CRITICAL_SECTION duplexLock;
HANDLE event; HANDLE event;
}; };

View File

@ -133,9 +133,6 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
tsg = (rdpTsg*) bio->ptr; tsg = (rdpTsg*) bio->ptr;
if (!tsg->FullDuplex)
EnterCriticalSection(&(tsg->DuplexLock));
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
status = tsg_write(tsg, (BYTE*) buf, num); status = tsg_write(tsg, (BYTE*) buf, num);
@ -143,9 +140,6 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
if (status == 0) if (status == 0)
BIO_set_retry_write(bio); BIO_set_retry_write(bio);
if (!tsg->FullDuplex)
LeaveCriticalSection(&(tsg->DuplexLock));
if (status > 0) if (status > 0)
return status; return status;
@ -159,9 +153,6 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
tsg = (rdpTsg*) bio->ptr; tsg = (rdpTsg*) bio->ptr;
if (!tsg->FullDuplex)
EnterCriticalSection(&(tsg->DuplexLock));
status = tsg_read(bio->ptr, (BYTE*) buf, size); status = tsg_read(bio->ptr, (BYTE*) buf, size);
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
@ -176,9 +167,6 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
status = 0; status = 0;
} }
if (!tsg->FullDuplex)
LeaveCriticalSection(&(tsg->DuplexLock));
return status >= 0 ? status : -1; return status >= 0 ? status : -1;
} }