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/smbd/notify_internal.c

    r414 r745  
    2525
    2626#include "includes.h"
     27#include "system/filesys.h"
    2728#include "librpc/gen_ndr/ndr_notify.h"
     29#include "dbwrap.h"
     30#include "smbd/smbd.h"
     31#include "messages.h"
     32#include "lib/util/tdb_wrap.h"
     33#include "util_tdb.h"
    2834
    2935struct notify_context {
     
    94100
    95101        notify->db_recursive = db_open(notify, lock_path("notify.tdb"),
    96                                        0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
     102                                       0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
    97103                                       O_RDWR|O_CREAT, 0644);
    98104        if (notify->db_recursive == NULL) {
     
    102108
    103109        notify->db_onelevel = db_open(notify, lock_path("notify_onelevel.tdb"),
    104                                       0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
     110                                      0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
    105111                                      O_RDWR|O_CREAT, 0644);
    106112        if (notify->db_onelevel == NULL) {
     
    129135}
    130136
     137bool notify_internal_parent_init(TALLOC_CTX *mem_ctx)
     138{
     139        struct tdb_wrap *db1, *db2;
     140
     141        if (lp_clustering()) {
     142                return true;
     143        }
     144
     145        /*
     146         * Open the tdbs in the parent process (smbd) so that our
     147         * CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
     148         * work.
     149         */
     150
     151        db1 = tdb_wrap_open(mem_ctx, lock_path("notify.tdb"),
     152                            0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
     153                           O_RDWR|O_CREAT, 0644);
     154        if (db1 == NULL) {
     155                DEBUG(1, ("could not open notify.tdb: %s\n", strerror(errno)));
     156                return false;
     157        }
     158        db2 = tdb_wrap_open(mem_ctx, lock_path("notify_onelevel.tdb"),
     159                            0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
     160        if (db2 == NULL) {
     161                DEBUG(1, ("could not open notify_onelevel.tdb: %s\n",
     162                          strerror(errno)));
     163                TALLOC_FREE(db1);
     164                return false;
     165        }
     166        return true;
     167}
     168
    131169/*
    132170  lock and fetch the record
     
    179217        if (blob.length > 0) {
    180218                enum ndr_err_code ndr_err;
    181                 ndr_err = ndr_pull_struct_blob(&blob, notify->array, NULL, notify->array,
     219                ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
    182220                                               (ndr_pull_flags_fn_t)ndr_pull_notify_array);
    183221                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    184                         status = ndr_map_error2ntstatus(ndr_err);
    185                 }
    186         }
    187 
    188         if (DEBUGLEVEL >= 10) {
    189                 DEBUG(10, ("notify_load:\n"));
    190                 NDR_PRINT_DEBUG(notify_array, notify->array);
    191         }
     222                        /* 1. log that we got a corrupt notify_array
     223                         * 2. clear the variable the garbage was stored into to not trip
     224                         *  over it next time this method is entered with the same seqnum
     225                         * 3. delete it from the database */
     226                        DEBUG(2, ("notify_array is corrupt, discarding it\n"));
     227
     228                        ZERO_STRUCTP(notify->array);
     229                        if (rec != NULL) {
     230                                rec->delete_rec(rec);
     231                        }
     232
     233                } else {
     234                        if (DEBUGLEVEL >= 10) {
     235                                DEBUG(10, ("notify_load:\n"));
     236                                NDR_PRINT_DEBUG(notify_array, notify->array);
     237                        }
     238                }
     239        }
     240
    192241
    193242        if (!rec) {
     
    201250  compare notify entries for sorting
    202251*/
    203 static int notify_compare(const void *p1, const void *p2)
    204 {
    205         const struct notify_entry *e1 = (const struct notify_entry *)p1;
    206         const struct notify_entry *e2 = (const struct notify_entry *)p2;
     252static int notify_compare(const struct notify_entry *e1, const struct notify_entry *e2)
     253{
    207254        return strcmp(e1->path, e2->path);
    208255}
     
    233280        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
    234281
    235         ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL, notify->array,
     282        ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
    236283                                      (ndr_push_flags_fn_t)ndr_push_notify_array);
    237284        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    271318        }
    272319
    273         ndr_err = ndr_pull_struct_blob(data, tmp_ctx, NULL, &ev,
     320        ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev,
    274321                                       (ndr_pull_flags_fn_t)ndr_pull_notify_event);
    275322        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    340387        d->max_mask_subdir |= e->subdir_filter;
    341388
    342         if (d->num_entries > 1) {
    343                 qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare);
    344         }
     389        TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare);
    345390
    346391        /* recalculate the maximum masks */
     
    389434
    390435        if (blob.length > 0) {
    391                 ndr_err = ndr_pull_struct_blob(
    392                         &blob, array, NULL, array,
     436                ndr_err = ndr_pull_struct_blob(&blob, array, array,
    393437                        (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array);
    394438                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    416460        array->num_entries += 1;
    417461
    418         ndr_err = ndr_push_struct_blob(
    419                 &blob, rec, NULL, array,
     462        ndr_err = ndr_push_struct_blob(&blob, rec, array,
    420463                (ndr_push_flags_fn_t)ndr_push_notify_entry_array);
    421464        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    569612
    570613        if (blob.length > 0) {
    571                 ndr_err = ndr_pull_struct_blob(
    572                         &blob, array, NULL, array,
     614                ndr_err = ndr_pull_struct_blob(&blob, array, array,
    573615                        (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array);
    574616                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    606648        }
    607649
    608         ndr_err = ndr_push_struct_blob(
    609                 &blob, rec, NULL, array,
     650        ndr_err = ndr_push_struct_blob(&blob, rec, array,
    610651                (ndr_push_flags_fn_t)ndr_push_notify_entry_array);
    611652        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    769810        tmp_ctx = talloc_new(notify);
    770811
    771         ndr_err = ndr_push_struct_blob(&data, tmp_ctx, NULL, &ev,
     812        ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev,
    772813                                       (ndr_push_flags_fn_t)ndr_push_notify_event);
    773814        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    813854        if (blob.length > 0) {
    814855                enum ndr_err_code ndr_err;
    815                 ndr_err = ndr_pull_struct_blob(
    816                         &blob, array, NULL, array,
     856                ndr_err = ndr_pull_struct_blob(&blob, array, array,
    817857                        (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array);
    818858                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
Note: See TracChangeset for help on using the changeset viewer.