summaryrefslogtreecommitdiffstats
path: root/common/trans.c
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2016-04-06 16:37:34 -0700
committerJay Sorg <jay.sorg@gmail.com>2016-04-06 16:37:34 -0700
commit0655272b9c779203cc6c9fb1f3e051fa0b5af43e (patch)
tree27495c5b4bc9d0a6d3ef5fe80da3c2b1bc7508af /common/trans.c
parentbd6c38af4d3b71118c8a50b293d5eba10d0c7ec0 (diff)
downloadxrdp-proprietary-0655272b9c779203cc6c9fb1f3e051fa0b5af43e.tar.gz
xrdp-proprietary-0655272b9c779203cc6c9fb1f3e051fa0b5af43e.zip
common: call recv/send before can_recv/can_send
Diffstat (limited to 'common/trans.c')
-rw-r--r--common/trans.c96
1 files changed, 45 insertions, 51 deletions
diff --git a/common/trans.c b/common/trans.c
index 2c44f28c..fb939a85 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -442,45 +442,42 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
{
return 1;
}
- if (self->trans_can_recv(self, self->sck, 100))
+ rcvd = self->trans_recv(self, in_s->end, size);
+ if (rcvd == -1)
{
- rcvd = self->trans_recv(self, in_s->end, size);
- if (rcvd == -1)
+ if (g_tcp_last_error_would_block(self->sck))
{
- if (g_tcp_last_error_would_block(self->sck))
- {
- }
- else
+ if (!self->trans_can_recv(self, self->sck, 100))
{
- /* error */
- self->status = TRANS_STATUS_DOWN;
- return 1;
+ /* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
- else if (rcvd == 0)
+ else
{
/* error */
self->status = TRANS_STATUS_DOWN;
return 1;
}
- else
- {
- in_s->end += rcvd;
- size -= rcvd;
- }
+ }
+ else if (rcvd == 0)
+ {
+ /* error */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
}
else
{
- /* check for term here */
- if (self->is_term != 0)
- {
- if (self->is_term())
- {
- /* term */
- self->status = TRANS_STATUS_DOWN;
- return 1;
- }
- }
+ in_s->end += rcvd;
+ size -= rcvd;
}
}
return 0;
@@ -514,44 +511,41 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
}
while (total < size)
{
- if (g_tcp_can_send(self->sck, 100))
+ sent = self->trans_send(self, out_s->data + total, size - total);
+ if (sent == -1)
{
- sent = self->trans_send(self, out_s->data + total, size - total);
- if (sent == -1)
+ if (g_tcp_last_error_would_block(self->sck))
{
- if (g_tcp_last_error_would_block(self->sck))
+ if (!g_tcp_can_send(self->sck, 100))
{
- }
- else
- {
- /* error */
- self->status = TRANS_STATUS_DOWN;
- return 1;
+ /* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
- else if (sent == 0)
+ else
{
/* error */
self->status = TRANS_STATUS_DOWN;
return 1;
}
- else
- {
- total = total + sent;
- }
+ }
+ else if (sent == 0)
+ {
+ /* error */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
}
else
{
- /* check for term here */
- if (self->is_term != 0)
- {
- if (self->is_term())
- {
- /* term */
- self->status = TRANS_STATUS_DOWN;
- return 1;
- }
- }
+ total = total + sent;
}
}
return 0;