head 1.2; access; symbols RPM_4_2_1:1.1.1.5 RPM_4_2:1.1.1.5 RPM_4_1_1:1.1.1.5 RPM_4_1:1.1.1.4 RPM_4_0_5:1.1.1.3 RPM_4_0_4:1.1.1.2 RPM_4_0_3:1.1.1.1 RPM:1.1.1; locks; strict; comment @# @; 1.2 date 2008.01.02.09.58.55; author rse; state dead; branches; next 1.1; commitid z4cpSiAhOCXk5PLs; 1.1 date 2001.05.13.19.58.32; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.05.13.19.58.32; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2002.01.07.22.30.58; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2003.01.18.13.49.10; author rse; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2001.10.15.03.47.27; author rse; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2003.01.18.14.05.14; author rse; state Exp; branches; next ; desc @@ 1.2 log @remove the ancient RPM 4.2.1 source tree copy @ text @

Locking Commands

Most locking commands work with the environment handle.  However, when a user gets a lock we create a new lock handle that they then use with in a similar manner to all the other handles to release the lock.  We present the general locking functions first, and then those that manipulate locks.

> <env> lock_detect [default|oldest|youngest|random]

This command runs the deadlock detector.  It directly translates to the lock_detect DB call.  It returns either a 0 (for success), a DB error message or it throws a Tcl error with a system message.  The first argument sets the policy for deadlock as follows:



> <env> lock_stat

This command returns a list of name/value pairs where the names correspond to the C-structure field names of DB_LOCK_STAT and the values are the data returned.  This command is a direct translation of the lock_stat DB call.



> <env> lock_id

This command returns a unique locker ID value.  It directly translates to the lock_id DB call.



> <env> lock_get [-nowait]lockmode locker obj

This command gets a lock. It will invoke the lock_get function.  After it successfully gets a handle to a lock, we bind it to a new Tcl command of the form $env.lockX, where X is an integer starting at  0 (e.g. $env.lock0, $env.lock1, etc).  We use the Tcl_CreateObjCommand() to create the top level locking command function.  It is through this handle that the user can release the lock.  Internally, the handle we get back from DB will be stored as the ClientData portion of the new command set so that future locking calls will have that handle readily available.

The arguments are:



> <lock> put

This command releases the lock referenced by the command.  It is a direct translation of the lock_put function.  It returns either a 0 (for success), a DB error message or it throws a Tcl error with a system message.  Additionally, since the handle is no longer valid, we will call Tcl_DeleteCommand() so that further uses of the handle will be dealt with properly by Tcl itself.



> <env> lock_vec [-nowait] locker {get|put|put_all|put_obj [obj] [lockmode] [lock]} ...

This command performs a series of lock calls.  It is a direct translation of the lock_vec function.  This command will return a list of the return values from each operation specified in the argument list.  For the 'put' operations the entry in the return value list is either a 0 (for success) or an error.  For the 'get' operation, the entry is the lock widget handle, $env.lockN (as described above in <env> lock_get) or an error.  If an error occurs, the return list will contain the return values for all the successful operations up the erroneous one and the error code for that operation.  Subsequent operations will be ignored.

As for the other operations, if we are doing a 'get' we will create the commands and if we are doing a 'put' we will have to delete the commands.  Additionally, we will have to do this after the call to the DB lock_vec and iterate over the results, creating and/or deleting Tcl commands.  It is possible that we may return a lock widget from a get operation that is considered invalid, if, for instance, there was a put_all operation performed later in the vector of operations.  The arguments are:

@ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @Import: RPM 4.0.3 @ text @@ 1.1.1.2 log @Import: RPM 4.0.4 @ text @d1 7 a7 7 d9 2 a10 2

Locking Commands

d16 3 a18 3

> <env> lock_detect [default|oldest|youngest|random]

This command runs the deadlock detector.  It directly translates to the lock_detect DB call.  d22 18 a39 19



> <env> lock_stat

This command returns a list of name/value pairs where the names correspond d41 1 a41 1 returned.  This command is a direct translation of the lock_stat d43 8 a50 21



> <env> lock_id

This command returns a unique locker ID value.  It directly translates to the lock_id DB call.



> <env> lock_id_free  locker

This command frees the locker allockated by the lock_id call. It directly translates to the  lock_id_free DB call.



> <env> lock_id_set  current max

This  is a diagnostic command to set the locker id that will get allocated next and the maximum id that
will trigger the id reclaim algorithm.



> <env> lock_get [-nowait]lockmode locker obj

This command gets a lock. It will invoke the lock_get d52 3 a54 3 it to a new Tcl command of the form $env.lockX, where X is an integer starting at  0 (e.g. $env.lock0, $env.lock1, etc).  We use the Tcl_CreateObjCommand() to create the top level locking d57 1 a57 1 as the ClientData portion of the new command set so that future d59 41 a99 41

The arguments are:



> <lock> put

This command releases the lock referenced by the command.  It is a direct translation of the lock_put d103 2 a104 2 Tcl_DeleteCommand() so d106 7 a112 7



> <env> lock_vec [-nowait] locker {get|put|put_all|put_obj [obj] [lockmode] [lock]} ...

This command performs a series of lock calls.  It is a direct translation of the lock_vec function.  d116 2 a117 2 For the 'get' operation, the entry is the lock widget handle, $env.lockN (as described above in <env> lock_get) d122 1 a122 1

As for the other operations, if we are doing a 'get' we will create d127 1 a127 1 is considered invalid, if, for instance, there was a put_all operation d129 8 a136 8



> <env> lock_timeout timeout

This command sets the lock timeout for all future locks in this environment.  The timeout is in micorseconds.
 
  @ 1.1.1.3 log @Import: RPM 4.0.5 @ text @d1 1 a1 2 @ 1.1.1.4 log @Import: RPM 4.1 @ text @d1 2 a2 1 @ 1.1.1.5 log @Import: RPM 4.1.1 @ text @d1 1 a1 2 @