Changeset 988 for vendor/current/source4/cluster
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/cluster
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/cluster/cluster.c
r740 r988 24 24 #include "cluster/cluster_private.h" 25 25 #include "librpc/gen_ndr/misc.h" 26 #include "librpc/gen_ndr/server_id 4.h"26 #include "librpc/gen_ndr/server_id.h" 27 27 28 28 static struct cluster_ops *ops; … … 51 51 create a server_id for the local node 52 52 */ 53 struct server_id cluster_id(uint64_t id, uint32_t id2)53 struct server_id cluster_id(uint64_t pid, uint32_t task_id) 54 54 { 55 55 cluster_init(); 56 return ops->cluster_id(ops, id, id2);56 return ops->cluster_id(ops, pid, task_id); 57 57 } 58 59 60 /*61 return a server_id as a string62 */63 const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id)64 {65 cluster_init();66 return ops->cluster_id_string(ops, mem_ctx, id);67 }68 69 58 70 59 /* 71 60 open a temporary tdb in a cluster friendly manner 72 61 */ 73 struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags)62 struct db_context *cluster_db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbbase, int flags) 74 63 { 75 64 cluster_init(); 76 return ops->cluster_ tdb_tmp_open(ops, mem_ctx, lp_ctx, dbname, flags);65 return ops->cluster_db_tmp_open(ops, mem_ctx, lp_ctx, dbbase, flags); 77 66 } 78 67 … … 81 70 register a callback function for a messaging endpoint 82 71 */ 83 NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server,72 NTSTATUS cluster_message_init(struct imessaging_context *msg, struct server_id server, 84 73 cluster_message_fn_t handler) 85 74 { -
vendor/current/source4/cluster/cluster.h
r740 r988 23 23 #define __CLUSTER_H__ 24 24 25 #include "librpc/gen_ndr/server_id 4.h"25 #include "librpc/gen_ndr/server_id.h" 26 26 27 27 /* 28 28 test for same cluster id 29 29 */ 30 #define cluster_id_equal(id_1, id_2) ((id_1)-> id == (id_2)->id \31 && (id_1)-> id2 == (id_2)->id2\32 && (id_1)-> node == (id_2)->node)30 #define cluster_id_equal(id_1, id_2) ((id_1)->pid == (id_2)->pid \ 31 && (id_1)->task_id == (id_2)->task_id \ 32 && (id_1)->vnn == (id_2)->vnn) 33 33 34 34 /* 35 35 test for same cluster node 36 36 */ 37 #define cluster_node_equal(id1, id2) ((id1)-> node == (id2)->node)37 #define cluster_node_equal(id1, id2) ((id1)->vnn == (id2)->vnn) 38 38 39 struct messaging_context;40 typedef void (*cluster_message_fn_t)(struct messaging_context *, DATA_BLOB);39 struct imessaging_context; 40 typedef void (*cluster_message_fn_t)(struct imessaging_context *, DATA_BLOB); 41 41 42 42 /* prototypes */ 43 struct server_id cluster_id(uint64_t id, uint32_t id2); 44 const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id); 45 struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags); 43 struct server_id cluster_id(uint64_t id, uint32_t task_id); 44 struct db_context *cluster_db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbbase, int flags); 46 45 void *cluster_backend_handle(void); 47 46 48 NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server,47 NTSTATUS cluster_message_init(struct imessaging_context *msg, struct server_id server, 49 48 cluster_message_fn_t handler); 50 49 NTSTATUS cluster_message_send(struct server_id server, DATA_BLOB *data); -
vendor/current/source4/cluster/cluster_private.h
r414 r988 25 25 struct cluster_ops { 26 26 struct server_id (*cluster_id)(struct cluster_ops *ops, uint64_t id, uint32_t id2); 27 const char *(*cluster_id_string)(struct cluster_ops *ops, 28 TALLOC_CTX *, struct server_id ); 29 struct tdb_wrap *(*cluster_tdb_tmp_open)(struct cluster_ops *, 30 TALLOC_CTX *, 27 struct db_context *(*cluster_db_tmp_open)(struct cluster_ops *, 28 TALLOC_CTX *, 31 29 struct loadparm_context *, 32 30 const char *, int); 33 31 void *(*backend_handle)(struct cluster_ops *); 34 32 NTSTATUS (*message_init)(struct cluster_ops *ops, 35 struct messaging_context *msg, struct server_id server,33 struct imessaging_context *msg, struct server_id server, 36 34 cluster_message_fn_t handler); 37 35 NTSTATUS (*message_send)(struct cluster_ops *ops, -
vendor/current/source4/cluster/local.c
r740 r988 23 23 #include "cluster/cluster.h" 24 24 #include "cluster/cluster_private.h" 25 #include <tdb.h> 26 #include "lib/util/tdb_wrap.h" 25 #include "dbwrap/dbwrap.h" 27 26 #include "system/filesys.h" 28 27 #include "param/param.h" 29 #include "librpc/gen_ndr/server_id 4.h"28 #include "librpc/gen_ndr/server_id.h" 30 29 31 30 /* 32 31 server a server_id for the local node 33 32 */ 34 static struct server_id local_id(struct cluster_ops *ops, uint64_t id, uint32_t id2)33 static struct server_id local_id(struct cluster_ops *ops, uint64_t pid, uint32_t task_id) 35 34 { 36 35 struct server_id server_id; 37 36 ZERO_STRUCT(server_id); 38 server_id.id = id; 39 server_id.id2 = id2; 37 server_id.pid = pid; 38 server_id.task_id = task_id; 39 server_id.vnn = NONCLUSTER_VNN; 40 /* This is because we are not in the s3 serverid database */ 41 server_id.unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY; 40 42 return server_id; 41 }42 43 44 /*45 return a server_id as a string46 */47 static const char *local_id_string(struct cluster_ops *ops,48 TALLOC_CTX *mem_ctx, struct server_id id)49 {50 return talloc_asprintf(mem_ctx, "%u.%llu.%u", id.node, (unsigned long long)id.id, id.id2);51 43 } 52 44 … … 56 48 TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup 57 49 */ 58 static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,59 TALLOC_CTX *mem_ctx,60 struct loadparm_context *lp_ctx,61 const char *dbname, int flags)50 static struct db_context *local_db_tmp_open(struct cluster_ops *ops, 51 TALLOC_CTX *mem_ctx, 52 struct loadparm_context *lp_ctx, 53 const char *dbbase, int flags) 62 54 { 63 char *path = smbd_tmp_path(mem_ctx, lp_ctx, dbname); 64 struct tdb_wrap *w; 65 w = tdb_wrap_open(mem_ctx, path, 0, flags, 66 O_RDWR|O_CREAT, 0600); 67 talloc_free(path); 68 return w; 55 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); 56 char *path, *dbname; 57 struct db_context *db; 58 59 dbname = talloc_asprintf(mem_ctx, "%s.tdb", dbbase); 60 61 path = smbd_tmp_path(tmp_ctx, lp_ctx, dbname); 62 db = dbwrap_local_open(mem_ctx, lp_ctx, path, 0, flags, O_RDWR|O_CREAT, 63 0600, DBWRAP_LOCK_ORDER_NONE, DBWRAP_FLAG_NONE); 64 talloc_free(tmp_ctx); 65 return db; 69 66 } 70 67 … … 81 78 */ 82 79 static NTSTATUS local_message_init(struct cluster_ops *ops, 83 struct messaging_context *msg,80 struct imessaging_context *msg, 84 81 struct server_id server, 85 82 cluster_message_fn_t handler) … … 99 96 static struct cluster_ops cluster_local_ops = { 100 97 .cluster_id = local_id, 101 .cluster_id_string = local_id_string, 102 .cluster_tdb_tmp_open = local_tdb_tmp_open, 98 .cluster_db_tmp_open = local_db_tmp_open, 103 99 .backend_handle = local_backend_handle, 104 100 .message_init = local_message_init, -
vendor/current/source4/cluster/wscript_build
r740 r988 3 3 bld.SAMBA_LIBRARY('cluster', 4 4 source='cluster.c local.c', 5 deps=' tdb-wrap samba-hostconfig talloc',5 deps='dbwrap samba-hostconfig talloc', 6 6 private_library=True 7 7 )
Note:
See TracChangeset
for help on using the changeset viewer.