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/messages_local.c

    r414 r745  
    33   Samba internal messaging functions
    44   Copyright (C) 2007 by Volker Lendecke
    5    
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2222  @{
    2323  @file messages.c
    24  
     24
    2525  @brief  Module for internal messaging between Samba daemons.
    2626
     
    4444
    4545#include "includes.h"
    46 #include "librpc/gen_ndr/messaging.h"
    47 #include "librpc/gen_ndr/ndr_messaging.h"
     46#include "system/filesys.h"
     47#include "messages.h"
     48#include "lib/util/tdb_wrap.h"
    4849
    4950struct messaging_tdb_context {
     
    104105
    105106        ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), 0,
    106                                  TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE,
     107                                 TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
    107108                                 O_RDWR|O_CREAT,0600);
    108109
    109110        if (!ctx->tdb) {
    110111                NTSTATUS status = map_nt_error_from_unix(errno);
    111                 DEBUG(0, ("ERROR: Failed to initialise messages database: "
     112                DEBUG(2, ("ERROR: Failed to initialise messages database: "
    112113                          "%s\n", strerror(errno)));
    113114                TALLOC_FREE(result);
     
    134135}
    135136
     137bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
     138{
     139        struct tdb_wrap *db;
     140
     141        /*
     142         * Open the tdb in the parent process (smbd) so that our
     143         * CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
     144         * work.
     145         */
     146
     147        db = tdb_wrap_open(mem_ctx, lock_path("messages.tdb"), 0,
     148                           TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
     149                           O_RDWR|O_CREAT,0600);
     150        if (db == NULL) {
     151                DEBUG(1, ("could not open messaging.tdb: %s\n",
     152                          strerror(errno)));
     153                return false;
     154        }
     155        return true;
     156}
     157
    136158/*******************************************************************
    137159 Form a static tdb key from a pid.
     
    146168
    147169        SMB_ASSERT(key != NULL);
    148        
     170
    149171        kbuf.dptr = (uint8 *)key;
    150172        kbuf.dsize = strlen(key)+1;
     
    180202
    181203        ndr_err = ndr_pull_struct_blob(
    182                 &blob, result, NULL, result,
     204                &blob, result, result,
    183205                (ndr_pull_flags_fn_t)ndr_pull_messaging_array);
    184206
     
    222244        }
    223245
    224         ndr_err = ndr_push_struct_blob(
    225                 &blob, mem_ctx, NULL, array,
     246        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, array,
    226247                (ndr_push_flags_fn_t)ndr_push_messaging_array);
    227248
     
    361382        rec[msg_array->num_messages].msg_type = msg_type & MSG_TYPE_MASK;
    362383        rec[msg_array->num_messages].dest = pid;
    363         rec[msg_array->num_messages].src = procid_self();
     384        rec[msg_array->num_messages].src = msg_ctx->id;
    364385        rec[msg_array->num_messages].buf = *data;
    365386
     
    372393                goto done;
    373394        }
    374        
     395
    375396        status = message_notify(pid);
    376397
     
    388409
    389410/****************************************************************************
    390  Retrieve all messages for the current process.
     411 Retrieve all messages for a process.
    391412****************************************************************************/
    392413
    393414static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
     415                                      struct server_id id,
    394416                                      TALLOC_CTX *mem_ctx,
    395417                                      struct messaging_array **presult)
    396418{
    397419        struct messaging_array *result;
    398         TDB_DATA key = message_key_pid(mem_ctx, procid_self());
     420        TDB_DATA key = message_key_pid(mem_ctx, id);
    399421        NTSTATUS status;
    400422
     
    444466                   ctx->received_messages));
    445467
    446         status = retrieve_all_messages(tdb->tdb, NULL, &msg_array);
     468        status = retrieve_all_messages(tdb->tdb, msg_ctx->id, NULL, &msg_array);
    447469        if (!NT_STATUS_IS_OK(status)) {
    448470                DEBUG(0, ("message_dispatch: failed to retrieve messages: %s\n",
Note: See TracChangeset for help on using the changeset viewer.