Changeset 745 for trunk/server/source3/lib/g_lock.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/lib/g_lock.c
r593 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 21 22 #include "g_lock.h" 23 #include "util_tdb.h" 24 #include "ctdbd_conn.h" 25 #include "../lib/util/select.h" 26 #include "system/select.h" 27 #include "messages.h" 22 28 23 29 static NTSTATUS g_lock_force_unlock(struct g_lock_ctx *ctx, const char *name, … … 52 58 53 59 result->db = db_open(result, lock_path("g_lock.tdb"), 0, 54 TDB_CLEAR_IF_FIRST , O_RDWR|O_CREAT, 0700);60 TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0700); 55 61 if (result->db == NULL) { 56 62 DEBUG(1, ("g_lock_init: Could not open g_lock.tdb")); … … 206 212 } 207 213 208 self = procid_self();214 self = messaging_server_id(ctx->msg); 209 215 our_index = -1; 210 216 … … 333 339 334 340 while (true) { 335 #ifdef CLUSTER_SUPPORT 336 fd_set _r_fds; 337 #endif 338 fd_set *r_fds = NULL; 339 int max_fd = 0; 341 struct pollfd *pollfds; 342 int num_pollfds; 343 int saved_errno; 340 344 int ret; 341 345 struct timeval timeout_remaining, select_timeout; … … 385 389 */ 386 390 391 /* 392 * We allocate 2 entries here. One is needed anyway for 393 * sys_poll and in the clustering case we might have to add 394 * the ctdb fd. This avoids the realloc then. 395 */ 396 pollfds = TALLOC_ARRAY(talloc_tos(), struct pollfd, 2); 397 if (pollfds == NULL) { 398 status = NT_STATUS_NO_MEMORY; 399 break; 400 } 401 num_pollfds = 0; 402 387 403 #ifdef CLUSTER_SUPPORT 388 404 if (lp_clustering()) { 389 struct ctdbd_connection *conn = messaging_ctdbd_connection(); 390 391 r_fds = &_r_fds; 392 FD_ZERO(r_fds); 393 max_fd = ctdbd_conn_get_fd(conn); 394 if (max_fd >= 0 && max_fd < FD_SETSIZE) { 395 FD_SET(max_fd, r_fds); 396 } 405 struct ctdbd_connection *conn; 406 conn = messaging_ctdbd_connection(); 407 408 pollfds[0].fd = ctdbd_conn_get_fd(conn); 409 pollfds[0].events = POLLIN|POLLHUP; 410 411 num_pollfds += 1; 397 412 } 398 413 #endif … … 405 420 &timeout_remaining); 406 421 407 ret = sys_select(max_fd + 1, r_fds, NULL, NULL, 408 &select_timeout); 422 ret = sys_poll(pollfds, num_pollfds, 423 timeval_to_msec(select_timeout)); 424 425 /* 426 * We're not *really interested in the actual flags. We just 427 * need to retry this whole thing. 428 */ 429 saved_errno = errno; 430 TALLOC_FREE(pollfds); 431 errno = saved_errno; 432 409 433 if (ret == -1) { 410 434 if (errno != EINTR) { … … 590 614 NTSTATUS status; 591 615 592 status = g_lock_force_unlock(ctx, name, procid_self());616 status = g_lock_force_unlock(ctx, name, messaging_server_id(ctx->msg)); 593 617 594 618 #ifdef CLUSTER_SUPPORT … … 707 731 struct tevent_context **pev, 708 732 struct messaging_context **pmsg, 733 const struct server_id self, 709 734 struct g_lock_ctx **pg_ctx) 710 735 { … … 718 743 goto fail; 719 744 } 720 msg = messaging_init(mem_ctx, procid_self(), ev);745 msg = messaging_init(mem_ctx, self, ev); 721 746 if (msg == NULL) { 722 747 d_fprintf(stderr, "ERROR: could not init messaging context\n"); … … 741 766 742 767 NTSTATUS g_lock_do(const char *name, enum g_lock_type lock_type, 743 struct timeval timeout, 768 struct timeval timeout, const struct server_id self, 744 769 void (*fn)(void *private_data), void *private_data) 745 770 { … … 749 774 NTSTATUS status; 750 775 751 if (!g_lock_init_all(talloc_tos(), &ev, &msg, &g_ctx)) {776 if (!g_lock_init_all(talloc_tos(), &ev, &msg, self, &g_ctx)) { 752 777 status = NT_STATUS_ACCESS_DENIED; 753 778 goto done;
Note:
See TracChangeset
for help on using the changeset viewer.