Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified vendor/current/source3/lib/ctdbd_conn.c

    r427 r740  
    2020
    2121#include "includes.h"
     22#include "util_tdb.h"
    2223
    2324#ifdef CLUSTER_SUPPORT
    2425
    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"
    2729
    2830/* paths to these include files come from --with-ctdb= in configure */
     
    5860           so that someone else can take over without getting sharing
    5961           violations */
    60         _exit(0);
     62        _exit(1);
    6163}
    6264
     
    105107}
    106108
     109/*
     110 * Are we active (i.e. not banned or stopped?)
     111 */
     112static 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;
     157fail:
     158        TALLOC_FREE(outdata.dptr);
     159        return ret;
     160}
     161
    107162uint32 ctdbd_vnn(const struct ctdbd_connection *conn)
    108163{
     
    136191        strncpy(addr.sun_path, sockname, sizeof(addr.sun_path));
    137192
    138         if (sys_connect(fd, (struct sockaddr *)&addr) == -1) {
     193        if (sys_connect(fd, (struct sockaddr *)(void *)&addr) == -1) {
    139194                DEBUG(1, ("connect(%s) failed: %s\n", sockname,
    140195                          strerror(errno)));
     
    258313
    259314        ndr_err = ndr_pull_struct_blob(
    260                 &blob, result, NULL, result,
     315                &blob, result, result,
    261316                (ndr_pull_flags_fn_t)ndr_pull_messaging_rec);
    262317
     
    278333static NTSTATUS ctdb_packet_fd_read_sync(struct packet_context *ctx)
    279334{
    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);
    287341}
    288342
     
    369423                                  ? "cluster reconfigure" : "SAMBA_NOTIFY"));
    370424
    371                         messaging_send(conn->msg_ctx, procid_self(),
     425                        messaging_send(conn->msg_ctx,
     426                                       messaging_server_id(conn->msg_ctx),
    372427                                       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),
    374430                                       MSG_DBWRAP_G_LOCK_RETRY,
    375431                                       &data_blob_null);
     
    378434                }
    379435
    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) {
    381438                        DEBUG(0, ("talloc failed\n"));
    382439                        TALLOC_FREE(hdr);
     
    432489 */
    433490
    434 NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
    435                                struct ctdbd_connection **pconn)
     491static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
     492                                      struct ctdbd_connection **pconn)
    436493{
    437494        struct ctdbd_connection *conn;
     
    454511        if (!NT_STATUS_IS_OK(status)) {
    455512                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;
    456519                goto fail;
    457520        }
     
    565628                 * clean the brl database
    566629                 */
    567                 messaging_send(conn->msg_ctx, procid_self(),
     630                messaging_send(conn->msg_ctx,
     631                               messaging_server_id(conn->msg_ctx),
    568632                               MSG_SMB_BRL_VALIDATE, &data_blob_null);
    569633
    570                 messaging_send(conn->msg_ctx, procid_self(),
     634                messaging_send(conn->msg_ctx,
     635                               messaging_server_id(conn->msg_ctx),
    571636                               MSG_DBWRAP_G_LOCK_RETRY,
    572637                               &data_blob_null);
     
    671736
    672737        ndr_err = ndr_push_struct_blob(
    673                 &blob, mem_ctx, NULL, msg,
     738                &blob, mem_ctx, msg,
    674739                (ndr_push_flags_fn_t)ndr_push_messaging_rec);
    675740
     
    758823        req.srvid            = srvid;
    759824        req.datalen          = data.dsize;
     825        req.flags            = flags;
    760826
    761827        DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
     
    781847        if (flags & CTDB_CTRL_FLAG_NOREPLY) {
    782848                TALLOC_FREE(new_conn);
     849                if (cstatus) {
     850                        *cstatus = 0;
     851                }
    783852                return NT_STATUS_OK;
    784853        }
     
    881950                               ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
    882951                               : CTDB_CONTROL_DB_ATTACH,
    883                                0, 0, data, NULL, &data, &cstatus);
     952                               tdb_flags, 0, data, NULL, &data, &cstatus);
    884953        if (!NT_STATUS_IS_OK(status)) {
    885954                DEBUG(0, (__location__ " ctdb_control for db_attach "
     
    12751344        switch (client.ss_family) {
    12761345        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;
    12791348                data.dptr = (uint8_t *)&p4;
    12801349                data.dsize = sizeof(p4);
     
    12821351#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
    12831352        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;
    12861355                data.dptr = (uint8_t *)&p;
    12871356                data.dsize = sizeof(p);
     
    12931362
    12941363        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;
    12951369
    12961370        /*
     
    13761450}
    13771451
    1378 #else
    1379 
    1380 NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
    1381                                struct ctdbd_connection **pconn)
    1382 {
    1383         return NT_STATUS_NOT_IMPLEMENTED;
    1384 }
    1385 
    13861452#endif
Note: See TracChangeset for help on using the changeset viewer.