aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-14 05:54:00 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-14 05:54:00 +0000
commit42b08abe2f5b356f640dd954831de0f3dad62694 (patch)
treeae76898da894851a02f0431b00a375fb74ba0294 /src
parent86afc13c7e79a484fe8f405820a50f92146705a4 (diff)
downloadmpd-42b08abe2f5b356f640dd954831de0f3dad62694.tar.gz
mpd-42b08abe2f5b356f640dd954831de0f3dad62694.tar.xz
mpd-42b08abe2f5b356f640dd954831de0f3dad62694.zip
fix a few bugs in read()'ing
git-svn-id: https://svn.musicpd.org/mpd/trunk@2650 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/interface.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/interface.c b/src/interface.c
index 56eebc5b5..38316c062 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -43,13 +43,13 @@
#define GREETING "OK MPD"
-#define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024
-#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
-#define INTERFACE_LIST_OK_MODE_BEGIN "command_list_ok_begin"
-#define INTERFACE_LIST_MODE_END "command_list_end"
-#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096
-#define INTERFACE_TIMEOUT_DEFAULT 60
-#define INTERFACE_MAX_CONNECTIONS_DEFAULT 10
+#define INTERFACE_MAX_BUFFER_LENGTH (40960)
+#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
+#define INTERFACE_LIST_OK_MODE_BEGIN "command_list_ok_begin"
+#define INTERFACE_LIST_MODE_END "command_list_end"
+#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE (4096)
+#define INTERFACE_TIMEOUT_DEFAULT (60)
+#define INTERFACE_MAX_CONNECTIONS_DEFAULT (10)
#define INTERFACE_MAX_COMMAND_LIST_DEFAULT (2048*1024)
#define INTERFACE_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (2048*1024)
@@ -309,6 +309,7 @@ static int processBytesRead(Interface * interface, int bytesRead) {
if(interface->bufferPos == 0) {
ERROR("interface %i: buffer overflow\n",
interface->num);
+ closeInterface(interface);
return 1;
}
interface->bufferLength-= interface->bufferPos;
@@ -325,7 +326,7 @@ static int processBytesRead(Interface * interface, int bytesRead) {
int interfaceReadInput(Interface * interface) {
int bytesRead = read(interface->fd,
interface->buffer+interface->bufferLength,
- INTERFACE_MAX_BUFFER_LENGTH-interface->bufferLength+1);
+ INTERFACE_MAX_BUFFER_LENGTH-interface->bufferLength);
if(bytesRead > 0) return processBytesRead(interface, bytesRead);
else if(bytesRead == 0 && errno!=EINTR) closeInterface(interface);