fix an issue with errors and new read() code on interface
git-svn-id: https://svn.musicpd.org/mpd/trunk@2683 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
469a5824b8
commit
a809094bc3
|
@ -24,6 +24,7 @@
|
||||||
#include "listen.h"
|
#include "listen.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "permission.h"
|
#include "permission.h"
|
||||||
|
#include "sig_handlers.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -323,12 +324,16 @@ static int processBytesRead(Interface * interface, int bytesRead) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int interfaceReadInput(Interface * interface) {
|
int interfaceReadInput(Interface * interface) {
|
||||||
int bytesRead = read(interface->fd,
|
int bytesRead;
|
||||||
|
|
||||||
|
bytesRead = read(interface->fd,
|
||||||
interface->buffer+interface->bufferLength,
|
interface->buffer+interface->bufferLength,
|
||||||
INTERFACE_MAX_BUFFER_LENGTH-interface->bufferLength);
|
INTERFACE_MAX_BUFFER_LENGTH-interface->bufferLength);
|
||||||
|
|
||||||
if(bytesRead > 0) return processBytesRead(interface, bytesRead);
|
if(bytesRead > 0) return processBytesRead(interface, bytesRead);
|
||||||
else if(bytesRead == 0 && errno!=EINTR) closeInterface(interface);
|
else if(bytesRead == 0 || (bytesRead < 0 && errno != EINTR)) {
|
||||||
|
closeInterface(interface);
|
||||||
|
}
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue