mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-30 08:03:49 +00:00
Improve monitor CLI client error handling
This commit is contained in:
parent
cfc16e8e87
commit
21125bc9bc
@ -172,12 +172,12 @@ int monitor_client_read(int fd, struct monitor_state *res, struct monitor_comman
|
|||||||
if (res->bufferBytes==0)
|
if (res->bufferBytes==0)
|
||||||
res->cmd = (char *)res->buffer;
|
res->cmd = (char *)res->buffer;
|
||||||
|
|
||||||
int bytesRead=read(fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset);
|
int bytesRead = read(fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset);
|
||||||
if (bytesRead<1){
|
if (bytesRead == -1){
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case ENOTRECOVERABLE:
|
case ENOTRECOVERABLE:
|
||||||
/* transient errors */
|
/* transient errors */
|
||||||
WHY_perror("read");
|
break;
|
||||||
case EINTR:
|
case EINTR:
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||||
@ -185,7 +185,10 @@ int monitor_client_read(int fd, struct monitor_state *res, struct monitor_comman
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
WHY_perror("read");
|
WHYF_perror("read(%d, %p, %ld)", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset);
|
||||||
|
return -1;
|
||||||
|
} else if (bytesRead == 0) {
|
||||||
|
WHYF("read(%d, %p, %ld) returned %d", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset, bytesRead);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
res->bufferBytes+=bytesRead;
|
res->bufferBytes+=bytesRead;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user