s3-ctdb: Fix ctdb_serverids_exist for target nodes that died
authorVolker Lendecke <vl@samba.org>
Mon, 16 Jul 2012 14:18:19 +0000 (16:18 +0200)
committerChristian Ambach <ambi@samba.org>
Fri, 3 Aug 2012 10:53:49 +0000 (12:53 +0200)
Signed-off-by: Christian Ambach <ambi@samba.org>
source3/lib/ctdbd_conn.c

index dddb41285e5ec4d360a91d29ffc8ac61a366d76e..0fa2f9040c822f32e04e45fd15b4f462e41f0cdd 100644 (file)
@@ -1190,6 +1190,7 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn,
                struct ctdb_reply_control *reply = NULL;
                struct ctdb_vnn_list *vnn;
                uint32_t reqid;
+               uint8_t *reply_data;
 
                status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1227,13 +1228,26 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn,
                           (unsigned)vnn->vnn, vnn->num_srvids,
                           (unsigned)reply->datalen));
 
-               if (reply->datalen < ((vnn->num_srvids+7)/8)) {
-                       DEBUG(1, ("Received short reply len %d, status %u,"
+               if (reply->datalen >= ((vnn->num_srvids+7)/8)) {
+                       /*
+                        * Got a real reply
+                        */
+                       reply_data = reply->data;
+               } else {
+                       /*
+                        * Got an error reply
+                        */
+                       DEBUG(1, ("Received short reply len %d, status %u, "
                                  "errorlen %u\n",
                                  (unsigned)reply->datalen,
                                  (unsigned)reply->status,
                                  (unsigned)reply->errorlen));
-                       goto fail;
+                       dump_data(1, reply->data, reply->errorlen);
+
+                       /*
+                        * This will trigger everything set to false
+                        */
+                       reply_data = NULL;
                }
 
                for (i=0; i<vnn->num_srvids; i++) {
@@ -1244,7 +1258,9 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn,
                                results[idx] = true;
                                continue;
                        }
-                       results[idx] = ((reply->data[i/8] & (1<<(i%8))) != 0);
+                       results[idx] =
+                               (reply_data != NULL) &&
+                               ((reply_data[i/8] & (1<<(i%8))) != 0);
                }
 
                TALLOC_FREE(reply);