vms_tdb.c modifications

Dave Jones JONESD at er6s1.eng.ohio-state.edu
Thu Jun 26 13:13:53 GMT 2003

I did some further modifications to vms_tdb.c/tdb.h, available at


   - Increase the maximum record size to 2036 bytes.

   - Fixed a bug in the TDB_INTERNAL mode operation (only the [.locking]posix.c
     module appears to use an 'internal' tdb.

   - Save the last key as well as the last hash in the TDB_CONTEXT structure.
     The optimization in fetch() now checks the last key is the same as
     well as the last hash.

   - The TDB_DATA items returned by the external functions now point to
     dynamically allocated copies of the data rather have the dptr field point
     to internal data buffers.  The main samba code assumes the dptr field
     contains an address returned by malloc() and can free() or realloc it.

   - Redid the CLEAR_IF_FIRST handling, the initialization logic is
          Generate resource name (SMBTDB_'fname').

          if CLEAR_IF_FIRST then
	     lock resource with CR (concurrent read) mode lock.
             convert lock to PW (protected write) mode lock with NOQUEUE flag.
             if conversion succeeds then
                  zero the database.
             convert lock to PR (protected read) mode. 
             lock resource with PR (protected read) mode lock.


      The idea is that the first person can get the PW mode lock because
      there is no contention.  Subsequent users will fail to get the PW
      mode lock and then the conversion to PR mode will force them to wait
      until the guy with the PW lock completes the file initialization (and
      lowers his lock to PR mode.  Passing through CR mode is probably

David L. Jones               |      Phone:    (614) 292-6929
Ohio State University        |      Internet:
140 W. 19th St. Rm. 231a     |               jonesd at er6s1.eng.ohio-state.edu
Columbus, OH 43210           |               vman+ at osu.edu

Disclaimer: I'm looking for marbles all day long.

More information about the samba-vms mailing list