Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/lib/g_lock.c

    r593 r745  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
    2122#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"
    2228
    2329static NTSTATUS g_lock_force_unlock(struct g_lock_ctx *ctx, const char *name,
     
    5258
    5359        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);
    5561        if (result->db == NULL) {
    5662                DEBUG(1, ("g_lock_init: Could not open g_lock.tdb"));
     
    206212        }
    207213
    208         self = procid_self();
     214        self = messaging_server_id(ctx->msg);
    209215        our_index = -1;
    210216
     
    333339
    334340        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;
    340344                int ret;
    341345                struct timeval timeout_remaining, select_timeout;
     
    385389                 */
    386390
     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
    387403#ifdef CLUSTER_SUPPORT
    388404                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;
    397412                }
    398413#endif
     
    405420                                             &timeout_remaining);
    406421
    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
    409433                if (ret == -1) {
    410434                        if (errno != EINTR) {
     
    590614        NTSTATUS status;
    591615
    592         status = g_lock_force_unlock(ctx, name, procid_self());
     616        status = g_lock_force_unlock(ctx, name, messaging_server_id(ctx->msg));
    593617
    594618#ifdef CLUSTER_SUPPORT
     
    707731                            struct tevent_context **pev,
    708732                            struct messaging_context **pmsg,
     733                            const struct server_id self,
    709734                            struct g_lock_ctx **pg_ctx)
    710735{
     
    718743                goto fail;
    719744        }
    720         msg = messaging_init(mem_ctx, procid_self(), ev);
     745        msg = messaging_init(mem_ctx, self, ev);
    721746        if (msg == NULL) {
    722747                d_fprintf(stderr, "ERROR: could not init messaging context\n");
     
    741766
    742767NTSTATUS 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,
    744769                   void (*fn)(void *private_data), void *private_data)
    745770{
     
    749774        NTSTATUS status;
    750775
    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)) {
    752777                status = NT_STATUS_ACCESS_DENIED;
    753778                goto done;
Note: See TracChangeset for help on using the changeset viewer.