aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-14 06:41:32 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-14 06:41:32 +0200
commitd4f18457a4bcdf321b6f97394c3a7c26dd2225e7 (patch)
tree8b1b20fd49869ace10fe449301ba0b21b878569d /src
parentm fix (diff)
downloadmds-d4f18457a4bcdf321b6f97394c3a7c26dd2225e7.tar.gz
mds-d4f18457a4bcdf321b6f97394c3a7c26dd2225e7.tar.bz2
mds-d4f18457a4bcdf321b6f97394c3a7c26dd2225e7.tar.xz
fix dumb-client and memory errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/mds-message.c1
-rw-r--r--src/libmdsserver/util.c4
-rw-r--r--src/mds-server/mds-server.c7
3 files changed, 7 insertions, 5 deletions
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c
index b324ad4..d65ac6b 100644
--- a/src/libmdsserver/mds-message.c
+++ b/src/libmdsserver/mds-message.c
@@ -94,6 +94,7 @@ int mds_message_read(mds_message_t* restrict this, int fd)
{
size_t i;
xfree(this->headers, this->header_count);
+ this->headers = NULL;
}
this->header_count = 0;
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c
index 07f4bfa..b909876 100644
--- a/src/libmdsserver/util.c
+++ b/src/libmdsserver/util.c
@@ -126,7 +126,7 @@ size_t send_message(int socket, const char* message, size_t length)
ssize_t just_sent;
while (length > 0)
- if ((just_sent = send(socket, message, min(block_size, length), MSG_NOSIGNAL)) < 0)
+ if ((just_sent = send(socket, message + sent, min(block_size, length), MSG_NOSIGNAL)) < 0)
{
if (errno == EMSGSIZE)
{
@@ -139,7 +139,7 @@ size_t send_message(int socket, const char* message, size_t length)
}
else
{
- message += (size_t)just_sent;
+ sent += (size_t)just_sent;
length -= (size_t)just_sent;
}
diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c
index aebd104..c0e4ea0 100644
--- a/src/mds-server/mds-server.c
+++ b/src/mds-server/mds-server.c
@@ -617,7 +617,7 @@ void* slave_loop(void* data)
break;
}
n -= sent;
- sendbuf_ += sent;
+ sendbuf_ += sent / sizeof(char);
}
free(sendbuf);
);
@@ -936,7 +936,7 @@ int message_received(client_t* client)
free(msgbuf);
return 0;
}
- queue_message_multicast(msgbuf, n, client);
+ queue_message_multicast(msgbuf_, n, client);
/* Queue message to be sent when this function returns.
This done to simplify `multicast_message` for re-exec. */
@@ -1346,6 +1346,7 @@ void multicast_message(multicast_t* multicast)
/* Send the message. */
with_mutex(client->mutex,
errno = 0;
+ n *= sizeof(char);
if (client->open)
while (n > 0)
{
@@ -1357,7 +1358,7 @@ void multicast_message(multicast_t* multicast)
break;
}
n -= sent;
- multicast->message_ptr += sent;
+ multicast->message_ptr += sent / sizeof(char);
}
);