aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-18 01:07:16 +0200
committerMax Kellermann <max@duempel.org>2008-09-18 01:07:16 +0200
commit44c3a54cf0d0f65627a5993a129b324107f9fc58 (patch)
tree857441cf5d7f4da02a09f608ee183300b3c8d676
parent96683ca4d3611e7c25364a1dbf326435727757d2 (diff)
downloadmpd-44c3a54cf0d0f65627a5993a129b324107f9fc58.tar.gz
mpd-44c3a54cf0d0f65627a5993a129b324107f9fc58.tar.xz
mpd-44c3a54cf0d0f65627a5993a129b324107f9fc58.zip
libmpdclient: smaller input buffer
Even for large responses, 16kB should be enough. There is no performance gain for larger buffers, even if MPD is local.
-rw-r--r--src/libmpdclient.c8
-rw-r--r--src/libmpdclient.h3
2 files changed, 5 insertions, 6 deletions
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index b29ffe746..1b0851ff1 100644
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
@@ -417,7 +417,7 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
ssize_t readed;
readed = recv(connection->sock,
&(connection->buffer[connection->buflen]),
- MPD_BUFFER_MAX_LENGTH-connection->buflen,0);
+ sizeof(connection->buffer) - connection->buflen, 0);
if(readed<=0) {
snprintf(connection->errorStr, sizeof(connection->errorStr),
"problems getting a response from"
@@ -553,14 +553,14 @@ static void mpd_getNextReturnElement(mpd_Connection * connection) {
!(rt = memchr(bufferCheck, '\n',
connection->buffer + connection->buflen -
bufferCheck))) {
- if (connection->buflen >= MPD_BUFFER_MAX_LENGTH) {
+ if (connection->buflen >= sizeof(connection->buffer)) {
memmove(connection->buffer,
connection->buffer + connection->bufstart,
connection->buflen - connection->bufstart);
connection->buflen -= connection->bufstart;
connection->bufstart = 0;
}
- if (connection->buflen >= MPD_BUFFER_MAX_LENGTH) {
+ if (connection->buflen >= sizeof(connection->buffer)) {
strcpy(connection->errorStr,"buffer overrun");
connection->error = MPD_ERROR_BUFFEROVERRUN;
connection->doneProcessing = 1;
@@ -575,7 +575,7 @@ static void mpd_getNextReturnElement(mpd_Connection * connection) {
if((err = select(connection->sock+1,&fds,NULL,NULL,&tv) == 1)) {
readed = recv(connection->sock,
connection->buffer+connection->buflen,
- MPD_BUFFER_MAX_LENGTH-connection->buflen,
+ sizeof(connection->buffer) - connection->buflen,
MSG_DONTWAIT);
if(readed<0 && SENDRECV_ERRNO_IGNORE) {
continue;
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index c4a22b2d8..792894476 100644
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
@@ -42,7 +42,6 @@
#include <sys/time.h>
#include <stddef.h>
-#define MPD_BUFFER_MAX_LENGTH 50000
#define MPD_WELCOME_MESSAGE "OK MPD "
#define MPD_ERROR_TIMEOUT 10 /* timeout trying to talk to mpd */
@@ -117,7 +116,7 @@ typedef struct _mpd_Connection {
int error;
/* DON'T TOUCH any of the rest of this stuff */
int sock;
- char buffer[MPD_BUFFER_MAX_LENGTH+1];
+ char buffer[16384];
size_t buflen;
size_t bufstart;
int doneProcessing;