Changeset 745 for trunk/server/source3/smbd/notify_internal.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/smbd/notify_internal.c
r414 r745 25 25 26 26 #include "includes.h" 27 #include "system/filesys.h" 27 28 #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" 28 34 29 35 struct notify_context { … … 94 100 95 101 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, 97 103 O_RDWR|O_CREAT, 0644); 98 104 if (notify->db_recursive == NULL) { … … 102 108 103 109 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, 105 111 O_RDWR|O_CREAT, 0644); 106 112 if (notify->db_onelevel == NULL) { … … 129 135 } 130 136 137 bool 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 131 169 /* 132 170 lock and fetch the record … … 179 217 if (blob.length > 0) { 180 218 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, 182 220 (ndr_pull_flags_fn_t)ndr_pull_notify_array); 183 221 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 192 241 193 242 if (!rec) { … … 201 250 compare notify entries for sorting 202 251 */ 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; 252 static int notify_compare(const struct notify_entry *e1, const struct notify_entry *e2) 253 { 207 254 return strcmp(e1->path, e2->path); 208 255 } … … 233 280 NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); 234 281 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, 236 283 (ndr_push_flags_fn_t)ndr_push_notify_array); 237 284 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 271 318 } 272 319 273 ndr_err = ndr_pull_struct_blob(data, tmp_ctx, NULL,&ev,320 ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev, 274 321 (ndr_pull_flags_fn_t)ndr_pull_notify_event); 275 322 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 340 387 d->max_mask_subdir |= e->subdir_filter; 341 388 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); 345 390 346 391 /* recalculate the maximum masks */ … … 389 434 390 435 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, 393 437 (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array); 394 438 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 416 460 array->num_entries += 1; 417 461 418 ndr_err = ndr_push_struct_blob( 419 &blob, rec, NULL, array, 462 ndr_err = ndr_push_struct_blob(&blob, rec, array, 420 463 (ndr_push_flags_fn_t)ndr_push_notify_entry_array); 421 464 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 569 612 570 613 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, 573 615 (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array); 574 616 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 606 648 } 607 649 608 ndr_err = ndr_push_struct_blob( 609 &blob, rec, NULL, array, 650 ndr_err = ndr_push_struct_blob(&blob, rec, array, 610 651 (ndr_push_flags_fn_t)ndr_push_notify_entry_array); 611 652 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 769 810 tmp_ctx = talloc_new(notify); 770 811 771 ndr_err = ndr_push_struct_blob(&data, tmp_ctx, NULL,&ev,812 ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, 772 813 (ndr_push_flags_fn_t)ndr_push_notify_event); 773 814 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 813 854 if (blob.length > 0) { 814 855 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, 817 857 (ndr_pull_flags_fn_t)ndr_pull_notify_entry_array); 818 858 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
Note:
See TracChangeset
for help on using the changeset viewer.