common: check for term in force send and recv
This commit is contained in:
parent
ded462ab8e
commit
2893fefc91
@ -249,6 +249,18 @@ trans_send_waiting(struct trans *self, int block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (block)
|
||||||
|
{
|
||||||
|
/* check for term here */
|
||||||
|
if (self->is_term != 0)
|
||||||
|
{
|
||||||
|
if (self->is_term())
|
||||||
|
{
|
||||||
|
/* term */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -412,6 +424,7 @@ trans_check_wait_objs(struct trans *self)
|
|||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int APP_CC
|
int APP_CC
|
||||||
trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
||||||
@ -422,7 +435,6 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
{
|
{
|
||||||
/* make sure stream has room */
|
/* make sure stream has room */
|
||||||
@ -430,26 +442,13 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (self->trans_can_recv(self, self->sck, 100))
|
||||||
|
{
|
||||||
rcvd = self->trans_recv(self, in_s->end, size);
|
rcvd = self->trans_recv(self, in_s->end, size);
|
||||||
|
|
||||||
if (rcvd == -1)
|
if (rcvd == -1)
|
||||||
{
|
{
|
||||||
if (g_tcp_last_error_would_block(self->sck))
|
if (g_tcp_last_error_would_block(self->sck))
|
||||||
{
|
{
|
||||||
if (!g_sck_can_recv(self->sck, 100))
|
|
||||||
{
|
|
||||||
/* check for term here */
|
|
||||||
if (self->is_term != 0)
|
|
||||||
{
|
|
||||||
if (self->is_term())
|
|
||||||
{
|
|
||||||
/* term */
|
|
||||||
self->status = TRANS_STATUS_DOWN;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -470,7 +469,20 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
|||||||
size -= rcvd;
|
size -= rcvd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* check for term here */
|
||||||
|
if (self->is_term != 0)
|
||||||
|
{
|
||||||
|
if (self->is_term())
|
||||||
|
{
|
||||||
|
/* term */
|
||||||
|
self->status = TRANS_STATUS_DOWN;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,37 +505,22 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = (int) (out_s->end - out_s->data);
|
size = (int) (out_s->end - out_s->data);
|
||||||
total = 0;
|
total = 0;
|
||||||
|
|
||||||
if (trans_send_waiting(self, 1) != 0)
|
if (trans_send_waiting(self, 1) != 0)
|
||||||
{
|
{
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (total < size)
|
while (total < size)
|
||||||
|
{
|
||||||
|
if (g_tcp_can_send(self->sck, 100))
|
||||||
{
|
{
|
||||||
sent = self->trans_send(self, out_s->data + total, size - total);
|
sent = self->trans_send(self, out_s->data + total, size - total);
|
||||||
|
|
||||||
if (sent == -1)
|
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))
|
|
||||||
{
|
|
||||||
/* check for term here */
|
|
||||||
if (self->is_term != 0)
|
|
||||||
{
|
|
||||||
if (self->is_term())
|
|
||||||
{
|
|
||||||
/* term */
|
|
||||||
self->status = TRANS_STATUS_DOWN;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -543,7 +540,20 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
|
|||||||
total = total + sent;
|
total = total + sent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* check for term here */
|
||||||
|
if (self->is_term != 0)
|
||||||
|
{
|
||||||
|
if (self->is_term())
|
||||||
|
{
|
||||||
|
/* term */
|
||||||
|
self->status = TRANS_STATUS_DOWN;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,6 +883,7 @@ trans_get_out_s(struct trans *self, int size)
|
|||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* returns error */
|
/* returns error */
|
||||||
int APP_CC
|
int APP_CC
|
||||||
@ -898,6 +909,7 @@ trans_set_tls_mode(struct trans *self, const char *key, const char *cert)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* returns error */
|
/* returns error */
|
||||||
int APP_CC
|
int APP_CC
|
||||||
|
Loading…
Reference in New Issue
Block a user