return cci_check_error (err);
}
-/* ------------------------------------------------------------------------ */
-
-cc_int32 ccs_lock_state_allow_read (ccs_lock_state_t in_lock_state,
- ccs_pipe_t in_client_pipe,
- cc_uint32 *out_allow_read)
-{
- cc_int32 err = ccNoError;
- cc_uint32 allow_read = 0;
-
- if (!in_lock_state ) { err = cci_check_error (ccErrBadParam); }
- if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
- if (!out_allow_read ) { err = cci_check_error (ccErrBadParam); }
-
- /* A client may read if no other clients have write locks */
-
- if (!err) {
- cc_uint64 lock_count = in_lock_state->first_pending_lock_index;
- if (lock_count == 0) {
- allow_read = 1;
- } else {
- ccs_lock_t lock = ccs_lock_array_object_at_index (in_lock_state->locks, 0);
- cc_uint32 is_read_lock;
- cc_uint32 is_for_client;
-
- err = ccs_lock_is_read_lock (lock, &is_read_lock);
-
- if (!err) {
- err = ccs_lock_is_for_client (lock, in_client_pipe, &is_for_client);
- }
-
- if (!err) {
- /* read locks or write lock we own */
- allow_read = (is_read_lock || is_for_client);
- }
- }
- }
-
- if (!err) {
- *out_allow_read = allow_read;
- }
-
- return cci_check_error (err);
-}
-
-/* ------------------------------------------------------------------------ */
-
-cc_int32 ccs_lock_state_allow_write (ccs_lock_state_t in_lock_state,
- ccs_pipe_t in_client_pipe,
- cc_uint32 *out_allow_write)
-{
- cc_int32 err = ccNoError;
- cc_uint32 allow_write = 0;
-
- if (!in_lock_state ) { err = cci_check_error (ccErrBadParam); }
- if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
- if (!out_allow_write ) { err = cci_check_error (ccErrBadParam); }
-
- /* A client may write if there are no locks or if it has a write lock */
-
- if (!err) {
- cc_uint64 lock_count = in_lock_state->first_pending_lock_index;
- if (lock_count == 0) {
- allow_write = 1;
- } else {
- ccs_lock_t lock = ccs_lock_array_object_at_index (in_lock_state->locks, 0);
- cc_uint32 is_write_lock = 0;
- cc_uint32 is_for_client = 0;
-
- err = ccs_lock_is_write_lock (lock, &is_write_lock);
-
- if (!err) {
- err = ccs_lock_is_for_client (lock, in_client_pipe, &is_for_client);
- }
-
- if (!err) {
- allow_write = (is_write_lock && is_for_client);
- }
- }
- }
-
- if (!err) {
- *out_allow_write = allow_write;
- }
-
- return cci_check_error (err);
-}
-
#pragma mark -
/* ------------------------------------------------------------------------ */
cc_int32 ccs_lock_state_release (ccs_lock_state_t io_lock_state);
-cc_int32 ccs_lock_state_allow_read (ccs_lock_state_t in_lock_state,
- ccs_pipe_t in_client_pipe,
- cc_uint32 *out_allow_read);
-
-cc_int32 ccs_lock_state_allow_write (ccs_lock_state_t in_lock_state,
- ccs_pipe_t in_client_pipe,
- cc_uint32 *out_allow_write);
-
cc_int32 ccs_lock_state_add (ccs_lock_state_t io_lock_state,
ccs_pipe_t in_client_pipe,
ccs_pipe_t in_reply_pipe,