aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-16 01:41:05 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-16 01:41:05 +0000
commita809094bc350e8969ac734668fc983efba46ab94 (patch)
treec4e2bc1ec05dd110d5a7dd70292f700520b24ed2
parent469a5824b80427f2672b1adcbb4b42fec542639e (diff)
downloadmpd-a809094bc350e8969ac734668fc983efba46ab94.tar.gz
mpd-a809094bc350e8969ac734668fc983efba46ab94.tar.xz
mpd-a809094bc350e8969ac734668fc983efba46ab94.zip
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
-rw-r--r--src/interface.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/interface.c b/src/interface.c
index 110e3e475..9cb256725 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -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;