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

1) Some simplification inside JRD_reschedule()

2) Cleaned up the unused ALL routines, the only remainings from the old allocator code.
This commit is contained in:
dimitr 2009-04-01 11:33:30 +00:00
parent 1ba465bb55
commit 1b8384583f
6 changed files with 45 additions and 250 deletions

View File

@ -36,9 +36,7 @@
#include "../jrd/gdsassert.h"
#include "../jrd/common.h"
#include "../jrd/dsc.h"
#include "../jrd/all.h"
#include "../jrd/btn.h"
#include "../jrd/all.h"
#include "../jrd/jrd_proto.h"
#include "../jrd/val.h"
#include "../jrd/irq.h"

View File

@ -1,131 +0,0 @@
/*
* PROGRAM: JRD Access Method
* MODULE: all.cpp
* DESCRIPTION: Internal block allocator
*
* 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): ______________________________________.
*/
#include "firebird.h"
#include "../jrd/jrd.h"
#include "../jrd/all.h"
#include <string.h>
#include <stdio.h>
using namespace Jrd;
#ifdef DEV_BUILD
void ALL_check_memory()
{
/**************************************
*
* A L L _ c h e c k _ m e m o r y
*
**************************************
*
* Functional description
* This routine goes through all allocated
* memory pools and checks the hunks of
* memory allocated to make sure they are
* valid. It is designed to be used for
* debugging purposes to find bad memory
* areas as soon as they are corrupted.
* A call to this routine can be made from
* looper() to ensure that it will be regularly
* executed.
*
**************************************/
Database* dbb = GET_DBB();
// walk through all the pools in the database
Firebird::Array<MemoryPool*>::iterator itr;
for (itr = dbb->dbb_pools.begin(); itr < dbb->dbb_pools.end(); ++itr)
{
MemoryPool* pool = *itr;
if (pool) {
// walk through all the hunks in the pool
pool->verify_pool();
}
}
}
#endif /* DEV_BUILD */
void ALL_print_memory_pool_info(FILE* fptr, Database* databases)
{
/***********************************************************
*
* A L L _ p r i n t _ m e m o r y _ p o o l _ i n f o
*
***********************************************************
*
* Functional description
* Print the different block types allocated in the pool.
* Walk the Database's to print out pool info of every database
*
**************************************/
Database* dbb;
Attachment* att;
int i, j, k;
/*fprintf(fptr, "\n\tALL_xx block types\n");
fprintf(fptr, "\t------------------");
for (i = 0, col = 0; i < types->type_MAX; i++) {
if (types->all_block_type_count[i]) {
if (col % 5 == 0)
fprintf(fptr, "\n\t");
fprintf(fptr, "%s = %d ", types->ALL_types[i],
types->all_block_type_count[i]);
++col;
}
}
fprintf(fptr, "\n");*/
// TMN: Note. Evil code.
for (i = 0, dbb = databases; dbb; dbb = dbb->dbb_next, ++i);
fprintf(fptr, "\tNo of dbbs = %d\n", i);
for (k = 1, dbb = databases; dbb; dbb = dbb->dbb_next, ++k)
{
fprintf(fptr, "\n\t dbb #%d -> %s\n", k, dbb->dbb_filename.c_str());
j = 0;
size_t itr;
for (itr = 0; itr < dbb->dbb_pools.getCount(); ++itr)
{
if (dbb->dbb_pools[itr])
{
++j;
}
}
fprintf(fptr, "\t %s has %d pools", dbb->dbb_filename.c_str(), j);
for (j = 0, att = dbb->dbb_attachments; att; att = att->att_next)
{
j++;
}
fprintf(fptr, " and %d attachment(s)\n\n", j);
for (itr = 0; itr < dbb->dbb_pools.getCount(); ++itr)
{
MemoryPool *myPool = dbb->dbb_pools[itr];
if (myPool)
{
myPool->print_contents(fptr, true);
}
}
}
}

View File

@ -1,41 +0,0 @@
/*
* PROGRAM: JRD Access Method
* MODULE: all.h
* DESCRIPTION: Block allocator blocks
*
* 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): ______________________________________.
*/
#ifndef JRD_ALL_H
#define JRD_ALL_H
#include "../common/classes/alloc.h"
#include "../jrd/lls.h"
namespace Jrd {
class Database;
}
void ALL_print_memory_pool_info(FILE*, Jrd::Database*);
#ifdef DEV_BUILD
void ALL_check_memory();
#endif
#endif // JRD_ALL_H

View File

@ -67,7 +67,6 @@
#include "../jrd/extds/ExtDS.h"
#include "../jrd/val.h"
#include "../jrd/rse.h"
#include "../jrd/all.h"
#include "../jrd/fil.h"
#include "../jrd/intl.h"
#include "../jrd/sbm.h"
@ -684,16 +683,6 @@ static const char* ENCRYPT = "encrypt";
static const char* DECRYPT = "decrypt";
void JRD_print_pools(const char* filename)
{
FILE* out = fopen(filename, "w");
if (out)
{
ALL_print_memory_pool_info(out, databases);
fclose(out);
}
}
void trace_failed_attach(TraceManager* traceManager, const char* filename, const DatabaseOptions& options,
bool create, bool no_priv)
{
@ -3961,80 +3950,66 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt)
{
// If database has been shutdown then get out
Attachment* attachment = tdbb->getAttachment();
jrd_tra* transaction = tdbb->getTransaction();
jrd_req* request = tdbb->getRequest();
Attachment* const attachment = tdbb->getAttachment();
jrd_tra* const transaction = tdbb->getTransaction();
jrd_req* const request = tdbb->getRequest();
if (attachment)
try
{
if ((dbb->dbb_ast_flags & DBB_shutdown) && (attachment->att_flags & ATT_shutdown))
if (attachment)
{
const PathName& file_name = attachment->att_filename;
if (punt)
if (attachment->att_flags & ATT_shutdown)
{
CCH_unwind(tdbb, false);
ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name));
if (dbb->dbb_ast_flags & DBB_shutdown)
{
status_exception::raise(Arg::Gds(isc_shutdown) <<
Arg::Str(attachment->att_filename));
}
else if (!(tdbb->tdbb_flags & TDBB_shutdown_manager))
{
status_exception::raise(Arg::Gds(isc_att_shutdown));
}
}
else
// If a cancel has been raised, defer its acknowledgement
// when executing in the context of an internal request or
// the system transaction.
if ((attachment->att_flags & ATT_cancel_raise) &&
!(attachment->att_flags & ATT_cancel_disable))
{
ERR_build_status(tdbb->tdbb_status_vector,
Arg::Gds(isc_shutdown) << Arg::Str(file_name));
return true;
}
}
else if ((attachment->att_flags & ATT_shutdown) && !(tdbb->tdbb_flags & TDBB_shutdown_manager))
{
if (punt)
{
CCH_unwind(tdbb, false);
ERR_post(Arg::Gds(isc_att_shutdown));
}
else
{
ERR_build_status(tdbb->tdbb_status_vector, Arg::Gds(isc_att_shutdown));
return true;
if ((!request ||
!(request->req_flags & (req_internal | req_sys_trigger))) &&
(!transaction || !(transaction->tra_flags & TRA_system)))
{
attachment->att_flags &= ~ATT_cancel_raise;
status_exception::raise(Arg::Gds(isc_cancelled));
}
}
}
// If a cancel has been raised, defer its acknowledgement
// when executing in the context of an internal request or
// the system transaction.
// Handle request cancellation
if ((attachment->att_flags & ATT_cancel_raise) &&
!(attachment->att_flags & ATT_cancel_disable))
if (transaction && (transaction->tra_flags & TRA_cancel_request))
{
if ((!request ||
!(request->req_flags & (req_internal | req_sys_trigger))) &&
(!transaction || !(transaction->tra_flags & TRA_system)))
{
attachment->att_flags &= ~ATT_cancel_raise;
if (punt)
{
CCH_unwind(tdbb, false);
ERR_post(Arg::Gds(isc_cancelled));
}
else
{
ERR_build_status(tdbb->tdbb_status_vector, Arg::Gds(isc_cancelled));
return true;
}
}
transaction->tra_flags &= ~TRA_cancel_request;
status_exception::raise(Arg::Gds(isc_cancelled));
}
}
// Handle request cancellation
if (transaction && (transaction->tra_flags & TRA_cancel_request))
catch (const status_exception& ex)
{
transaction->tra_flags &= ~TRA_cancel_request;
tdbb->tdbb_flags |= TDBB_sys_error;
if (punt) {
const Arg::StatusVector status(ex.value());
if (punt)
{
CCH_unwind(tdbb, false);
ERR_post(Arg::Gds(isc_cancelled));
ERR_post(status);
}
else {
ERR_build_status(tdbb->tdbb_status_vector, Arg::Gds(isc_cancelled));
else
{
ERR_build_status(tdbb->tdbb_status_vector, status);
return true;
}
}
@ -4042,7 +4017,8 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt)
// Enable signal handler for the monitoring stuff
if (dbb->dbb_ast_flags & DBB_monitor_off) {
if (dbb->dbb_ast_flags & DBB_monitor_off)
{
dbb->dbb_ast_flags &= ~DBB_monitor_off;
LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT);
}
@ -4173,8 +4149,6 @@ static void check_transaction(thread_db* tdbb, jrd_tra* transaction)
if (transaction && (transaction->tra_flags & TRA_cancel_request))
{
transaction->tra_flags &= ~TRA_cancel_request;
tdbb->tdbb_flags |= TDBB_sys_error;
status_exception::raise(Arg::Gds(isc_cancelled));
}
}
@ -6505,7 +6479,7 @@ void JRD_compile(thread_db* tdbb,
jrd_req** req_handle,
SSHORT blr_length,
const UCHAR* blr,
Firebird::RefStrPtr ref_str,
RefStrPtr ref_str,
USHORT dbginfo_length, const UCHAR* dbginfo)
{
/**************************************

View File

@ -34,9 +34,7 @@
#include "../jrd/gdsassert.h"
#include "../jrd/common.h"
#include "../jrd/dsc.h"
#include "../jrd/all.h"
#include "../jrd/btn.h"
#include "../jrd/all.h"
#include "../jrd/jrd_proto.h"
#include "../jrd/val.h"

View File

@ -132,9 +132,6 @@ UCHAR* JRD_num_attachments(UCHAR* const, USHORT, JRD_info_tag, ULONG*, ULONG*);
bool JRD_reschedule(Jrd::thread_db*, SLONG, bool);
// Call this function from the debugger if desired
void JRD_print_pools(const char* filename);
#ifdef DEBUG_PROCS
void JRD_print_procedure_info(Jrd::thread_db*, const char*);
#endif