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:
Warren Dukes 2004-11-16 01:41:05 +00:00
parent 469a5824b8
commit a809094bc3
1 changed files with 8 additions and 3 deletions

View File

@ -24,6 +24,7 @@
#include "listen.h"
#include "playlist.h"
#include "permission.h"
#include "sig_handlers.h"
#include <stdio.h>
#include <stdlib.h>
@ -323,12 +324,16 @@ static int processBytesRead(Interface * interface, int bytesRead) {
}
int interfaceReadInput(Interface * interface) {
int bytesRead = read(interface->fd,
int bytesRead;
bytesRead = read(interface->fd,
interface->buffer+interface->bufferLength,
INTERFACE_MAX_BUFFER_LENGTH-interface->bufferLength);
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;
return 1;