Changeset 740 for vendor/current/source3/lib/ctdbd_conn.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified vendor/current/source3/lib/ctdbd_conn.c ¶
r427 r740 20 20 21 21 #include "includes.h" 22 #include "util_tdb.h" 22 23 23 24 #ifdef CLUSTER_SUPPORT 24 25 25 #include "librpc/gen_ndr/messaging.h" 26 #include "librpc/gen_ndr/ndr_messaging.h" 26 #include "ctdbd_conn.h" 27 #include "packet.h" 28 #include "messages.h" 27 29 28 30 /* paths to these include files come from --with-ctdb= in configure */ … … 58 60 so that someone else can take over without getting sharing 59 61 violations */ 60 _exit( 0);62 _exit(1); 61 63 } 62 64 … … 105 107 } 106 108 109 /* 110 * Are we active (i.e. not banned or stopped?) 111 */ 112 static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn) 113 { 114 int32_t cstatus=-1; 115 NTSTATUS status; 116 TDB_DATA outdata; 117 struct ctdb_node_map *m; 118 uint32_t failure_flags; 119 bool ret = false; 120 int i; 121 122 status = ctdbd_control(conn, CTDB_CURRENT_NODE, 123 CTDB_CONTROL_GET_NODEMAP, 0, 0, 124 tdb_null, talloc_tos(), &outdata, &cstatus); 125 if (!NT_STATUS_IS_OK(status)) { 126 cluster_fatal("ctdbd_control failed\n"); 127 } 128 if ((cstatus != 0) || (outdata.dptr == NULL)) { 129 DEBUG(2, ("Received invalid ctdb data\n")); 130 return false; 131 } 132 133 m = (struct ctdb_node_map *)outdata.dptr; 134 135 for (i=0; i<m->num; i++) { 136 if (vnn == m->nodes[i].pnn) { 137 break; 138 } 139 } 140 141 if (i == m->num) { 142 DEBUG(2, ("Did not find ourselves (node %d) in nodemap\n", 143 (int)vnn)); 144 goto fail; 145 } 146 147 failure_flags = NODE_FLAGS_BANNED | NODE_FLAGS_DISCONNECTED 148 | NODE_FLAGS_PERMANENTLY_DISABLED | NODE_FLAGS_STOPPED; 149 150 if ((m->nodes[i].flags & failure_flags) != 0) { 151 DEBUG(2, ("Node has status %x, not active\n", 152 (int)m->nodes[i].flags)); 153 goto fail; 154 } 155 156 ret = true; 157 fail: 158 TALLOC_FREE(outdata.dptr); 159 return ret; 160 } 161 107 162 uint32 ctdbd_vnn(const struct ctdbd_connection *conn) 108 163 { … … 136 191 strncpy(addr.sun_path, sockname, sizeof(addr.sun_path)); 137 192 138 if (sys_connect(fd, (struct sockaddr *) &addr) == -1) {193 if (sys_connect(fd, (struct sockaddr *)(void *)&addr) == -1) { 139 194 DEBUG(1, ("connect(%s) failed: %s\n", sockname, 140 195 strerror(errno))); … … 258 313 259 314 ndr_err = ndr_pull_struct_blob( 260 &blob, result, NULL,result,315 &blob, result, result, 261 316 (ndr_pull_flags_fn_t)ndr_pull_messaging_rec); 262 317 … … 278 333 static NTSTATUS ctdb_packet_fd_read_sync(struct packet_context *ctx) 279 334 { 280 struct timeval timeout; 281 struct timeval *ptimeout; 282 283 timeout = timeval_set(lp_ctdb_timeout(), 0); 284 ptimeout = (timeout.tv_sec != 0) ? &timeout : NULL; 285 286 return packet_fd_read_sync(ctx, ptimeout); 335 int timeout = lp_ctdb_timeout(); 336 337 if (timeout == 0) { 338 timeout = -1; 339 } 340 return packet_fd_read_sync(ctx, timeout); 287 341 } 288 342 … … 369 423 ? "cluster reconfigure" : "SAMBA_NOTIFY")); 370 424 371 messaging_send(conn->msg_ctx, procid_self(), 425 messaging_send(conn->msg_ctx, 426 messaging_server_id(conn->msg_ctx), 372 427 MSG_SMB_BRL_VALIDATE, &data_blob_null); 373 messaging_send(conn->msg_ctx, procid_self(), 428 messaging_send(conn->msg_ctx, 429 messaging_server_id(conn->msg_ctx), 374 430 MSG_DBWRAP_G_LOCK_RETRY, 375 431 &data_blob_null); … … 378 434 } 379 435 380 if (!(msg_state = TALLOC_P(talloc_autofree_context(), struct deferred_msg_state))) { 436 msg_state = TALLOC_P(NULL, struct deferred_msg_state); 437 if (msg_state == NULL) { 381 438 DEBUG(0, ("talloc failed\n")); 382 439 TALLOC_FREE(hdr); … … 432 489 */ 433 490 434 NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,435 491 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx, 492 struct ctdbd_connection **pconn) 436 493 { 437 494 struct ctdbd_connection *conn; … … 454 511 if (!NT_STATUS_IS_OK(status)) { 455 512 DEBUG(10, ("get_cluster_vnn failed: %s\n", nt_errstr(status))); 513 goto fail; 514 } 515 516 if (!ctdbd_working(conn, conn->our_vnn)) { 517 DEBUG(2, ("Node is not working, can not connect\n")); 518 status = NT_STATUS_INTERNAL_DB_ERROR; 456 519 goto fail; 457 520 } … … 565 628 * clean the brl database 566 629 */ 567 messaging_send(conn->msg_ctx, procid_self(), 630 messaging_send(conn->msg_ctx, 631 messaging_server_id(conn->msg_ctx), 568 632 MSG_SMB_BRL_VALIDATE, &data_blob_null); 569 633 570 messaging_send(conn->msg_ctx, procid_self(), 634 messaging_send(conn->msg_ctx, 635 messaging_server_id(conn->msg_ctx), 571 636 MSG_DBWRAP_G_LOCK_RETRY, 572 637 &data_blob_null); … … 671 736 672 737 ndr_err = ndr_push_struct_blob( 673 &blob, mem_ctx, NULL,msg,738 &blob, mem_ctx, msg, 674 739 (ndr_push_flags_fn_t)ndr_push_messaging_rec); 675 740 … … 758 823 req.srvid = srvid; 759 824 req.datalen = data.dsize; 825 req.flags = flags; 760 826 761 827 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n")); … … 781 847 if (flags & CTDB_CTRL_FLAG_NOREPLY) { 782 848 TALLOC_FREE(new_conn); 849 if (cstatus) { 850 *cstatus = 0; 851 } 783 852 return NT_STATUS_OK; 784 853 } … … 881 950 ? CTDB_CONTROL_DB_ATTACH_PERSISTENT 882 951 : CTDB_CONTROL_DB_ATTACH, 883 0, 0, data, NULL, &data, &cstatus);952 tdb_flags, 0, data, NULL, &data, &cstatus); 884 953 if (!NT_STATUS_IS_OK(status)) { 885 954 DEBUG(0, (__location__ " ctdb_control for db_attach " … … 1275 1344 switch (client.ss_family) { 1276 1345 case AF_INET: 1277 p4.dest = *(struct sockaddr_in *) &server;1278 p4.src = *(struct sockaddr_in *) &client;1346 p4.dest = *(struct sockaddr_in *)(void *)&server; 1347 p4.src = *(struct sockaddr_in *)(void *)&client; 1279 1348 data.dptr = (uint8_t *)&p4; 1280 1349 data.dsize = sizeof(p4); … … 1282 1351 #ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR 1283 1352 case AF_INET6: 1284 p.dest.ip6 = *(struct sockaddr_in6 *) &server;1285 p.src.ip6 = *(struct sockaddr_in6 *) &client;1353 p.dest.ip6 = *(struct sockaddr_in6 *)(void *)&server; 1354 p.src.ip6 = *(struct sockaddr_in6 *)(void *)&client; 1286 1355 data.dptr = (uint8_t *)&p; 1287 1356 data.dsize = sizeof(p); … … 1293 1362 1294 1363 conn->release_ip_handler = release_ip_handler; 1364 /* 1365 * store the IP address of the server socket for later 1366 * comparison in release_ip() 1367 */ 1368 conn->release_ip_priv = private_data; 1295 1369 1296 1370 /* … … 1376 1450 } 1377 1451 1378 #else1379 1380 NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,1381 struct ctdbd_connection **pconn)1382 {1383 return NT_STATUS_NOT_IMPLEMENTED;1384 }1385 1386 1452 #endif
Note:
See TracChangeset
for help on using the changeset viewer.