Stop watching debugger file descriptor as soon as there is a read error.

[GB.DEBUG]
* BUG: Stop watching debugger file descriptor as soon as there is a read error.
This commit is contained in:
gambas 2021-02-06 17:05:03 +01:00
parent eb467786fe
commit ab74b3195d

View file

@ -61,19 +61,21 @@ static void callback_read(int fd, int type, intptr_t param)
if (_buffer_left) if (_buffer_left)
{ {
n = read(_fdr, &_buffer[_buffer_left], BUFFER_SIZE - _buffer_left); n = read(_fdr, &_buffer[_buffer_left], BUFFER_SIZE - _buffer_left);
if (n < 0) if (n > 0)
n = 0; {
n += _buffer_left; n += _buffer_left;
_buffer_left = 0; _buffer_left = 0;
} }
}
else else
n = read(_fdr, _buffer, BUFFER_SIZE); n = read(_fdr, _buffer, BUFFER_SIZE);
if (n <= 0) if (n <= 0)
{ {
//usleep(10000); // the callback is called again and again even if there is nothing to read, why? if (n == 0 || (errno != EINTR && errno != EAGAIN))
break; GB.Watch(fd, GB_WATCH_NONE, (void *)callback_read, 0);
break; // try again
} }
p = 0; p = 0;