Commit 48c11c52 authored by Max Kellermann's avatar Max Kellermann

client: removed CLIENT_MAX_BUFFER_LENGTH

Use a literal in the struct declaration, and sizeof(client->buffer) everywhere else. Also shrink the buffer from 40 kB to 4 kB. The buffer must only be large enough to hold one line of input, and 4 kB is still more than enough.
parent 3689d5e4
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#define GREETING "OK MPD " PROTOCOL_VERSION "\n" #define GREETING "OK MPD " PROTOCOL_VERSION "\n"
#define CLIENT_MAX_BUFFER_LENGTH (40960)
#define CLIENT_LIST_MODE_BEGIN "command_list_begin" #define CLIENT_LIST_MODE_BEGIN "command_list_begin"
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin" #define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_MODE_END "command_list_end" #define CLIENT_LIST_MODE_END "command_list_end"
...@@ -69,7 +68,7 @@ static struct strnode *list_cache_tail; ...@@ -69,7 +68,7 @@ static struct strnode *list_cache_tail;
struct client { struct client {
struct list_head siblings; struct list_head siblings;
char buffer[CLIENT_MAX_BUFFER_LENGTH]; char buffer[4096];
size_t bufferLength; size_t bufferLength;
size_t bufferPos; size_t bufferPos;
...@@ -509,7 +508,7 @@ static int client_read(struct client *client) ...@@ -509,7 +508,7 @@ static int client_read(struct client *client)
bytesRead = read(client->fd, bytesRead = read(client->fd,
client->buffer + client->bufferLength, client->buffer + client->bufferLength,
CLIENT_MAX_BUFFER_LENGTH - client->bufferLength); sizeof(client->buffer) - client->bufferLength);
if (bytesRead > 0) if (bytesRead > 0)
return client_input_received(client, bytesRead); return client_input_received(client, bytesRead);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment