diff options
author | sr | 2012-09-05 19:11:40 +0200 |
---|---|---|
committer | sr | 2012-09-05 19:11:40 +0200 |
commit | 4a2159f128ec9004ae12528c4a876158248bf944 (patch) | |
tree | f773cf19e3b61cf6a8cff02d93bae948f9bfb9f1 /src/server/job.c | |
parent | make things actually work as promised in last commit (diff) | |
download | dnbd3-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.c | 10 |
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); } } |