transport: added function to get bytes written

added function to get written bytes on transport.
This is needed to get a more accurate bandwidth
management.
This commit is contained in:
Martin Haimberger 2015-04-14 03:49:01 -07:00
parent 951a40b639
commit 9c0d275548
4 changed files with 14 additions and 0 deletions

View File

@ -275,6 +275,8 @@ FREERDP_API const char* freerdp_get_last_error_name(UINT32 error);
FREERDP_API const char* freerdp_get_last_error_string(UINT32 error);
FREERDP_API void freerdp_set_last_error(rdpContext* context, UINT32 lastError);
FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount);
#ifdef __cplusplus
}
#endif

View File

@ -697,3 +697,10 @@ void freerdp_free(freerdp* instance)
free(instance);
}
}
FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount) {
ULONG written = context->rdp->transport->written;
if (resetCount)
context->rdp->transport->written = 0;
return written;
}

View File

@ -576,10 +576,12 @@ int transport_write(rdpTransport* transport, wStream* s)
{
int length;
int status = -1;
int writtenlength = 0;
EnterCriticalSection(&(transport->WriteLock));
length = Stream_GetPosition(s);
writtenlength = length;
Stream_SetPosition(s, 0);
if (length > 0)
@ -637,8 +639,10 @@ int transport_write(rdpTransport* transport, wStream* s)
length -= status;
Stream_Seek(s, status);
}
transport->written += writtenlength;
out_cleanup:
if (status < 0)
{
/* A write error indicates that the peer has dropped the connection */

View File

@ -76,6 +76,7 @@ struct rdp_transport
BOOL GatewayEnabled;
CRITICAL_SECTION ReadLock;
CRITICAL_SECTION WriteLock;
ULONG written;
};
wStream* transport_send_stream_init(rdpTransport* transport, int size);