common: call recv/send before can_recv/can_send
This commit is contained in:
parent
bd6c38af4d
commit
0655272b9c
@ -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))
|
||||
if (!self->trans_can_recv(self, 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 (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;
|
||||
|
Loading…
Reference in New Issue
Block a user