summaryrefslogtreecommitdiffstats
path: root/src/server/job.c
diff options
context:
space:
mode:
authorsr2012-09-05 19:11:40 +0200
committersr2012-09-05 19:11:40 +0200
commit4a2159f128ec9004ae12528c4a876158248bf944 (patch)
treef773cf19e3b61cf6a8cff02d93bae948f9bfb9f1 /src/server/job.c
parentmake things actually work as promised in last commit (diff)
downloaddnbd3-4a2159f128ec9004ae12528c4a876158248bf944.tar.gz
dnbd3-4a2159f128ec9004ae12528c4a876158248bf944.tar.xz
dnbd3-4a2159f128ec9004ae12528c4a876158248bf944.zip
[SERVER] Fix saving of trusted server data
Diffstat (limited to 'src/server/job.c')
-rw-r--r--src/server/job.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server/job.c b/src/server/job.c
index 799e69e..3c9bdc9 100644
--- a/src/server/job.c
+++ b/src/server/job.c
@@ -361,10 +361,14 @@ static void add_alt_server(dnbd3_image_t *image, dnbd3_host_t *host)
if (image->servers[i].host.type == 0)
{
image->servers[i].host = *host;
+ image->servers[i].failures = 0;
break;
}
}
- // Broadcast to connected clients
+ if (i >= NUMBER_SERVERS) // To many known alt servers already
+ return;
+ // Broadcast to connected clients. Note that i now points to the new server
+ printf("[DEBUG] Adding alt server to %s\n", image->low_name);
GSList *itc;
dnbd3_reply_t header;
header.cmd = CMD_GET_SERVERS;
@@ -377,9 +381,9 @@ static void add_alt_server(dnbd3_image_t *image, dnbd3_host_t *host)
if (client->image == image)
{
// Don't send message directly as the lock is being held; instead, enqueue it
- NEW_BINSTRING(message, sizeof(header) + sizeof(*host));
+ NEW_BINSTRING(message, sizeof(header) + sizeof(image->servers[i]));
memcpy(message->data, &header, sizeof(header));
- memcpy(message->data + sizeof(header), host, sizeof(*host));
+ memcpy(message->data + sizeof(header), &image->servers[i], sizeof(image->servers[i]));
client->sendqueue = g_slist_append(client->sendqueue, message);
}
}