mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:03:03 +01:00
Fixed my bug in alice. Also some style changes and cleanup.
This commit is contained in:
parent
4053524807
commit
edf58bab73
@ -24,7 +24,7 @@
|
|||||||
//
|
//
|
||||||
//____________________________________________________________
|
//____________________________________________________________
|
||||||
//
|
//
|
||||||
// $Id: alice.cpp,v 1.70 2004-08-30 18:10:28 alexpeshkoff Exp $
|
// $Id: alice.cpp,v 1.71 2004-09-01 14:51:33 alexpeshkoff Exp $
|
||||||
//
|
//
|
||||||
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
||||||
// conditionals, as the engine now fully supports
|
// conditionals, as the engine now fully supports
|
||||||
@ -193,19 +193,8 @@ int common_main(int argc,
|
|||||||
fAnsiCP = (GetConsoleCP() == GetACP());
|
fAnsiCP = (GetConsoleCP() == GetACP());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AliceGlobals* tdgbl = 0;
|
AliceGlobals gblInstance(output_proc, output_data);
|
||||||
try
|
AliceGlobals* tdgbl = &gblInstance;
|
||||||
{
|
|
||||||
// FREE: during function exit in catch
|
|
||||||
tdgbl = FB_NEW(*getDefaultMemoryPool())
|
|
||||||
AliceGlobals(*getDefaultMemoryPool(), output_proc, output_data);
|
|
||||||
}
|
|
||||||
catch (std::bad_alloc)
|
|
||||||
{
|
|
||||||
// NOMEM: return error, FREE: during function exit in catch
|
|
||||||
return FINI_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
AliceGlobals::putSpecific(tdgbl);
|
AliceGlobals::putSpecific(tdgbl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -626,15 +615,14 @@ int common_main(int argc,
|
|||||||
int exit_code = tdgbl->exit_code;
|
int exit_code = tdgbl->exit_code;
|
||||||
|
|
||||||
// Close the status output file
|
// Close the status output file
|
||||||
if (tdgbl->sw_redirect == REDIRECT && tdgbl->output_file != NULL) {
|
if (tdgbl->sw_redirect == REDIRECT && tdgbl->output_file != NULL)
|
||||||
|
{
|
||||||
fclose(tdgbl->output_file);
|
fclose(tdgbl->output_file);
|
||||||
tdgbl->output_file = NULL;
|
tdgbl->output_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AliceGlobals::restoreSpecific();
|
AliceGlobals::restoreSpecific();
|
||||||
|
|
||||||
delete tdgbl;
|
|
||||||
|
|
||||||
#if defined(DEBUG_GDS_ALLOC) && !defined(SUPERSERVER)
|
#if defined(DEBUG_GDS_ALLOC) && !defined(SUPERSERVER)
|
||||||
gds_alloc_report(0, __FILE__, __LINE__);
|
gds_alloc_report(0, __FILE__, __LINE__);
|
||||||
#endif
|
#endif
|
||||||
|
@ -162,16 +162,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AliceGlobals(MemoryPool& p, Jrd::pfn_svc_output outProc, Jrd::Service* outData)
|
AliceGlobals(Jrd::pfn_svc_output outProc, Jrd::Service* outData)
|
||||||
: ThreadData(ThreadData::tddALICE), pools(p),
|
: ThreadData(ThreadData::tddALICE),
|
||||||
output_proc(outProc), output_data(outData),
|
output_proc(outProc), output_data(outData),
|
||||||
ALICE_permanent_pool(0), ALICE_default_pool(0)
|
ALICE_default_pool(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~AliceGlobals()
|
|
||||||
{
|
|
||||||
subsystemCleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
AliceMemoryPool* getDefaultPool()
|
AliceMemoryPool* getDefaultPool()
|
||||||
{
|
{
|
||||||
@ -179,10 +175,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
user_action ALICE_data;
|
user_action ALICE_data;
|
||||||
AliceMemoryPool* ALICE_permanent_pool;
|
|
||||||
ISC_STATUS_ARRAY status_vector;
|
ISC_STATUS_ARRAY status_vector;
|
||||||
typedef Firebird::HalfStaticArray<AliceMemoryPool*, 4> PoolsArray;
|
|
||||||
PoolsArray pools;
|
|
||||||
int exit_code;
|
int exit_code;
|
||||||
Jrd::pfn_svc_output output_proc;
|
Jrd::pfn_svc_output output_proc;
|
||||||
Jrd::Service* output_data;
|
Jrd::Service* output_data;
|
||||||
@ -197,7 +190,9 @@ public:
|
|||||||
|
|
||||||
#ifdef SUPERSERVER
|
#ifdef SUPERSERVER
|
||||||
static inline AliceGlobals* getSpecific() {
|
static inline AliceGlobals* getSpecific() {
|
||||||
return (AliceGlobals*) ThreadData::getSpecific();
|
ThreadData* tData = ThreadData::getSpecific();
|
||||||
|
fb_assert (tData->getType() == ThreadData::tddALICE)
|
||||||
|
return (AliceGlobals*) tData;
|
||||||
}
|
}
|
||||||
static inline void putSpecific(AliceGlobals* tdgbl) {
|
static inline void putSpecific(AliceGlobals* tdgbl) {
|
||||||
tdgbl->ThreadData::putSpecific();
|
tdgbl->ThreadData::putSpecific();
|
||||||
@ -215,20 +210,6 @@ public:
|
|||||||
static inline void restoreSpecific() {
|
static inline void restoreSpecific() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
// Perform AliceGlobals cleanup
|
|
||||||
void subsystemCleanup(void)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pools.getCount(); ++i)
|
|
||||||
{
|
|
||||||
AliceMemoryPool::deletePool(pools[i]);
|
|
||||||
pools[i] = 0;
|
|
||||||
}
|
|
||||||
pools.clear();
|
|
||||||
setDefaultPool(0);
|
|
||||||
ALICE_permanent_pool = 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Firebird::SubsystemContextPoolHolder <AliceGlobals, AliceMemoryPool>
|
typedef Firebird::SubsystemContextPoolHolder <AliceGlobals, AliceMemoryPool>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//
|
//
|
||||||
//____________________________________________________________
|
//____________________________________________________________
|
||||||
//
|
//
|
||||||
// $Id: all.cpp,v 1.28 2004-08-30 18:10:28 alexpeshkoff Exp $
|
// $Id: all.cpp,v 1.29 2004-09-01 14:51:33 alexpeshkoff Exp $
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "firebird.h"
|
#include "firebird.h"
|
||||||
@ -34,114 +34,12 @@
|
|||||||
#include "../jrd/thd.h"
|
#include "../jrd/thd.h"
|
||||||
#include "../common/classes/alloc.h"
|
#include "../common/classes/alloc.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOT_USED_OR_REPLACED
|
|
||||||
void AliceMemoryPool::ALLA_push(blk* object, alice_lls** stack)
|
|
||||||
{
|
|
||||||
/**************************************
|
|
||||||
*
|
|
||||||
* A L L _ p u s h
|
|
||||||
*
|
|
||||||
**************************************
|
|
||||||
*
|
|
||||||
* Functional description
|
|
||||||
* Push an object on an LLS stack.
|
|
||||||
*
|
|
||||||
**************************************/
|
|
||||||
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
|
||||||
AliceMemoryPool* pool = tdgbl->ALICE_default_pool;
|
|
||||||
|
|
||||||
alice_lls* node = pool->lls_cache.newBlock();
|
|
||||||
node->lls_object = object;
|
|
||||||
node->lls_next = *stack;
|
|
||||||
*stack = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BLK AliceMemoryPool::ALLA_pop(alice_lls** stack)
|
|
||||||
{
|
|
||||||
/**************************************
|
|
||||||
*
|
|
||||||
* A L L _ p o p
|
|
||||||
*
|
|
||||||
**************************************
|
|
||||||
*
|
|
||||||
* Functional description
|
|
||||||
* Pop an object off a linked list stack. Save the node for
|
|
||||||
* further use.
|
|
||||||
*
|
|
||||||
**************************************/
|
|
||||||
alice_lls* node = *stack;
|
|
||||||
*stack = node->lls_next;
|
|
||||||
BLK object = node->lls_object;
|
|
||||||
|
|
||||||
AliceMemoryPool* pool = (AliceMemoryPool*)MemoryPool::blk _pool(node);
|
|
||||||
pool->lls_cache.returnBlock(node);
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
AliceMemoryPool* AliceMemoryPool::create_new_pool(MemoryPool* parent)
|
|
||||||
{
|
|
||||||
/**************************************
|
|
||||||
*
|
|
||||||
* A L L _ p o o l
|
|
||||||
*
|
|
||||||
**************************************
|
|
||||||
*
|
|
||||||
* Functional description
|
|
||||||
* Allocate a new pool.
|
|
||||||
*
|
|
||||||
**************************************/
|
|
||||||
|
|
||||||
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
|
||||||
|
|
||||||
// TMN: John, is this correct?
|
|
||||||
AliceMemoryPool* pool = new(0, parent) AliceMemoryPool(parent);
|
|
||||||
AliceGlobals::pool_vec_t::iterator curr;
|
|
||||||
|
|
||||||
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
|
|
||||||
{
|
|
||||||
if (!*curr)
|
|
||||||
{
|
|
||||||
*curr = pool;
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tdgbl->pools.resize(tdgbl->pools.size() + 10);
|
|
||||||
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
|
|
||||||
{
|
|
||||||
if (!*curr)
|
|
||||||
{
|
|
||||||
*curr = pool;
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//fb_assert(0);
|
|
||||||
//BUGCHECK ("ALLA_fini - finishing before starting");
|
|
||||||
return 0;//pool; // Never reached, but makes the compiler happy.
|
|
||||||
}
|
|
||||||
#endif //NOT_USED_OR_REPLACED
|
|
||||||
|
|
||||||
AliceMemoryPool* AliceMemoryPool::createPool() {
|
AliceMemoryPool* AliceMemoryPool::createPool() {
|
||||||
AliceMemoryPool* result = (AliceMemoryPool*)internal_create(sizeof(AliceMemoryPool));
|
AliceMemoryPool* result = (AliceMemoryPool*)internal_create(sizeof(AliceMemoryPool));
|
||||||
AliceGlobals::getSpecific()->pools.add(result);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AliceMemoryPool::deletePool(AliceMemoryPool* pool)
|
void AliceMemoryPool::deletePool(AliceMemoryPool* pool)
|
||||||
{
|
{
|
||||||
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
|
||||||
|
|
||||||
for (int i = 0; i < tdgbl->pools.getCount(); ++i)
|
|
||||||
{
|
|
||||||
if (tdgbl->pools[i] == pool)
|
|
||||||
{
|
|
||||||
tdgbl->pools.remove(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MemoryPool::deletePool(pool);
|
MemoryPool::deletePool(pool);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
#ifndef ALICE_ALL_H
|
#ifndef ALICE_ALL_H
|
||||||
#define ALICE_ALL_H
|
#define ALICE_ALL_H
|
||||||
|
|
||||||
#include "../jrd/block_cache.h"
|
#include "../common/classes/auto.h"
|
||||||
|
#include "../common/classes/alloc.h"
|
||||||
|
|
||||||
class AliceMemoryPool : public MemoryPool
|
class AliceMemoryPool : public MemoryPool
|
||||||
{
|
{
|
||||||
@ -35,7 +36,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static AliceMemoryPool* createPool();
|
static AliceMemoryPool* createPool();
|
||||||
static void deletePool(AliceMemoryPool* pool);
|
static void deletePool(AliceMemoryPool* pool);
|
||||||
|
static void clear(AliceMemoryPool* ptr)
|
||||||
|
{
|
||||||
|
deletePool(ptr);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef Firebird::AutoPtr<AliceMemoryPool, AliceMemoryPool> AliceAutoPool;
|
||||||
|
|
||||||
#endif // ALICE_ALL_H
|
#endif // ALICE_ALL_H
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//
|
//
|
||||||
//____________________________________________________________
|
//____________________________________________________________
|
||||||
//
|
//
|
||||||
// $Id: exe.cpp,v 1.37 2004-08-30 18:10:28 alexpeshkoff Exp $
|
// $Id: exe.cpp,v 1.38 2004-09-01 14:51:33 alexpeshkoff Exp $
|
||||||
//
|
//
|
||||||
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
||||||
// conditionals, as the engine now fully supports
|
// conditionals, as the engine now fully supports
|
||||||
@ -82,20 +82,24 @@ static inline void stuff_dpb_long(UCHAR** d, int blr)
|
|||||||
//
|
//
|
||||||
|
|
||||||
int EXE_action(const TEXT* database, const ULONG switches)
|
int EXE_action(const TEXT* database, const ULONG switches)
|
||||||
|
{
|
||||||
|
bool error = false;
|
||||||
|
AliceAutoPool newPool(AliceMemoryPool::createPool());
|
||||||
{
|
{
|
||||||
UCHAR dpb[128];
|
UCHAR dpb[128];
|
||||||
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
||||||
AliceContextPoolHolder context(tdgbl, AliceMemoryPool::createPool());
|
AliceContextPoolHolder context(tdgbl, newPool);
|
||||||
|
|
||||||
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
||||||
|
{
|
||||||
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// generate the database parameter block for the attach,
|
// generate the database parameter block for the attach,
|
||||||
// based on the various switches
|
// based on the various switches
|
||||||
|
|
||||||
const USHORT dpb_length = build_dpb(dpb, switches);
|
const USHORT dpb_length = build_dpb(dpb, switches);
|
||||||
|
|
||||||
bool error = false;
|
|
||||||
FB_API_HANDLE handle = 0;
|
FB_API_HANDLE handle = 0;
|
||||||
isc_attach_database(tdgbl->status, 0, database, &handle, dpb_length,
|
isc_attach_database(tdgbl->status, 0, database, &handle, dpb_length,
|
||||||
reinterpret_cast<SCHAR*>(dpb));
|
reinterpret_cast<SCHAR*>(dpb));
|
||||||
@ -111,11 +115,15 @@ int EXE_action(const TEXT* database, const ULONG switches)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tdgbl->status[2] == isc_arg_warning)
|
if (tdgbl->status[2] == isc_arg_warning)
|
||||||
|
{
|
||||||
ALICE_print_status(tdgbl->status);
|
ALICE_print_status(tdgbl->status);
|
||||||
|
}
|
||||||
|
|
||||||
if (handle != 0) {
|
if (handle != 0)
|
||||||
|
{
|
||||||
UCHAR error_string[128];
|
UCHAR error_string[128];
|
||||||
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) {
|
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check))
|
||||||
|
{
|
||||||
isc_database_info(tdgbl->status, &handle, sizeof(val_errors),
|
isc_database_info(tdgbl->status, &handle, sizeof(val_errors),
|
||||||
val_errors, sizeof(error_string),
|
val_errors, sizeof(error_string),
|
||||||
reinterpret_cast<char*>(error_string));
|
reinterpret_cast<char*>(error_string));
|
||||||
@ -124,10 +132,13 @@ int EXE_action(const TEXT* database, const ULONG switches)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (switches & sw_disable)
|
if (switches & sw_disable)
|
||||||
|
{
|
||||||
MET_disable_wal(tdgbl->status, handle);
|
MET_disable_wal(tdgbl->status, handle);
|
||||||
|
}
|
||||||
|
|
||||||
isc_detach_database(tdgbl->status, &handle);
|
isc_detach_database(tdgbl->status, &handle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ((error) ? FINI_ERROR : FINI_OK);
|
return ((error) ? FINI_ERROR : FINI_OK);
|
||||||
}
|
}
|
||||||
@ -138,20 +149,24 @@ int EXE_action(const TEXT* database, const ULONG switches)
|
|||||||
//
|
//
|
||||||
|
|
||||||
int EXE_two_phase(const TEXT* database, const ULONG switches)
|
int EXE_two_phase(const TEXT* database, const ULONG switches)
|
||||||
|
{
|
||||||
|
bool error = false;
|
||||||
|
AliceAutoPool newPool(AliceMemoryPool::createPool());
|
||||||
{
|
{
|
||||||
UCHAR dpb[128];
|
UCHAR dpb[128];
|
||||||
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
|
||||||
AliceContextPoolHolder context(tdgbl, AliceMemoryPool::createPool());
|
AliceContextPoolHolder context(tdgbl, newPool);
|
||||||
|
|
||||||
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
||||||
|
{
|
||||||
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// generate the database parameter block for the attach,
|
// generate the database parameter block for the attach,
|
||||||
// based on the various switches
|
// based on the various switches
|
||||||
|
|
||||||
const USHORT dpb_length = build_dpb(dpb, switches);
|
const USHORT dpb_length = build_dpb(dpb, switches);
|
||||||
|
|
||||||
bool error = false;
|
|
||||||
FB_API_HANDLE handle = 0;
|
FB_API_HANDLE handle = 0;
|
||||||
isc_attach_database(tdgbl->status, 0, database, &handle,
|
isc_attach_database(tdgbl->status, 0, database, &handle,
|
||||||
dpb_length, reinterpret_cast<char*>(dpb));
|
dpb_length, reinterpret_cast<char*>(dpb));
|
||||||
@ -159,18 +174,27 @@ int EXE_two_phase(const TEXT* database, const ULONG switches)
|
|||||||
tdgbl->service_blk->svc_started();
|
tdgbl->service_blk->svc_started();
|
||||||
|
|
||||||
if (tdgbl->status[1])
|
if (tdgbl->status[1])
|
||||||
|
{
|
||||||
error = true;
|
error = true;
|
||||||
|
}
|
||||||
else if (switches & sw_list)
|
else if (switches & sw_list)
|
||||||
|
{
|
||||||
TDR_list_limbo((handle), database, switches);
|
TDR_list_limbo((handle), database, switches);
|
||||||
|
}
|
||||||
else if (switches & (sw_commit | sw_rollback | sw_two_phase))
|
else if (switches & (sw_commit | sw_rollback | sw_two_phase))
|
||||||
|
{
|
||||||
error = TDR_reconnect_multiple((handle),
|
error = TDR_reconnect_multiple((handle),
|
||||||
tdgbl->ALICE_data.ua_transaction, database,
|
tdgbl->ALICE_data.ua_transaction, database,
|
||||||
switches);
|
switches);
|
||||||
|
}
|
||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
|
{
|
||||||
isc_detach_database(tdgbl->status, &handle);
|
isc_detach_database(tdgbl->status, &handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ((error) ? FINI_ERROR : FINI_OK);
|
return (error ? FINI_ERROR : FINI_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
//____________________________________________________________
|
//____________________________________________________________
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* PROGRAM: Alice
|
|
||||||
* MODULE: lls.h
|
|
||||||
* DESCRIPTION: Linked list stack definitions
|
|
||||||
*
|
|
||||||
* 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 ALICE_LLS_H
|
|
||||||
#define ALICE_LLS_H
|
|
||||||
|
|
||||||
struct alice_lls {
|
|
||||||
struct blk* lls_object;
|
|
||||||
alice_lls* lls_next;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ALICE_LLS_H
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user