8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:43:03 +01:00

Cleaned up mutexes - removed MUTX_T and related macros

This commit is contained in:
alexpeshkoff 2007-06-06 12:37:24 +00:00
parent 61a2561e2c
commit ea8ba3370d
24 changed files with 517 additions and 472 deletions

View File

@ -157,10 +157,8 @@ static const UCHAR sql_records_info[] = {
isc_info_sql_records
};
#ifdef MULTI_THREAD
static MUTX_T databases_mutex;
static MUTX_T cursors_mutex;
#endif
static Firebird::Mutex databases_mutex;
static Firebird::Mutex cursors_mutex;
#ifdef DSQL_DEBUG
@ -589,10 +587,10 @@ ISC_STATUS GDS_DSQL_EXECUTE_CPP(
request->req_open_cursor = open_cursor;
open_cursor->opn_request = request;
open_cursor->opn_transaction = *trans_handle;
THD_MUTEX_LOCK(&cursors_mutex);
cursors_mutex.enter();
open_cursor->opn_next = open_cursors;
open_cursors = open_cursor;
THD_MUTEX_UNLOCK(&cursors_mutex);
cursors_mutex.leave();
THREAD_EXIT();
ISC_STATUS_ARRAY local_status;
gds__transaction_cleanup(local_status,
@ -841,7 +839,7 @@ ISC_STATUS callback_execute_immediate( ISC_STATUS* status,
dsql_dbb* database = 0;
THREAD_EXIT();
THD_MUTEX_LOCK (&databases_mutex);
databases_mutex.enter();
try
{
// 1. Locate why_db_handle, corresponding to jrd_database_handle
@ -864,14 +862,14 @@ ISC_STATUS callback_execute_immediate( ISC_STATUS* status,
}
catch (const Firebird::Exception& e)
{
THD_MUTEX_UNLOCK(&databases_mutex);
databases_mutex.leave();
THREAD_ENTER();
return e.stuff_exception(status);
}
// 3. Call execute... function
THD_MUTEX_UNLOCK (&databases_mutex);
databases_mutex.leave();
THREAD_ENTER();
const ISC_STATUS rc = dsql8_execute_immediate_common(status,
&database->dbb_database_handle, &why_trans_handle->public_handle,
@ -887,7 +885,7 @@ YValve::Attachment* GetWhyAttachment(ISC_STATUS* status,
Jrd::Attachment* jrd_attachment_handle)
{
THREAD_EXIT();
THD_MUTEX_LOCK (&databases_mutex);
databases_mutex.enter();
dsql_dbb* database;
YValve::Attachment* db_handle = 0;
for (database = databases; database; database = database->dbb_next)
@ -913,7 +911,7 @@ YValve::Attachment* GetWhyAttachment(ISC_STATUS* status,
status[1] = isc_bad_db_handle;
status[2] = isc_arg_end;
}
THD_MUTEX_UNLOCK (&databases_mutex);
databases_mutex.leave();
THREAD_ENTER();
return database ? db_handle : 0;
}
@ -2943,7 +2941,7 @@ static void cleanup_database(FB_API_HANDLE* db_handle, void* flag)
/* if (flag)
THREAD_EXIT();*/
THD_MUTEX_LOCK(&databases_mutex);
databases_mutex.enter();
dsql_dbb* dbb;
for (dsql_dbb** dbb_ptr = &databases; dbb = *dbb_ptr; dbb_ptr = &dbb->dbb_next)
@ -2976,7 +2974,7 @@ static void cleanup_database(FB_API_HANDLE* db_handle, void* flag)
cleanup(0);
gds__unregister_cleanup(cleanup, 0);
}
THD_MUTEX_UNLOCK(&databases_mutex);
databases_mutex.leave();
}
@ -2998,7 +2996,7 @@ static void cleanup_transaction (FB_API_HANDLE tra_handle, void* arg)
// find this transaction/request pair in the list of pairs
THD_MUTEX_LOCK(&cursors_mutex);
cursors_mutex.enter();
dsql_opn** open_cursor_ptr = &open_cursors;
dsql_opn* open_cursor;
while (open_cursor = *open_cursor_ptr)
@ -3007,7 +3005,7 @@ static void cleanup_transaction (FB_API_HANDLE tra_handle, void* arg)
/* Found it, close the cursor but don't remove it from the list.
The close routine will have done that. */
THD_MUTEX_UNLOCK(&cursors_mutex);
cursors_mutex.leave();
/*
* we are expected to be within the subsystem when we do this
* cleanup, for now do a thread_enter/thread_exit here.
@ -3020,14 +3018,14 @@ static void cleanup_transaction (FB_API_HANDLE tra_handle, void* arg)
&open_cursor->opn_request,
DSQL_close);
THREAD_EXIT();
THD_MUTEX_LOCK(&cursors_mutex);
cursors_mutex.enter();
open_cursor_ptr = &open_cursors;
}
else
open_cursor_ptr = &open_cursor->opn_next;
}
THD_MUTEX_UNLOCK(&cursors_mutex);
cursors_mutex.leave();
}
@ -3061,7 +3059,7 @@ static void close_cursor( dsql_req* request)
// Remove the open cursor from the list
THD_MUTEX_LOCK(&cursors_mutex);
cursors_mutex.enter();
dsql_opn** open_cursor_ptr = &open_cursors;
dsql_opn* open_cursor;
for (; open_cursor = *open_cursor_ptr;
@ -3073,7 +3071,7 @@ static void close_cursor( dsql_req* request)
}
}
THD_MUTEX_UNLOCK(&cursors_mutex);
cursors_mutex.leave();
if (open_cursor) {
delete open_cursor;
@ -4200,7 +4198,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
static dsql_dbb* init(FB_API_HANDLE* db_handle)
{
THREAD_EXIT();
THD_MUTEX_LOCK(&databases_mutex);
databases_mutex.enter();
THREAD_ENTER();
if (!init_flag)
@ -4223,7 +4221,7 @@ static dsql_dbb* init(FB_API_HANDLE* db_handle)
}
if (!db_handle) {
THD_MUTEX_UNLOCK(&databases_mutex);
databases_mutex.leave();
return NULL;
}
@ -4233,7 +4231,7 @@ static dsql_dbb* init(FB_API_HANDLE* db_handle)
for (database = databases; database; database = database->dbb_next)
{
if (database->dbb_database_handle == *db_handle) {
THD_MUTEX_UNLOCK(&databases_mutex);
databases_mutex.leave();
return database;
}
}
@ -4244,7 +4242,7 @@ static dsql_dbb* init(FB_API_HANDLE* db_handle)
database->dbb_next = databases;
databases = database;
database->dbb_database_handle = *db_handle;
THD_MUTEX_UNLOCK(&databases_mutex);
databases_mutex.leave();
ISC_STATUS_ARRAY user_status;

View File

@ -1,7 +1,35 @@
/*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
/*
* PROGRAM: JRD Access Method
* MODULE: ids.h
* DESCRIPTION: System relations' field numeric identifiers (and positions)
* MODULE: relations.h
* DESCRIPTION: System relation definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -21,349 +49,394 @@
* Contributor(s): ______________________________________.
*/
enum fids {
f_pag_page = 0,
f_pag_id,
f_pag_seq,
f_pag_type,
// Persistent tables
f_dat_desc = 0,
f_dat_id,
f_dat_class,
f_dat_charset,
f_fld_name = 0,
f_fld_qname,
f_fld_v_blr,
f_fld_v_source,
f_fld_computed,
f_fld_csource,
f_fld_default,
f_fld_dsource,
f_fld_length,
f_fld_scale,
f_fld_type,
f_fld_sub_type,
f_fld_missing,
f_fld_msource,
f_fld_desc,
f_fld_sys_flag,
f_fld_qheader,
f_fld_seg_len,
f_fld_estring,
f_fld_ext_length,
f_fld_ext_scale,
f_fld_ext_type,
f_fld_dimensions,
f_fld_null_flag,
f_fld_char_length,
f_fld_coll_id,
f_fld_charset_id,
f_fld_precision,
f_seg_name = 0,
f_seg_field,
f_seg_position,
f_seg_statistics,
f_idx_name = 0,
f_idx_relation,
f_idx_id,
f_idx_flag,
f_idx_desc,
f_idx_count,
f_idx_inactive,
f_idx_type,
f_idx_foreign,
f_idx_sys_flag,
f_idx_exp_blr,
f_idx_exp_source,
f_idx_statistics,
f_rfr_fname = 0,
f_rfr_rname,
f_rfr_sname,
f_rfr_qname,
f_rfr_base,
f_rfr_estring,
f_rfr_position,
f_rfr_qheader,
f_rfr_flag,
f_rfr_id,
f_rfr_context,
f_rfr_desc,
f_rfr_default,
f_rfr_sys_flag,
f_rfr_class,
f_rfr_complex,
f_rfr_null_flag,
f_rfr_dsource,
f_rfr_coll_id,
f_rel_blr = 0,
f_rel_source,
f_rel_desc,
f_rel_id,
f_rel_sys_flag,
f_rel_key_len,
f_rel_format,
f_rel_field_id,
f_rel_name,
f_rel_class,
f_rel_ext_file,
f_rel_runtime,
f_rel_ext_desc,
f_rel_owner,
f_rel_def_class,
f_rel_flags,
f_rel_type,
f_vrl_vname = 0,
f_vrl_rname,
f_vrl_context,
f_vrl_cname,
f_fmt_rid = 0,
f_fmt_format,
f_fmt_desc,
f_cls_class = 0,
f_cls_acl,
f_cls_desc,
f_file_name = 0,
f_file_seq,
f_file_start,
f_file_length,
f_file_flags,
f_file_shad_num,
f_typ_field = 0,
f_typ_type,
f_typ_name,
f_typ_desc,
f_typ_sys_flag,
f_trg_name = 0,
f_trg_rname,
f_trg_seq,
f_trg_type,
f_trg_source,
f_trg_blr,
f_trg_desc,
f_trg_inactive,
f_trg_sys_flag,
f_trg_flags,
f_trg_valid_blr,
f_dpd_name = 0,
f_dpd_o_name,
f_dpd_f_name,
f_dpd_type,
f_dpd_o_type,
f_fun_name = 0,
f_fun_type,
f_fun_qname,
f_fun_desc,
f_fun_module,
f_fun_entry,
f_fun_ret_arg,
f_fun_sys_flag,
f_arg_fun_name = 0,
f_arg_pos,
f_arg_mech,
f_arg_type,
f_arg_scale,
f_arg_length,
f_arg_sub_type,
f_arg_charset_id,
f_arg_precision,
f_arg_char_length,
f_flt_name = 0,
f_flt_desc,
f_flt_module,
f_flt_entry,
f_flt_input,
f_flt_output,
f_flt_sys_flag,
f_msg_trigger = 0,
f_msg_number,
f_msg_msg,
f_prv_user = 0,
f_prv_grantor,
f_prv_priv,
f_prv_grant,
f_prv_rname,
f_prv_fname,
f_prv_u_type,
f_prv_o_type,
f_trn_id = 0,
f_trn_state,
f_trn_time,
f_trn_desc,
f_gen_name = 0,
f_gen_id,
f_gen_sys_flag,
f_gen_desc,
f_dims_fname = 0,
f_dims_dim,
f_dims_lower,
f_dims_upper,
f_rcon_cname = 0,
f_rcon_ctype,
f_rcon_rname,
f_rcon_dfr,
f_rcon_idfr,
f_rcon_iname,
f_refc_cname = 0,
f_refc_uq,
f_refc_match,
f_refc_upd_rul,
f_refc_del_rul,
f_ccon_cname = 0,
f_ccon_tname,
f_log_name = 0,
f_log_seq,
f_log_length,
f_log_partitions,
f_log_p_offset,
f_log_flags,
f_prc_name = 0,
f_prc_id,
f_prc_inputs,
f_prc_outputs,
f_prc_desc,
f_prc_source,
f_prc_blr,
f_prc_class,
f_prc_owner,
f_prc_runtime,
f_prc_sys_flag,
f_prc_type,
f_prc_valid_blr,
f_prm_name = 0,
f_prm_procedure,
f_prm_number,
f_prm_type,
f_prm_sname,
f_prm_desc,
f_prm_sys_flag,
f_prm_default,
f_prm_dsource,
f_prm_coll_id,
f_prm_null_flag,
f_prm_mech,
f_cs_cs_name = 0,
f_cs_form_of_use,
f_cs_num_chars,
f_cs_def_collate,
f_cs_id,
f_cs_sys_flag,
f_cs_desc,
f_cs_fun_name,
f_cs_bytes_char,
f_coll_name = 0,
f_coll_id,
f_coll_cs_id,
f_coll_attr,
f_coll_sys_flag,
f_coll_desc,
f_coll_fun_name,
f_coll_base_collation_name,
f_coll_specific_attr,
f_xcp_name = 0,
f_xcp_number,
f_xcp_msg,
f_xcp_desc,
f_xcp_sys_flag,
f_rol_name = 0,
f_rol_owner,
f_rol_desc,
f_rol_sys_flag,
f_backup_id = 0,
f_backup_time,
f_backup_level,
f_backup_guid,
f_backup_scn,
f_backup_name,
f_mon_db_name = 0,
f_mon_db_page_size,
f_mon_db_ods_major,
f_mon_db_ods_minor,
f_mon_db_oit,
f_mon_db_oat,
f_mon_db_ost,
f_mon_db_nt,
f_mon_db_page_bufs,
f_mon_db_dialect,
f_mon_db_shut_mode,
f_mon_db_sweep_int,
f_mon_db_read_only,
f_mon_db_forced_writes,
f_mon_db_res_space,
f_mon_db_created,
f_mon_db_pages,
f_mon_att_id = 0,
f_mon_att_server_pid,
f_mon_att_state,
f_mon_att_name,
f_mon_att_user,
f_mon_att_role,
f_mon_att_remote_proto,
f_mon_att_remote_addr,
f_mon_att_remote_pid,
f_mon_att_charset_id,
f_mon_att_timestamp,
f_mon_att_gc,
f_mon_att_remote_process,
f_mon_tra_id = 0,
f_mon_tra_att_id,
f_mon_tra_state,
f_mon_tra_timestamp,
f_mon_tra_top,
f_mon_tra_oit,
f_mon_tra_oat,
f_mon_tra_iso_mode,
f_mon_tra_lock_timeout,
f_mon_tra_read_only,
f_mon_tra_auto_commit,
f_mon_tra_auto_undo,
// Virtual tables
f_mon_stmt_id = 0,
f_mon_stmt_att_id,
f_mon_stmt_tra_id,
f_mon_stmt_state,
f_mon_stmt_timestamp,
f_mon_stmt_sql_text,
f_mon_call_id = 0,
f_mon_call_stmt_id,
f_mon_call_caller_id,
f_mon_call_name,
f_mon_call_type,
f_mon_call_timestamp,
f_mon_call_src_line,
f_mon_call_src_column
};
const USHORT f_pag_page = 0 ;
const USHORT f_pag_id = 1 ;
const USHORT f_pag_seq = 2 ;
const USHORT f_pag_type = 3 ;
const USHORT f_dat_desc = 0 ;
const USHORT f_dat_id = 1 ;
const USHORT f_dat_class = 2 ;
const USHORT f_dat_charset = 3 ;
const USHORT f_fld_name = 0 ;
const USHORT f_fld_qname = 1 ;
const USHORT f_fld_v_blr = 2 ;
const USHORT f_fld_v_source = 3 ;
const USHORT f_fld_computed = 4 ;
const USHORT f_fld_csource = 5 ;
const USHORT f_fld_default = 6 ;
const USHORT f_fld_dsource = 7 ;
const USHORT f_fld_length = 8 ;
const USHORT f_fld_scale = 9 ;
const USHORT f_fld_type = 10 ;
const USHORT f_fld_sub_type = 11 ;
const USHORT f_fld_missing = 12 ;
const USHORT f_fld_msource = 13 ;
const USHORT f_fld_desc = 14 ;
const USHORT f_fld_sys_flag = 15 ;
const USHORT f_fld_qheader = 16 ;
const USHORT f_fld_seg_len = 17 ;
const USHORT f_fld_estring = 18 ;
const USHORT f_fld_ext_length = 19 ;
const USHORT f_fld_ext_scale = 20 ;
const USHORT f_fld_ext_type = 21 ;
const USHORT f_fld_dimensions = 22 ;
const USHORT f_fld_null_flag = 23 ;
const USHORT f_fld_char_length = 24 ;
const USHORT f_fld_coll_id = 25 ;
const USHORT f_fld_charset_id = 26 ;
const USHORT f_fld_precision = 27 ;
const USHORT f_seg_name = 0 ;
const USHORT f_seg_field = 1 ;
const USHORT f_seg_position = 2 ;
const USHORT f_seg_statistics = 3 ;
const USHORT f_idx_name = 0 ;
const USHORT f_idx_relation = 1 ;
const USHORT f_idx_id = 2 ;
const USHORT f_idx_flag = 3 ;
const USHORT f_idx_desc = 4 ;
const USHORT f_idx_count = 5 ;
const USHORT f_idx_inactive = 6 ;
const USHORT f_idx_type = 7 ;
const USHORT f_idx_foreign = 8 ;
const USHORT f_idx_sys_flag = 9 ;
const USHORT f_idx_exp_blr = 10 ;
const USHORT f_idx_exp_source = 11 ;
const USHORT f_idx_statistics = 12 ;
const USHORT f_rfr_fname = 0 ;
const USHORT f_rfr_rname = 1 ;
const USHORT f_rfr_sname = 2 ;
const USHORT f_rfr_qname = 3 ;
const USHORT f_rfr_base = 4 ;
const USHORT f_rfr_estring = 5 ;
const USHORT f_rfr_position = 6 ;
const USHORT f_rfr_qheader = 7 ;
const USHORT f_rfr_flag = 8 ;
const USHORT f_rfr_id = 9 ;
const USHORT f_rfr_context = 10 ;
const USHORT f_rfr_desc = 11 ;
const USHORT f_rfr_default = 12 ;
const USHORT f_rfr_sys_flag = 13 ;
const USHORT f_rfr_class = 14 ;
const USHORT f_rfr_complex = 15 ;
const USHORT f_rfr_null_flag = 16 ;
const USHORT f_rfr_dsource = 17 ;
const USHORT f_rfr_coll_id = 18 ;
const USHORT f_rel_blr = 0 ;
const USHORT f_rel_source = 1 ;
const USHORT f_rel_desc = 2 ;
const USHORT f_rel_id = 3 ;
const USHORT f_rel_sys_flag = 4 ;
const USHORT f_rel_key_len = 5 ;
const USHORT f_rel_format = 6 ;
const USHORT f_rel_field_id = 7 ;
const USHORT f_rel_name = 8 ;
const USHORT f_rel_class = 9 ;
const USHORT f_rel_ext_file = 10 ;
const USHORT f_rel_runtime = 11 ;
const USHORT f_rel_ext_desc = 12 ;
const USHORT f_rel_owner = 13 ;
const USHORT f_rel_def_class = 14 ;
const USHORT f_rel_flags = 15 ;
const USHORT f_rel_type = 16 ;
const USHORT f_vrl_vname = 0 ;
const USHORT f_vrl_rname = 1 ;
const USHORT f_vrl_context = 2 ;
const USHORT f_vrl_cname = 3 ;
const USHORT f_fmt_rid = 0 ;
const USHORT f_fmt_format = 1 ;
const USHORT f_fmt_desc = 2 ;
const USHORT f_cls_class = 0 ;
const USHORT f_cls_acl = 1 ;
const USHORT f_cls_desc = 2 ;
const USHORT f_file_name = 0 ;
const USHORT f_file_seq = 1 ;
const USHORT f_file_start = 2 ;
const USHORT f_file_length = 3 ;
const USHORT f_file_flags = 4 ;
const USHORT f_file_shad_num = 5 ;
const USHORT f_typ_field = 0 ;
const USHORT f_typ_type = 1 ;
const USHORT f_typ_name = 2 ;
const USHORT f_typ_desc = 3 ;
const USHORT f_typ_sys_flag = 4 ;
const USHORT f_trg_name = 0 ;
const USHORT f_trg_rname = 1 ;
const USHORT f_trg_seq = 2 ;
const USHORT f_trg_type = 3 ;
const USHORT f_trg_source = 4 ;
const USHORT f_trg_blr = 5 ;
const USHORT f_trg_desc = 6 ;
const USHORT f_trg_inactive = 7 ;
const USHORT f_trg_sys_flag = 8 ;
const USHORT f_trg_flags = 9 ;
const USHORT f_trg_valid_blr = 10 ;
const USHORT f_trg_debug_info = 11 ;
const USHORT f_dpd_name = 0 ;
const USHORT f_dpd_o_name = 1 ;
const USHORT f_dpd_f_name = 2 ;
const USHORT f_dpd_type = 3 ;
const USHORT f_dpd_o_type = 4 ;
const USHORT f_fun_name = 0 ;
const USHORT f_fun_type = 1 ;
const USHORT f_fun_qname = 2 ;
const USHORT f_fun_desc = 3 ;
const USHORT f_fun_module = 4 ;
const USHORT f_fun_entry = 5 ;
const USHORT f_fun_ret_arg = 6 ;
const USHORT f_fun_sys_flag = 7 ;
const USHORT f_arg_fun_name = 0 ;
const USHORT f_arg_pos = 1 ;
const USHORT f_arg_mech = 2 ;
const USHORT f_arg_type = 3 ;
const USHORT f_arg_scale = 4 ;
const USHORT f_arg_length = 5 ;
const USHORT f_arg_sub_type = 6 ;
const USHORT f_arg_charset_id = 7 ;
const USHORT f_arg_precision = 8 ;
const USHORT f_arg_char_length = 9 ;
const USHORT f_flt_name = 0 ;
const USHORT f_flt_desc = 1 ;
const USHORT f_flt_module = 2 ;
const USHORT f_flt_entry = 3 ;
const USHORT f_flt_input = 4 ;
const USHORT f_flt_output = 5 ;
const USHORT f_flt_sys_flag = 6 ;
const USHORT f_msg_trigger = 0 ;
const USHORT f_msg_number = 1 ;
const USHORT f_msg_msg = 2 ;
const USHORT f_prv_user = 0 ;
const USHORT f_prv_grantor = 1 ;
const USHORT f_prv_priv = 2 ;
const USHORT f_prv_grant = 3 ;
const USHORT f_prv_rname = 4 ;
const USHORT f_prv_fname = 5 ;
const USHORT f_prv_u_type = 6 ;
const USHORT f_prv_o_type = 7 ;
const USHORT f_trn_id = 0 ;
const USHORT f_trn_state = 1 ;
const USHORT f_trn_time = 2 ;
const USHORT f_trn_desc = 3 ;
const USHORT f_gen_name = 0 ;
const USHORT f_gen_id = 1 ;
const USHORT f_gen_sys_flag = 2 ;
const USHORT f_gen_desc = 3 ;
const USHORT f_dims_fname = 0 ;
const USHORT f_dims_dim = 1 ;
const USHORT f_dims_lower = 2 ;
const USHORT f_dims_upper = 3 ;
const USHORT f_rcon_cname = 0 ;
const USHORT f_rcon_ctype = 1 ;
const USHORT f_rcon_rname = 2 ;
const USHORT f_rcon_dfr = 3 ;
const USHORT f_rcon_idfr = 4 ;
const USHORT f_rcon_iname = 5 ;
const USHORT f_refc_cname = 0 ;
const USHORT f_refc_uq = 1 ;
const USHORT f_refc_match = 2 ;
const USHORT f_refc_upd_rul = 3 ;
const USHORT f_refc_del_rul = 4 ;
const USHORT f_ccon_cname = 0 ;
const USHORT f_ccon_tname = 1 ;
const USHORT f_log_name = 0 ;
const USHORT f_log_seq = 1 ;
const USHORT f_log_length = 2 ;
const USHORT f_log_partitions = 3 ;
const USHORT f_log_p_offset = 4 ;
const USHORT f_log_flags = 5 ;
const USHORT f_prc_name = 0 ;
const USHORT f_prc_id = 1 ;
const USHORT f_prc_inputs = 2 ;
const USHORT f_prc_outputs = 3 ;
const USHORT f_prc_desc = 4 ;
const USHORT f_prc_source = 5 ;
const USHORT f_prc_blr = 6 ;
const USHORT f_prc_class = 7 ;
const USHORT f_prc_owner = 8 ;
const USHORT f_prc_runtime = 9 ;
const USHORT f_prc_sys_flag = 10 ;
const USHORT f_prc_type = 11 ;
const USHORT f_prc_valid_blr = 12 ;
const USHORT f_prc_debug_info = 13 ;
const USHORT f_prm_name = 0 ;
const USHORT f_prm_procedure = 1 ;
const USHORT f_prm_number = 2 ;
const USHORT f_prm_type = 3 ;
const USHORT f_prm_sname = 4 ;
const USHORT f_prm_desc = 5 ;
const USHORT f_prm_sys_flag = 6 ;
const USHORT f_prm_default = 7 ;
const USHORT f_prm_dsource = 8 ;
const USHORT f_prm_coll_id = 9 ;
const USHORT f_prm_null_flag = 10 ;
const USHORT f_prm_mech = 11 ;
const USHORT f_cs_cs_name = 0 ;
const USHORT f_cs_form_of_use = 1 ;
const USHORT f_cs_num_chars = 2 ;
const USHORT f_cs_def_collate = 3 ;
const USHORT f_cs_id = 4 ;
const USHORT f_cs_sys_flag = 5 ;
const USHORT f_cs_desc = 6 ;
const USHORT f_cs_fun_name = 7 ;
const USHORT f_cs_bytes_char = 8 ;
const USHORT f_coll_name = 0 ;
const USHORT f_coll_id = 1 ;
const USHORT f_coll_cs_id = 2 ;
const USHORT f_coll_attr = 3 ;
const USHORT f_coll_sys_flag = 4 ;
const USHORT f_coll_desc = 5 ;
const USHORT f_coll_fun_name = 6 ;
const USHORT f_coll_base_collation_name = 7 ;
const USHORT f_coll_specific_attr = 8 ;
const USHORT f_xcp_name = 0 ;
const USHORT f_xcp_number = 1 ;
const USHORT f_xcp_msg = 2 ;
const USHORT f_xcp_desc = 3 ;
const USHORT f_xcp_sys_flag = 4 ;
const USHORT f_rol_name = 0 ;
const USHORT f_rol_owner = 1 ;
const USHORT f_rol_desc = 2 ;
const USHORT f_rol_sys_flag = 3 ;
const USHORT f_backup_id = 0 ;
const USHORT f_backup_time = 1 ;
const USHORT f_backup_level = 2 ;
const USHORT f_backup_guid = 3 ;
const USHORT f_backup_scn = 4 ;
const USHORT f_backup_name = 5 ;
const USHORT f_mon_db_name = 0 ;
const USHORT f_mon_db_page_size = 1 ;
const USHORT f_mon_db_ods_major = 2 ;
const USHORT f_mon_db_ods_minor = 3 ;
const USHORT f_mon_db_oit = 4 ;
const USHORT f_mon_db_oat = 5 ;
const USHORT f_mon_db_ost = 6 ;
const USHORT f_mon_db_nt = 7 ;
const USHORT f_mon_db_page_bufs = 8 ;
const USHORT f_mon_db_dialect = 9 ;
const USHORT f_mon_db_shut_mode = 10 ;
const USHORT f_mon_db_sweep_int = 11 ;
const USHORT f_mon_db_read_only = 12 ;
const USHORT f_mon_db_forced_writes = 13 ;
const USHORT f_mon_db_res_space = 14 ;
const USHORT f_mon_db_created = 15 ;
const USHORT f_mon_db_pages = 16 ;
const USHORT f_mon_att_id = 0 ;
const USHORT f_mon_att_server_pid = 1 ;
const USHORT f_mon_att_state = 2 ;
const USHORT f_mon_att_name = 3 ;
const USHORT f_mon_att_user = 4 ;
const USHORT f_mon_att_role = 5 ;
const USHORT f_mon_att_remote_proto = 6 ;
const USHORT f_mon_att_remote_addr = 7 ;
const USHORT f_mon_att_remote_pid = 8 ;
const USHORT f_mon_att_charset_id = 9 ;
const USHORT f_mon_att_timestamp = 10 ;
const USHORT f_mon_att_gc = 11 ;
const USHORT f_mon_att_remote_process = 12 ;
const USHORT f_mon_tra_id = 0 ;
const USHORT f_mon_tra_att_id = 1 ;
const USHORT f_mon_tra_state = 2 ;
const USHORT f_mon_tra_timestamp = 3 ;
const USHORT f_mon_tra_top = 4 ;
const USHORT f_mon_tra_oit = 5 ;
const USHORT f_mon_tra_oat = 6 ;
const USHORT f_mon_tra_iso_mode = 7 ;
const USHORT f_mon_tra_lock_timeout = 8 ;
const USHORT f_mon_tra_read_only = 9 ;
const USHORT f_mon_tra_auto_commit = 10 ;
const USHORT f_mon_tra_auto_undo = 11 ;
const USHORT f_mon_stmt_id = 0 ;
const USHORT f_mon_stmt_att_id = 1 ;
const USHORT f_mon_stmt_tra_id = 2 ;
const USHORT f_mon_stmt_state = 3 ;
const USHORT f_mon_stmt_timestamp = 4 ;
const USHORT f_mon_stmt_sql_text = 5 ;
const USHORT f_mon_call_id = 0 ;
const USHORT f_mon_call_stmt_id = 1 ;
const USHORT f_mon_call_caller_id = 2 ;
const USHORT f_mon_call_name = 3 ;
const USHORT f_mon_call_type = 4 ;
const USHORT f_mon_call_timestamp = 5 ;
const USHORT f_mon_call_src_line = 6 ;
const USHORT f_mon_call_src_column = 7 ;

View File

@ -52,10 +52,6 @@ static SERVICE_STATUS_HANDLE service_handle;
static Firebird::string* service_name = NULL;
static Firebird::string* remote_name = NULL;
static HANDLE stop_event_handle;
#ifdef NOT_USED_OR_REPLACED
static MUTX_T thread_mutex[1];
static thread* threads;
#endif
void CNTL_init(ThreadEntryPoint* handler, const TEXT* name)
@ -95,8 +91,6 @@ void WINAPI CNTL_main_thread( DWORD argc, char* argv[])
if (!service_handle)
return;
// THD_mutex_init (thread_mutex);
/* start everything, and wait here for ever, or at
* least until we get the stop event indicating that
* the service is stoping. */
@ -135,8 +129,6 @@ void WINAPI CNTL_main_thread( DWORD argc, char* argv[])
CloseServiceHandle(hService);
report_status(SERVICE_STOPPED, last_error, 0, 0);
// THD_mutex_destroy (thread_mutex);
}
void CNTL_shutdown_service(const TEXT* message)

View File

@ -1436,7 +1436,7 @@ void CCH_flush(thread_db* tdbb, USHORT flush_flag, SLONG tra_number)
{
const time_t now = time(0);
THD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_flush_count);
dbb->dbb_mutexes[DBB_MUTX_flush_count].enter();
// If this is the first commit set last_flushed_write to now
if (!dbb->last_flushed_write)
@ -1461,7 +1461,7 @@ void CCH_flush(thread_db* tdbb, USHORT flush_flag, SLONG tra_number)
dbb->unflushed_writes++;
}
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_flush_count);
dbb->dbb_mutexes[DBB_MUTX_flush_count].leave();
}
if (doFlush)

View File

@ -637,7 +637,7 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
// if the request hasn't been compiled or isn't active,
// there're nothing to do
THD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_cmp_clone);
dbb->dbb_mutexes[DBB_MUTX_cmp_clone].enter();
jrd_req* request;
if ((which == IRQ_REQUESTS && !(request = REQUEST(id))) ||
(which == DYN_REQUESTS && !(request = DYN_REQUEST(id))) ||
@ -646,7 +646,7 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
if (request) {
request->req_flags |= req_reserved;
}
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_cmp_clone);
dbb->dbb_mutexes[DBB_MUTX_cmp_clone].leave();
return request;
}
@ -655,7 +655,7 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
for (int n = 1; true; n++) {
if (n > MAX_RECURSION) {
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_cmp_clone);
dbb->dbb_mutexes[DBB_MUTX_cmp_clone].leave();
ERR_post(isc_no_meta_update,
isc_arg_gds, isc_req_depth_exceeded,
isc_arg_number, (SLONG) MAX_RECURSION, 0);
@ -664,7 +664,7 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
jrd_req* clone = CMP_clone_request(tdbb, request, n, false);
if (!(clone->req_flags & (req_active | req_reserved))) {
clone->req_flags |= req_reserved;
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_cmp_clone);
dbb->dbb_mutexes[DBB_MUTX_cmp_clone].leave();
return clone;
}
}

View File

@ -134,7 +134,7 @@ void DYN_ddl(Attachment* attachment, jrd_tra* transaction, USHORT length,
try {
THD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_dyn);
dbb->dbb_mutexes[DBB_MUTX_dyn].enter();
VIO_start_save_point(tdbb, transaction);
transaction->tra_save_point->sav_verb_count++;
@ -143,7 +143,7 @@ void DYN_ddl(Attachment* attachment, jrd_tra* transaction, USHORT length,
transaction->tra_save_point->sav_verb_count--;
VIO_verb_cleanup(tdbb, transaction);
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_dyn);
dbb->dbb_mutexes[DBB_MUTX_dyn].leave();
}
catch (const Firebird::Exception& ex) {
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
@ -158,12 +158,12 @@ void DYN_ddl(Attachment* attachment, jrd_tra* transaction, USHORT length,
VIO_verb_cleanup(tdbb, transaction);
}
catch (const Firebird::Exception&) {
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_dyn);
dbb->dbb_mutexes[DBB_MUTX_dyn].leave();
BUGCHECK(290); /* msg 290 error during savepoint backout */
}
}
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_dyn);
dbb->dbb_mutexes[DBB_MUTX_dyn].leave();
ERR_punt();
}
}

View File

@ -611,7 +611,7 @@ jrd_req* EXE_find_request(thread_db* tdbb, jrd_req* request, bool validate)
if (!request)
BUGCHECK /* REQUEST */ (167); /* msg 167 invalid SEND request */
THD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_clone);
dbb->dbb_mutexes[DBB_MUTX_clone].enter();
jrd_req* clone = NULL;
USHORT count = 0;
if (!(request->req_flags & req_in_use))
@ -642,7 +642,7 @@ jrd_req* EXE_find_request(thread_db* tdbb, jrd_req* request, bool validate)
}
if (count > MAX_CLONES) {
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_clone);
dbb->dbb_mutexes[DBB_MUTX_clone].leave();
ERR_post(isc_req_max_clones_exceeded, 0);
}
if (!clone)
@ -651,7 +651,7 @@ jrd_req* EXE_find_request(thread_db* tdbb, jrd_req* request, bool validate)
clone->req_attachment = tdbb->tdbb_attachment;
clone->req_stats.setParent(&tdbb->tdbb_attachment->att_stats);
clone->req_flags |= req_in_use;
THD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_clone);
dbb->dbb_mutexes[DBB_MUTX_clone].leave();
return clone;
}

View File

@ -47,7 +47,7 @@ struct dir_list {
struct mutexed_dir_list {
dir_list* mdls_dls; /* Pointer to the directory list */
MUTX_T mdls_mutex; /* Mutex for directory list. Must
Firebird::Mutex mdls_mutex; /* Mutex for directory list. Must
be locked before list operations */
mutexed_dir_list()
: mdls_dls(NULL) {}

View File

@ -33,7 +33,7 @@ static void cleanup(void *);
static void init(void);
static IUO free_list = NULL;
static MUTX_T inuse_mutex[1];
static Firebird::Mutex inuse_mutex;
static bool initialized = false;
@ -75,10 +75,10 @@ bool INUSE_cleanup(IUO inuse, FPTR_VOID_PTR cleanup_routine)
IUO* secondary_end_ptr = &secondary_inuse->iuo_next;
while (*secondary_end_ptr)
secondary_end_ptr = &(*secondary_end_ptr)->iuo_next;
THD_MUTEX_LOCK(inuse_mutex);
inuse_mutex.enter();
*secondary_end_ptr = free_list;
free_list = secondary_inuse;
THD_MUTEX_UNLOCK(inuse_mutex);
inuse_mutex.leave();
}
return needed_cleaning;
@ -143,14 +143,14 @@ bool INUSE_insert(IUO inuse, void *new_object, bool dup_flag)
#ifdef DEV_BUILD
gds__log("in-use block overflow. secondary block allocated.");
#endif
THD_MUTEX_LOCK(inuse_mutex);
inuse_mutex.enter();
IUO new_inuse = free_list;
if (new_inuse) {
free_list = new_inuse->iuo_next;
THD_MUTEX_UNLOCK(inuse_mutex);
inuse_mutex.leave();
}
else {
THD_MUTEX_UNLOCK(inuse_mutex);
inuse_mutex.leave();
new_inuse = (IUO) gds__alloc((SLONG) sizeof(struct iuo));
/* FREE: at process exit, by cleanup handler cleanup() in this module */
if (!new_inuse) { /* NOMEM: */

View File

@ -157,10 +157,10 @@ const SSHORT WAIT_PERIOD = -1;
#ifdef V4_THREADING
#ifndef SUPERSERVER
static MUTX_T databases_mutex;
static Firebird::Mutex databases_mutex;
#define V4_JRD_MUTEX_LOCK(mutx) {THREAD_EXIT(); THD_JRD_MUTEX_LOCK(&mutx); THREAD_ENTER();}
#define V4_JRD_MUTEX_UNLOCK(mutx) THD_JRD_MUTEX_UNLOCK(&mutx)
#define V4_JRD_MUTEX_LOCK(mutx) {THREAD_EXIT(); mutx.enter(); THREAD_ENTER();}
#define V4_JRD_MUTEX_UNLOCK(mutx) mutx.leave()
#endif // SUPERSERVER
#endif // V4_THREADING
@ -4426,7 +4426,7 @@ bool JRD_getdir(Firebird::PathName& buf)
#endif // SUPERSERVER
void JRD_mutex_lock(MUTX_PTR mutex)
void JRD_mutex_lock(Firebird::Mutex& mutex)
{
/**************************************
*
@ -4440,12 +4440,12 @@ void JRD_mutex_lock(MUTX_PTR mutex)
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
INUSE_insert(&tdbb->tdbb_mutexes, mutex, true);
THD_MUTEX_LOCK(mutex);
INUSE_insert(&tdbb->tdbb_mutexes, &mutex, true);
mutex.enter();
}
void JRD_mutex_unlock(MUTX_PTR mutex)
void JRD_mutex_unlock(Firebird::Mutex& mutex)
{
/**************************************
*
@ -4459,8 +4459,8 @@ void JRD_mutex_unlock(MUTX_PTR mutex)
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
INUSE_remove(&tdbb->tdbb_mutexes, mutex, false);
THD_MUTEX_UNLOCK(mutex);
INUSE_remove(&tdbb->tdbb_mutexes, &mutex, false);
mutex.leave();
}
@ -5790,7 +5790,7 @@ static Database* init(thread_db* tdbb,
* OPEN.
*
**************************************/
MUTX_T temp_mutx[DBB_MUTX_max];
Firebird::Mutex temp_mutx[DBB_MUTX_max];
// wlck_t temp_wlck[DBB_WLCK_max];
SET_TDBB(tdbb);
@ -5891,7 +5891,7 @@ static Database* init(thread_db* tdbb,
dbb->dbb_next = databases;
databases = dbb;
dbb->dbb_mutexes = FB_NEW(*dbb->dbb_permanent) MUTX_T[DBB_MUTX_max];
dbb->dbb_mutexes = FB_NEW(*dbb->dbb_permanent) Firebird::Mutex[DBB_MUTX_max];
dbb->dbb_internal = vec<jrd_req*>::newVector(*dbb->dbb_permanent, irq_MAX);
dbb->dbb_dyn_req = vec<jrd_req*>::newVector(*dbb->dbb_permanent, drq_MAX);
dbb->dbb_flags |= DBB_exclusive;

View File

@ -229,7 +229,7 @@ public:
trig_vec* dbb_triggers[DB_TRIGGER_MAX];
DatabaseModules modules; // external function/filter modules
MUTX_T *dbb_mutexes; // Database block mutexes
Firebird::Mutex *dbb_mutexes; // Database block mutexes
REC_MUTX_T dbb_sp_rec_mutex; // Recursive mutex for accessing/updating stored procedure metadata
//SLONG dbb_sort_size; // Size of sort space per sort, unused for now

View File

@ -162,8 +162,8 @@ void JRD_database_close(Jrd::Attachment**, Jrd::Attachment**);
void JRD_set_cache_default(ULONG *);
void JRD_blocked(Jrd::Attachment*, Jrd::BlockingThread**);
void JRD_mutex_lock(Firebird::Mutex*);
void JRD_mutex_unlock(Firebird::Mutex*);
void JRD_mutex_lock(Firebird::Mutex&);
void JRD_mutex_unlock(Firebird::Mutex&);
bool JRD_reschedule(Jrd::thread_db*, SLONG, bool);
void JRD_restore_context(void);
void JRD_set_context(Jrd::thread_db*);

View File

@ -46,7 +46,7 @@ class jrd_file : public pool_alloc_rpt<SCHAR, type_fil>
USHORT fil_fudge; /* Fudge factor for page relocation */
int fil_desc;
//int *fil_trace; /* Trace file, if any */
MUTX_T fil_mutex[1];
Firebird::Mutex fil_mutex;
USHORT fil_flags;
USHORT fil_length; /* Length of expanded file name */
SCHAR fil_string[1]; /* Expanded file name */
@ -67,7 +67,7 @@ class jrd_file : public pool_alloc_rpt<SCHAR, type_fil>
USHORT fil_fudge; /* Fudge factor for page relocation */
int fil_desc;
int fil_trace; /* Trace file, if any */
MUTX_T fil_mutex[1];
Firebird::Mutex fil_mutex;
USHORT fil_length; /* Length of expanded file name */
USHORT fil_fid[3]; /* File id */
USHORT fil_did[3]; /* Directory id */
@ -93,7 +93,7 @@ class jrd_file : public pool_alloc_rpt<SCHAR, type_fil>
SLONG fil_desc;
SLONG fil_force_write_desc; /* Handle of force write open */
//int *fil_trace; /* Trace file, if any */
MUTX_T fil_mutex[1];
Firebird::Mutex fil_mutex;
#ifdef SUPERSERVER_V2
void* fil_io_events[MAX_FILE_IO]; /* Overlapped I/O events */
#endif

View File

@ -115,9 +115,7 @@ static bool initialized_signals = false;
static SIG volatile signals = NULL;
static SLONG volatile overflow_count = 0;
#ifdef MULTI_THREAD
static MUTX_T sig_mutex;
#endif
static Firebird::Mutex sig_mutex;
static int process_id = 0;
@ -334,7 +332,7 @@ static bool isc_signal2(
if (!process_id)
process_id = getpid();
THD_MUTEX_LOCK(&sig_mutex);
sig_mutex.enter();
/* See if this signal has ever been cared about before */
@ -377,7 +375,7 @@ static bool isc_signal2(
que_signal(signal_number, handler, arg, flags, old_sig_w_siginfo);
THD_MUTEX_UNLOCK(&sig_mutex);
sig_mutex.leave();
return rc;
}
@ -401,7 +399,7 @@ void ISC_signal_cancel(
SIG sig;
volatile SIG* ptr;
THD_MUTEX_LOCK(&sig_mutex);
sig_mutex.enter();
for (ptr = &signals; sig = *ptr;) {
if (sig->sig_signal == signal_number &&
@ -415,7 +413,7 @@ void ISC_signal_cancel(
ptr = &(*ptr)->sig_next;
}
THD_MUTEX_UNLOCK(&sig_mutex);
sig_mutex.leave();
}

View File

@ -78,15 +78,11 @@ using namespace Jrd;
#endif
#ifdef SUPERSERVER
#define THD_IO_MUTEX_INIT(mutx) THD_MUTEX_INIT(mutx)
#define THD_IO_MUTEX_LOCK(mutx) THD_MUTEX_LOCK(mutx)
#define THD_IO_MUTEX_UNLOCK(mutx) THD_MUTEX_UNLOCK(mutx)
#define THD_IO_MUTEX_DESTROY(mutx) THD_MUTEX_DESTROY(mutx)
#define THD_IO_MUTEX_LOCK(mutx) mutx.enter()
#define THD_IO_MUTEX_UNLOCK(mutx) mutx.leave()
#else
#define THD_IO_MUTEX_INIT(mutx)
#define THD_IO_MUTEX_LOCK(mutx)
#define THD_IO_MUTEX_UNLOCK(mutx)
#define THD_IO_MUTEX_DESTROY(mutx)
#endif
#define IO_RETRY 20
@ -195,9 +191,6 @@ void PIO_close(jrd_file* main_file)
if (file->fil_desc && file->fil_desc != -1) {
close(file->fil_desc);
file->fil_desc = -1;
#ifndef PREAD_PWRITE
THD_IO_MUTEX_DESTROY(file->fil_mutex);
#endif
}
}
}
@ -835,9 +828,6 @@ static jrd_file* setup_file(Database* dbb, const Firebird::PathName& file_name,
file->fil_max_page = -1UL;
MOVE_FAST(file_name.c_str(), file->fil_string, file_name.length());
file->fil_string[file_name.length()] = '\0';
#ifndef PREAD_PWRITE
THD_IO_MUTEX_INIT(file->fil_mutex);
#endif
/* If this isn't the primary file, we're done */

View File

@ -68,7 +68,7 @@
static USHORT initialized_signals = FALSE;
static SLONG volatile overflow_count = 0;
static MUTX_T sig_mutex;
static Firebird::Mutex sig_mutex;
static int process_id = 0;

View File

@ -304,12 +304,12 @@ void PIO_flush(jrd_file* main_file)
{
if (ostype == OS_CHICAGO)
{
THD_MUTEX_LOCK(file->fil_mutex);
file->fil_mutex.enter();
}
FlushFileBuffers((HANDLE) file->fil_desc);
if (ostype == OS_CHICAGO)
{
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
}
}
@ -392,10 +392,10 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
OVERLAPPED overlapped, *overlapped_ptr;
if (ostype == OS_CHICAGO)
{
THD_MUTEX_LOCK(file->fil_mutex);
file->fil_mutex.enter();
if (SetFilePointer(desc, 0, NULL, FILE_BEGIN) == (DWORD) -1)
{
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
nt_error("SetFilePointer", file, isc_io_read_err, 0);
}
overlapped_ptr = NULL;
@ -421,7 +421,7 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
{
if (ostype == OS_CHICAGO)
{
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
nt_error("ReadFile", file, isc_io_read_err, 0);
}
@ -444,7 +444,7 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
#else
if (ostype == OS_CHICAGO)
{
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
nt_error("ReadFile", file, isc_io_read_err, 0);
#endif
@ -456,7 +456,7 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
#endif
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
}
@ -569,7 +569,7 @@ bool PIO_read(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* statu
|| actual_length != size)
{
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return nt_error("ReadFile", file, isc_io_read_err, status_vector);
}
@ -593,7 +593,7 @@ bool PIO_read(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* statu
}
#else
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return nt_error("ReadFile", file, isc_io_read_err, status_vector);
#endif
@ -605,7 +605,7 @@ bool PIO_read(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* statu
#endif
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return true;
@ -793,7 +793,7 @@ bool PIO_write(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* stat
|| actual_length != size)
{
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return nt_error("WriteFile", file, isc_io_write_err, status_vector);
}
@ -814,7 +814,7 @@ bool PIO_write(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* stat
}
#else
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return nt_error("WriteFile", file, isc_io_write_err, status_vector);
#endif
@ -826,7 +826,7 @@ bool PIO_write(jrd_file* file, BufferDesc* bdb, Ods::pag* page, ISC_STATUS* stat
#endif
if (ostype == OS_CHICAGO) {
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
}
return true;
@ -878,14 +878,14 @@ static void release_io_event(jrd_file* file, OVERLAPPED* overlapped)
if (!overlapped || !overlapped->hEvent)
return;
THD_MUTEX_LOCK(file->fil_mutex);
file->fil_mutex.enter();
for (int i = 0; i < MAX_FILE_IO; i++)
if (!file->fil_io_events[i]) {
file->fil_io_events[i] = overlapped->hEvent;
overlapped->hEvent = NULL;
break;
}
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
if (overlapped->hEvent)
CloseHandle(overlapped->hEvent);
@ -929,7 +929,7 @@ static jrd_file* seek_file(jrd_file* file,
UInt32x32To64((DWORD) page, (DWORD) dbb->dbb_page_size);
if (ostype == OS_CHICAGO) {
THD_MUTEX_LOCK(file->fil_mutex);
file->fil_mutex.enter();
HANDLE desc = (HANDLE) ((file->fil_flags & FIL_force_write) ?
file->fil_force_write_desc : file->fil_desc);
@ -937,7 +937,7 @@ static jrd_file* seek_file(jrd_file* file,
(LONG) liOffset.LowPart,
&liOffset.HighPart, FILE_BEGIN) == 0xffffffff)
{
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
nt_error("SetFilePointer", file, isc_io_access_err, status_vector);
return 0;
}
@ -953,14 +953,14 @@ static jrd_file* seek_file(jrd_file* file,
*overlapped_ptr = overlapped;
#ifdef SUPERSERVER_V2
THD_MUTEX_LOCK(file->fil_mutex);
file->fil_mutex.enter();
for (USHORT i = 0; i < MAX_FILE_IO; i++) {
if (overlapped->hEvent = (HANDLE) file->fil_io_events[i]) {
file->fil_io_events[i] = 0;
break;
}
}
THD_MUTEX_UNLOCK(file->fil_mutex);
file->fil_mutex.leave();
if (!overlapped->hEvent &&
!(overlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
{

View File

@ -76,13 +76,13 @@ static bool schedule(void);
static bool schedule_active(bool);
static void stall(THREAD);
static void stall_ast(THREAD);
static void sch_mutex_lock(Firebird::Mutex*);
static void sch_mutex_unlock(Firebird::Mutex*);
static void sch_mutex_lock(Firebird::Mutex&);
static void sch_mutex_unlock(Firebird::Mutex&);
static THREAD free_threads = NULL;
static THREAD active_thread = NULL;
static THREAD ast_thread = NULL;
static MUTX_T thread_mutex[1];
static Firebird::Mutex thread_mutex;
volatile static bool init_flag = false;
static USHORT enabled = FALSE;
@ -780,7 +780,7 @@ static void cleanup(void *arg)
#ifdef SUPERCLIENT
/* use locks */
thread_mutex->enter();
thread_mutex.enter();
if (!init_flag)
return;
@ -821,7 +821,7 @@ static void cleanup(void *arg)
}
thread_mutex->leave();
thread_mutex.leave();
#endif /* SUPERCLIENT */
init_flag = false;
@ -1027,7 +1027,7 @@ static void stall_ast(THREAD thread)
}
static void sch_mutex_lock(Firebird::Mutex* mtx)
static void sch_mutex_lock(Firebird::Mutex& mtx)
{
/**************************************
*
@ -1041,7 +1041,7 @@ static void sch_mutex_lock(Firebird::Mutex* mtx)
**************************************/
try
{
mtx->enter();
mtx.enter();
}
catch (const Firebird::system_call_failed& e)
{
@ -1050,7 +1050,7 @@ static void sch_mutex_lock(Firebird::Mutex* mtx)
}
static void sch_mutex_unlock(Firebird::Mutex* mtx)
static void sch_mutex_unlock(Firebird::Mutex& mtx)
{
/**************************************
*
@ -1064,7 +1064,7 @@ static void sch_mutex_unlock(Firebird::Mutex* mtx)
**************************************/
try
{
mtx->leave();
mtx.leave();
}
catch (const Firebird::system_call_failed& e)
{

View File

@ -359,7 +359,7 @@ static ULONG shutdown_param = 0L;
const char* const SPB_SEC_USERNAME = "isc_spb_sec_username";
static MUTX_T svc_mutex[1], thd_mutex[1];
static Firebird::Mutex svc_mutex, thd_mutex;
/* Service Functions */
#if defined(SERVICE_THREAD) && !defined(BOOT_BUILD)
@ -1809,9 +1809,9 @@ void* SVC_start(Service* service, USHORT spb_length, const SCHAR* spb_data)
ERR_post(isc_bad_spb_form, 0);
}
THD_MUTEX_LOCK(thd_mutex);
thd_mutex.enter();
if (service->svc_flags & SVC_thd_running) {
THD_MUTEX_UNLOCK(thd_mutex);
thd_mutex.leave();
ERR_post(isc_svc_in_use, isc_arg_string,
error_string(serv->serv_name, strlen(serv->serv_name)),
0);
@ -1825,7 +1825,7 @@ void* SVC_start(Service* service, USHORT spb_length, const SCHAR* spb_data)
service->svc_flags = 0;
}
service->svc_flags |= SVC_thd_running;
THD_MUTEX_UNLOCK(thd_mutex);
thd_mutex.leave();
thread_db* tdbb = JRD_get_thread_data();
@ -2661,7 +2661,7 @@ void SVC_finish(Service* service, USHORT flag)
*
**************************************/
THD_MUTEX_LOCK(svc_mutex);
svc_mutex.enter();
if (service && ((flag == SVC_finished) || (flag == SVC_detached)))
{
service->svc_flags |= flag;
@ -2685,7 +2685,7 @@ void SVC_finish(Service* service, USHORT flag)
service->svc_handle = 0;
}
}
THD_MUTEX_UNLOCK(svc_mutex);
svc_mutex.leave();
}

View File

@ -109,7 +109,7 @@ int THD_rec_mutex_lock(REC_MUTX_T * rec_mutex)
{
try
{
rec_mutex->rec_mutx_mtx->enter();
rec_mutex->rec_mutx_mtx.enter();
}
catch (const Firebird::system_call_failed& e)
{
@ -144,7 +144,7 @@ int THD_rec_mutex_unlock(REC_MUTX_T * rec_mutex)
rec_mutex->rec_mutx_id = 0;
try
{
rec_mutex->rec_mutx_mtx->leave();
rec_mutex->rec_mutx_mtx.leave();
}
catch (const Firebird::system_call_failed& e)
{

View File

@ -36,9 +36,14 @@
#include "../common/classes/alloc.h"
#ifdef MULTI_THREAD
inline void THD_mutex_lock(Firebird::Mutex* m) {
m->enter();
}
//
//inline void THD_mutex_lock(Firebird::Mutex* m) {
// m->enter();
//}
//
// THD_mutex_unlock is kept here to preserve INUSE_cleanup()
// logic
//
inline void THD_mutex_unlock(Firebird::Mutex* m) {
m->leave();
}
@ -166,14 +171,9 @@ struct iuo {
typedef iuo *IUO;
/* Mutex structure */
typedef Firebird::Mutex MUTX_T;
typedef Firebird::Mutex* MUTX_PTR;
/* Recursive mutex structure */
struct rec_mutx_t {
MUTX_T rec_mutx_mtx[1];
Firebird::Mutex rec_mutx_mtx;
FB_THREAD_ID rec_mutx_id;
SLONG rec_mutx_count;
};
@ -184,13 +184,9 @@ typedef rec_mutx_t REC_MUTX_T;
#ifdef MULTI_THREAD
#define THD_GLOBAL_MUTEX_LOCK THD_mutex_lock_global()
#define THD_GLOBAL_MUTEX_UNLOCK THD_mutex_unlock_global()
#define THD_MUTEX_LOCK(mutx) THD_mutex_lock(mutx)
#define THD_MUTEX_UNLOCK(mutx) THD_mutex_unlock(mutx)
#else // MULTI_THREAD
#define THD_GLOBAL_MUTEX_LOCK
#define THD_GLOBAL_MUTEX_UNLOCK
#define THD_MUTEX_LOCK(mutx)
#define THD_MUTEX_UNLOCK(mutx)
#endif // MULTI_THREAD
extern "C" {

View File

@ -406,33 +406,27 @@ static WSADATA INET_wsadata;
#ifdef SUPERSERVER
static MUTX_T port_mutex;
static bool port_mutex_inited = false;
static Firebird::Mutex port_mutex;
#define DEFER_PORT_CLEANUP
inline void START_PORT_CRITICAL()
inline void START_PORT_CRITICAL()
{
if (!port_mutex_inited) {
port_mutex_inited = true;
}
THREAD_EXIT();
THD_mutex_lock (&port_mutex);
port_mutex.enter();
THREAD_ENTER();
}
inline void STOP_PORT_CRITICAL()
{
THREAD_EXIT();
THD_mutex_unlock (&port_mutex);
port_mutex.leave();
THREAD_ENTER();
}
#else
inline void START_PORT_CRITICAL() {
}
inline void STOP_PORT_CRITICAL() {
}
inline void START_PORT_CRITICAL() { }
inline void STOP_PORT_CRITICAL() { }
#endif

View File

@ -55,7 +55,7 @@ static SERVICE_STATUS_HANDLE service_handle;
static Firebird::string* service_name = NULL;
static Firebird::string* mutex_name = NULL;
static HANDLE stop_event_handle;
static MUTX_T thread_mutex[1];
static Firebird::Mutex thread_mutex;
static THREAD threads;
static HANDLE hMutex = NULL;
static bool bGuarded = false;
@ -103,10 +103,10 @@ void *CNTL_insert_thread(void)
GetCurrentProcess(), &new_thread->thread_handle, 0, FALSE,
DUPLICATE_SAME_ACCESS);
THD_mutex_lock(thread_mutex);
thread_mutex.enter();
new_thread->thread_next = threads;
threads = new_thread;
THD_mutex_unlock(thread_mutex);
thread_mutex.leave();
return new_thread;
}
@ -188,7 +188,7 @@ void CNTL_remove_thread( void *thread)
* Functional description
*
**************************************/
THD_mutex_lock(thread_mutex);
thread_mutex.enter();
for (THREAD* thread_ptr = &threads;
*thread_ptr; thread_ptr = &(*thread_ptr)->thread_next)
{
@ -197,7 +197,7 @@ void CNTL_remove_thread( void *thread)
break;
}
}
THD_mutex_unlock(thread_mutex);
thread_mutex.leave();
THREAD this_thread = (THREAD) thread;
CloseHandle(this_thread->thread_handle);

View File

@ -146,28 +146,32 @@ inline void make_event_name(char* buffer, size_t size, const char* format, ULONG
fb_utils::snprintf(buffer, size, format, Config::getIpcName(), arg1, arg2, arg3);
}
static MUTX_T xnet_mutex;
static Firebird::Mutex xnet_mutex;
#if defined(SUPERCLIENT)
inline void XNET_LOCK() {
THD_mutex_lock(&xnet_mutex);
xnet_mutex.enter();
}
inline void XNET_UNLOCK() {
THD_mutex_unlock(&xnet_mutex);
xnet_mutex.leave();
}
#elif defined(SUPERSERVER)
inline void XNET_LOCK() {
if (!xnet_shutdown)
{
THREAD_EXIT();
THD_mutex_lock(&xnet_mutex);
}
xnet_mutex.enter();
if (!xnet_shutdown)
{
THREAD_ENTER();
}
}
inline void XNET_UNLOCK() {
THD_mutex_unlock(&xnet_mutex);
xnet_mutex.leave();
}
#else // CS
@ -2125,7 +2129,7 @@ void release_all()
connect_fini();
#endif
THD_mutex_lock(&xnet_mutex);
xnet_mutex.enter();
// release all map stuf left not released by broken ports
@ -2139,7 +2143,7 @@ void release_all()
global_client_maps = NULL;
THD_mutex_unlock(&xnet_mutex);
xnet_mutex.leave();
xnet_initialized = false;
}