fix for 100% cpu when socket error
This commit is contained in:
parent
1e8b5ea2cd
commit
368db23061
@ -114,7 +114,7 @@ trans_check_wait_objs(struct trans* self)
|
|||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (in_sck != -1)
|
if (in_sck != -1)
|
||||||
@ -157,14 +157,14 @@ trans_check_wait_objs(struct trans* self)
|
|||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (read_bytes == 0)
|
else if (read_bytes == 0)
|
||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -189,14 +189,12 @@ trans_check_wait_objs(struct trans* self)
|
|||||||
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)
|
||||||
{
|
{
|
||||||
int rv;
|
|
||||||
int rcvd;
|
int rcvd;
|
||||||
|
|
||||||
if (self->status != TRANS_STATUS_UP)
|
if (self->status != TRANS_STATUS_UP)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rv = 0;
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
{
|
{
|
||||||
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
||||||
@ -213,14 +211,14 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
|||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rcvd == 0)
|
else if (rcvd == 0)
|
||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -228,7 +226,7 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
|||||||
size -= rcvd;
|
size -= rcvd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -244,14 +242,12 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
|||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
int total;
|
int total;
|
||||||
int rv;
|
|
||||||
int sent;
|
int sent;
|
||||||
|
|
||||||
if (self->status != TRANS_STATUS_UP)
|
if (self->status != TRANS_STATUS_UP)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rv = 0;
|
|
||||||
size = (int)(out_s->end - out_s->data);
|
size = (int)(out_s->end - out_s->data);
|
||||||
total = 0;
|
total = 0;
|
||||||
while (total < size)
|
while (total < size)
|
||||||
@ -270,21 +266,21 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
|||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sent == 0)
|
else if (sent == 0)
|
||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
self->status = TRANS_STATUS_DOWN;
|
self->status = TRANS_STATUS_DOWN;
|
||||||
rv = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
total = total + sent;
|
total = total + sent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user