Fix a few more breakages from our recent changes to the server_id
[samba.git] / source4 / lib / messaging / messaging.c
index df0bfa32a69f5c03344782a104948212e19f0812..6a879ab962774f8008af09b56aea34b949042b37 100644 (file)
@@ -49,6 +49,7 @@ struct messaging_context {
        struct idr_context *dispatch_tree;
        struct messaging_rec *pending;
        struct messaging_rec *retry_queue;
+       struct smb_iconv_convenience *iconv_convenience;
        struct irpc_list *irpc;
        struct idr_context *idr;
        const char **names;
@@ -120,8 +121,8 @@ static NTSTATUS irpc_uptime(struct irpc_message *msg,
 */
 static char *messaging_path(struct messaging_context *msg, struct server_id server_id)
 {
-       return talloc_asprintf(msg, "%s/msg.%u.%u", msg->base_path, 
-                              (unsigned)server_id.node, (unsigned)server_id.id);
+       return talloc_asprintf(msg, "%s/msg.%s", msg->base_path, 
+                              cluster_id_string(msg, server_id));
 }
 
 /*
@@ -262,8 +263,10 @@ static void messaging_send_handler(struct messaging_context *msg)
                }
                rec->retries = 0;
                if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(1,("messaging: Lost message from %u to %u of type %u - %s\n", 
-                                rec->header->from.id, rec->header->to.id, rec->header->msg_type, 
+                       DEBUG(1,("messaging: Lost message from %s to %s of type %u - %s\n", 
+                                cluster_id_string(debug_ctx(), rec->header->from), 
+                                cluster_id_string(debug_ctx(), rec->header->to), 
+                                rec->header->msg_type, 
                                 nt_errstr(status)));
                }
                DLIST_REMOVE(msg->pending, rec);
@@ -532,6 +535,7 @@ static int messaging_destructor(struct messaging_context *msg)
 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, 
                                         const char *dir,
                                         struct server_id server_id, 
+                                        struct smb_iconv_convenience *iconv_convenience,
                                         struct event_context *ev)
 {
        struct messaging_context *msg;
@@ -560,6 +564,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
        msg->base_path     = talloc_reference(msg, dir);
        msg->path          = messaging_path(msg, server_id);
        msg->server_id     = server_id;
+       msg->iconv_convenience = iconv_convenience;
        msg->idr           = idr_init(msg);
        msg->dispatch_tree = idr_init(msg);
        msg->start_time    = timeval_current();
@@ -609,12 +614,13 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 */
 struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx, 
                                                const char *dir,
+                                               struct smb_iconv_convenience *iconv_convenience,
                                                struct event_context *ev)
 {
        struct server_id id;
        ZERO_STRUCT(id);
        id.id = random() % 0x10000000;
-       return messaging_init(mem_ctx, dir, id, ev);
+       return messaging_init(mem_ctx, dir, id, iconv_convenience, ev);
 }
 /*
   a list of registered irpc server functions
@@ -698,7 +704,7 @@ NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status)
        m->header.status = status;
 
        /* setup the reply */
-       push = ndr_push_init_ctx(m->ndr);
+       push = ndr_push_init_ctx(m->ndr, m->msg_ctx->iconv_convenience);
        if (push == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto failed;
@@ -798,7 +804,7 @@ static void irpc_handler(struct messaging_context *msg_ctx, void *private,
 
        m->from = src;
 
-       m->ndr = ndr_pull_init_blob(packet, m);
+       m->ndr = ndr_pull_init_blob(packet, m, msg_ctx->iconv_convenience);
        if (m->ndr == NULL) goto failed;
 
        m->ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
@@ -890,7 +896,7 @@ struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
        header.status     = NT_STATUS_OK;
 
        /* construct the irpc packet */
-       ndr = ndr_push_init_ctx(irpc);
+       ndr = ndr_push_init_ctx(irpc, msg_ctx->iconv_convenience);
        if (ndr == NULL) goto failed;
 
        ndr_err = ndr_push_irpc_header(ndr, NDR_SCALARS|NDR_BUFFERS, &header);
@@ -1047,7 +1053,7 @@ struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx,
        for (i=0;i<count;i++) {
                ret[i] = ((struct server_id *)rec.dptr)[i];
        }
-       ret[i] = cluster_id(0);
+       ret[i] = cluster_id(0, 0);
        free(rec.dptr);
        tdb_unlock_bystring(t->tdb, name);
        talloc_free(t);