diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-12-17 19:06:28 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-12-17 19:06:28 -0800 |
commit | d1fc67102a273a8e0b170d0c613cf0d611cfa7f8 (patch) | |
tree | 39e1caec71bfb33ee94d7fcf1ba36683262d24ab /xrdpapi | |
parent | 4f6cbfd3fe7041de98537731574e63485a6dcc82 (diff) | |
download | xrdp-proprietary-d1fc67102a273a8e0b170d0c613cf0d611cfa7f8.tar.gz xrdp-proprietary-d1fc67102a273a8e0b170d0c613cf0d611cfa7f8.zip |
xrdpapi: send for all bytes
Diffstat (limited to 'xrdpapi')
-rw-r--r-- | xrdpapi/xrdpapi.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/xrdpapi/xrdpapi.c b/xrdpapi/xrdpapi.c index 610a8078..f35c8210 100644 --- a/xrdpapi/xrdpapi.c +++ b/xrdpapi/xrdpapi.c @@ -155,6 +155,31 @@ WTSVirtualChannelOpenEx(unsigned int SessionId, const char *pVirtualName, return wts; } +/*****************************************************************************/ +static int +mysend(int sck, const void* adata, int bytes) +{ + int sent; + int error; + const char* data; + + data = (char*)adata; + sent = 0; + while (sent < bytes) + { + if (can_send(sck, 100)) + { + error = send(sck, data + sent, bytes - sent, MSG_NOSIGNAL); + if (error < 1) + { + return -1; + } + sent += error; + } + } + return sent; +} + /* * write data to client connection * @@ -189,11 +214,12 @@ WTSVirtualChannelWrite(void *hChannelHandle, const char *Buffer, return 0; /* can't write now, ok to try again */ } + rv = 0; memcpy(header, g_xrdpapi_magic, 12); header[3] = Length; - if (send(wts->fd, header, 16, 0) == 16) + if (mysend(wts->fd, header, 16) == 16) { - rv = send(wts->fd, Buffer, Length, 0); + rv = mysend(wts->fd, Buffer, Length); } else { @@ -201,7 +227,7 @@ WTSVirtualChannelWrite(void *hChannelHandle, const char *Buffer, return -1; } - LLOGLN(10, ("WTSVirtualChannelWrite: send() reted %d", rv)); + LLOGLN(10, ("WTSVirtualChannelWrite: mysend() reted %d", rv)); if (rv >= 0) { |