Skip to content

Commit

Permalink
Merge pull request FreeRDP#2538 from MartinHaimberger/mh-add-transpor…
Browse files Browse the repository at this point in the history
…t-get-bytes

transport: added function to get bytes written
  • Loading branch information
bmiklautz committed Apr 20, 2015
2 parents 5622b91 + 9c0d275 commit 12e256b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/freerdp/freerdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions libfreerdp/core/freerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions libfreerdp/core/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions libfreerdp/core/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 12e256b

Please sign in to comment.