summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96683ca)
raw | patch | inline | side by side (parent: 96683ca)
author | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 23:07:16 +0000 (01:07 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 23:07:16 +0000 (01:07 +0200) |
Even for large responses, 16kB should be enough. There is no
performance gain for larger buffers, even if MPD is local.
performance gain for larger buffers, even if MPD is local.
src/libmpdclient.c | patch | blob | history | |
src/libmpdclient.h | patch | blob | history |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index b29ffe746527fda3c0cf9520d21b25dd4834746f..1b0851ff125c08b4d8d86dc9806b5af676a6345d 100644 (file)
--- 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"
!(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;
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 c4a22b2d83ed643c3f181ad91ddd156d2a422218..7928944763a8eda7886a67bc9f4479181eb3f1e0 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
#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 */
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;