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

Get rid of the old config stuff completely.

This commit is contained in:
dimitr 2003-07-04 15:17:49 +00:00
parent e3f041d36f
commit 8a9fd67841
4 changed files with 8 additions and 554 deletions

View File

@ -33,7 +33,7 @@
*
*/
/*
$Id: ibase.h,v 1.39 2003-06-05 10:12:45 aafemt Exp $
$Id: ibase.h,v 1.40 2003-07-04 15:17:46 dimitr Exp $
*/
#ifndef JRD_IBASE_H
@ -1931,38 +1931,7 @@ enum info_db_provider
/* Server configuration key values */
/***********************************/
#define ISCCFG_LOCKMEM_KEY 0
#define ISCCFG_LOCKSEM_KEY 1
#define ISCCFG_LOCKSIG_KEY 2
#define ISCCFG_EVNTMEM_KEY 3
#define ISCCFG_DBCACHE_KEY 4
#define ISCCFG_PRIORITY_KEY 5
#define ISCCFG_IPCMAP_KEY 6
#define ISCCFG_MEMMIN_KEY 7
#define ISCCFG_MEMMAX_KEY 8
#define ISCCFG_LOCKORDER_KEY 9
#define ISCCFG_ANYLOCKMEM_KEY 10
#define ISCCFG_ANYLOCKSEM_KEY 11
#define ISCCFG_ANYLOCKSIG_KEY 12
#define ISCCFG_ANYEVNTMEM_KEY 13
#define ISCCFG_LOCKHASH_KEY 14
#define ISCCFG_DEADLOCK_KEY 15
#define ISCCFG_LOCKSPIN_KEY 16
#define ISCCFG_CONN_TIMEOUT_KEY 17
#define ISCCFG_DUMMY_INTRVL_KEY 18
#define ISCCFG_TRACE_POOLS_KEY 19 /* Internal Use only */
#define ISCCFG_REMOTE_BUFFER_KEY 20
#ifdef SET_TCP_NO_DELAY
#define ISCCFG_NO_NAGLE_KEY 21
#endif
#ifdef WIN_NT
#if defined SET_TCP_NO_DELAY
#error Currently unsupported configuration
#endif
#define ISCCFG_CPU_AFFINITY_KEY 21
#endif
/* Not available in Firebird 1.5 */
/**********************************************/

View File

@ -36,7 +36,7 @@
*
*/
/*
$Id: isc.cpp,v 1.35 2003-06-25 07:43:33 dimitr Exp $
$Id: isc.cpp,v 1.36 2003-07-04 15:17:47 dimitr Exp $
*/
#ifdef DARWIN
#define _STLP_CCTYPE
@ -60,41 +60,6 @@ $Id: isc.cpp,v 1.35 2003-06-25 07:43:33 dimitr Exp $
#include "../jrd/isc_proto.h"
#include "../jrd/jrd_proto.h"
/* Initialize the structure that hold all the config information */
static struct cfgtbl ISC_def_cfg_tbl[] = {
{ISCCFG_LOCKMEM, ISCCFG_LOCKMEM_KEY, ISCCFG_LOCKMEM_DEF, ISCCFG_LOCKMEM_DEF},
{ISCCFG_LOCKSEM, ISCCFG_LOCKSEM_KEY, ISCCFG_LOCKSEM_DEF, ISCCFG_LOCKSEM_DEF},
{ISCCFG_LOCKSIG, ISCCFG_LOCKSIG_KEY, ISCCFG_LOCKSIG_DEF, ISCCFG_LOCKSIG_DEF},
{ISCCFG_EVNTMEM, ISCCFG_EVNTMEM_KEY, ISCCFG_EVNTMEM_DEF, ISCCFG_EVNTMEM_DEF},
{ISCCFG_DBCACHE, ISCCFG_DBCACHE_KEY, ISCCFG_DBCACHE_DEF, ISCCFG_DBCACHE_DEF},
{ISCCFG_PRIORITY, ISCCFG_PRIORITY_KEY, ISCCFG_PRIORITY_DEF, ISCCFG_PRIORITY_DEF},
{ISCCFG_IPCMAP, ISCCFG_IPCMAP_KEY, ISCCFG_IPCMAP_DEF, ISCCFG_IPCMAP_DEF},
{ISCCFG_MEMMIN, ISCCFG_MEMMIN_KEY, ISCCFG_MEMMIN_DEF, ISCCFG_MEMMIN_DEF},
{ISCCFG_MEMMAX, ISCCFG_MEMMAX_KEY, ISCCFG_MEMMAX_DEF, ISCCFG_MEMMAX_DEF},
{ISCCFG_LOCKORDER, ISCCFG_LOCKORDER_KEY, ISCCFG_LOCKORDER_DEF, ISCCFG_LOCKORDER_DEF},
{ISCCFG_ANYLOCKMEM, ISCCFG_ANYLOCKMEM_KEY, ISCCFG_ANYLOCKMEM_DEF, ISCCFG_ANYLOCKMEM_DEF},
{ISCCFG_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Y_DEF},
#endif
{NULL, 0, 0, 0}
};
static struct cfgtbl *ISC_cfg_tbl = NULL;
/* Temporary file management specific stuff */
#include "../jrd/fil.h"
@ -185,8 +150,6 @@ static LKSB wake_lock;
#include <fcntl.h>
#endif
void isc_internal_set_config_value(UCHAR, ULONG*, ULONG*);
#ifdef VMS
static void blocking_ast(void);
static void poke_ast(POKE);
@ -363,293 +326,6 @@ int ISC_expand_logical_once(
#endif
void DLL_EXPORT ISC_get_config(TEXT * config_file, IPCCFG config_table)
{
/*************************************
*
* I S C _ g e t _ c o n f i g
*
*************************************
*
* Functional description
* Read user-defined values for shared memory and
* semaphores, and temporary directory list
* from a configuration file.
*
************************************/
IPCCFG h;
struct cfgtbl *tbl;
if (ISC_cfg_tbl == NULL) {
IB_FILE *fd;
TEXT *p, *q, buf[80];
TEXT buffer[MAXPATHLEN];
#ifdef SUPERSERVER
int n;
TEXT dir_name[MAXPATHLEN];
ULONG size;
#endif
gds__prefix(buffer, config_file);
config_file = buffer;
/* Read the configuration file into a local buffer. This
local buffer knows about all valid configuration options.
Later requests for configuration information will read it
from the in-memory copy rather than the disk copy */
ISC_cfg_tbl = ISC_def_cfg_tbl;
if ( (fd = ib_fopen(config_file, FOPEN_READ_TYPE)) )
{
while ( (p = ib_fgets(buf, sizeof(buf), fd)) )
{
/* The same keyword can be used more than once for
temp directory definition hence it should be handled
in its own way */
if (strncmp(buf, ISCCFG_TMPDIR, sizeof(ISCCFG_TMPDIR) - 1) == 0)
{
#ifdef SUPERSERVER
/* Note that this should be #ifdef SERVER once we implement that flag.
* We want this code to execute in classic servers as well as superserver,
* but not in client libraries, or in tools which link with a private
* copy of our object file, such as alice and dudley.
* This needs to be changed in time for the first Classic port of V6.0
*/
/* there is temp. directory definition */
if (!dls_init)
if ((n = sscanf(buf + sizeof(ISCCFG_TMPDIR) - 1,
" %ld \"%[^\"]", &size,
dir_name)) == 2)
{
if (DLS_add_dir(size, dir_name))
dls_flag = TRUE;
else {
gds__log
("Unable to use config parameter %s : No memory ",
ISCCFG_TMPDIR);
dls_flag = FALSE;
}
}
#endif
continue;
}
for (tbl = ISC_cfg_tbl; (q = tbl->cfgtbl_keyword) ; tbl++)
{
p = buf;
/* Scan until we see the end of the keyword or
a mismatch */
while (*q && (*p == *q))
{
p++;
q++;
};
/* If we reached the end of the keyword we've got
a match! The remainder of the input line had
better be spaces and numbers */
if (!*q && (isspace(*p) || isdigit(*p))) {
tbl->cfgtbl_value = atol(p);
break;
}
} /* for */
} /* while */
ib_fclose(fd);
} /* if ib_fopen */
else
{
/* Error opening file. Log a message only if file exists */
if (errno != ENOENT)
gds__log("Unable to open config file \"%s\": errno = %d",
config_file, errno);
}
#ifndef SUPERCLIENT
if (!dls_flag)
{
/* Temp. directory configuration has not been defined.
Let's make default configuration */
if (!(q = getenv("FIREBIRD_TMP")) &&
!(q = getenv("TMP")) &&
!(q = getenv("TEMP")))
{
q = WORKDIR;
}
if (!DLS_add_dir(ALLROOM, q))
{
/* we are out of memory, also we can only get here during
server start hence let us exit with an exit status indicating
to the guardian that the server need not be restarted */
gds__log
("Unable to set configuration parameters : No Memory");
exit(STARTUP_ERROR);
}
dls_flag = TRUE;
}
#endif
dls_init = TRUE; /* Temp dir config should be read only once */
fdls_init = TRUE; /* Ext func dir config should be read only once. */
} /* if ICS_cfg_tbl == NULL */
/* The master configuration options are in memory, now for
this request for option values mark each one as not found
and search the memory table for each one. */
if (!config_table) return;
for (h = config_table; h->ipccfg_keyword; h++)
{
h->ipccfg_found = FALSE;
}
for (h = config_table; h->ipccfg_keyword; h++)
{
if (!h->ipccfg_parent_offset ||
!h[h->ipccfg_parent_offset].ipccfg_found)
{
for (tbl = ISC_cfg_tbl; tbl->cfgtbl_keyword; tbl++)
{
if (!strcmp(tbl->cfgtbl_keyword, h->ipccfg_keyword))
{
*h->ipccfg_variable = tbl->cfgtbl_value;
h->ipccfg_key = tbl->cfgtbl_key;
h->ipccfg_found = TRUE;
break;
}
}
}
}
}
#ifndef SUPERCLIENT
int DLL_EXPORT ISC_set_config(TEXT * config_file, IPCCFG config_table)
{
/*************************************
*
* I S C _ s e t _ c o n f i g
*
*************************************
*
* Functional description
* Set new values in the configuration file
* and make them take affect if possible.
*
************************************/
IB_FILE *fd = NULL;
IPCCFG h;
struct cfgtbl *t;
TEXT buffer[MAXPATHLEN];
int ret = 1;
if (config_file)
{
gds__prefix(buffer, config_file);
config_file = buffer;
fd = ib_fopen(config_file, FOPEN_WRITE_TYPE);
}
if ((ISC_cfg_tbl != NULL) && (!config_file || fd))
{
ULONG config_mask = 0;
ret = 0;
/* If config_table = NULL then assume we want to restore defaults,
* otherwise get the users values and use them.
*/
for (t = ISC_def_cfg_tbl; t->cfgtbl_keyword; t++)
{
if (config_table)
{
for (h = config_table; h->ipccfg_variable; h++)
{
if (h->ipccfg_keyword ?
!strcmp(t->cfgtbl_keyword, h->ipccfg_keyword) :
h->ipccfg_key == t->cfgtbl_key)
{
config_mask |= (1 << t->cfgtbl_key);
t->cfgtbl_value = *h->ipccfg_variable;
break;
}
}
}
else if (t->cfgtbl_value != t->cfgtbl_def_value)
{
config_mask |= (1 << t->cfgtbl_key);
t->cfgtbl_value = t->cfgtbl_def_value;
}
}
/* if one of the working set sizes has been set the make sure they're
* both set.
*/
if (config_mask &
((1 << ISCCFG_MEMMIN_KEY) | (1 << ISCCFG_MEMMAX_KEY))) config_mask
|= ((1 << ISCCFG_MEMMIN_KEY) | (1 << ISCCFG_MEMMAX_KEY));
for (t = ISC_def_cfg_tbl; config_mask && t->cfgtbl_keyword; t++)
{
#ifdef SUPERSERVER
if (config_mask & (1 << t->cfgtbl_key))
{
ULONG *valptr = 0;
switch (t->cfgtbl_key)
{
case ISCCFG_MEMMIN_KEY:
valptr = &(t->cfgtbl_value);
break;
case ISCCFG_MEMMAX_KEY:
isc_internal_set_config_value( t->cfgtbl_key,
valptr,
&(t->cfgtbl_value));
break;
default:
isc_internal_set_config_value( t->cfgtbl_key,
&(t->cfgtbl_value),
NULL);
break;
}
}
#endif /* SUPERSERVER */
if (fd)
{
char *p, *q, buf[80];
int tabs;
p = buf;
if (t->cfgtbl_value == t->cfgtbl_def_value)
*p++ = '#';
q = t->cfgtbl_keyword;
while (*q)
*p++ = *q++;
tabs = 4 - (p - buf) / 8;
while (tabs--)
*p++ = '\t';
*p = '\0';
if (ib_fprintf(fd, "%s%ld\n", buf, t->cfgtbl_value) < 0)
gds__log("Error writing config file \"%s\" : errno = %d",
config_file, errno);
}
}
if (fd) {
ib_fclose(fd);
gds__log("Config file \"%s\" has been modified.", config_file);
}
}
return ret;
}
#endif /* ! SUPERCLIENT */
#if (defined SOLARIS || defined SCO_EV)
#define GET_HOST
TEXT *INTERNAL_API_ROUTINE ISC_get_host(TEXT * string, USHORT length)
@ -1487,80 +1163,6 @@ static int wait_test(SSHORT * iosb)
#endif
#if defined(SUPERSERVER)
void isc_internal_set_config_value(UCHAR key, ULONG * value1, ULONG * value2)
{
switch (key) {
case ISCCFG_DBCACHE_KEY:
JRD_set_cache_default(value1);
break;
case ISCCFG_PRIORITY_KEY:
/*
* This is where you should call your OS specific function to set the
* Process priority (if available).
*/
#ifdef WIN_NT
ULONG priority;
if (*value1 == 2)
priority = HIGH_PRIORITY_CLASS;
else
priority = NORMAL_PRIORITY_CLASS;
if (!SetPriorityClass(GetCurrentProcess(), priority))
{
gds__log("Unable to set process priority.");
}
#endif
break;
case ISCCFG_MEMMAX_KEY:
case ISCCFG_MEMMIN_KEY:
/*
* This is where you should call your OS specific function to set the
* Process priority (if available).
*/
#ifdef WIN_NT
if (*value1 && *value2 && ISC_is_WinNT())
{
HANDLE hndl =
OpenProcess(PROCESS_SET_QUOTA, FALSE, GetCurrentProcessId());
if (hndl) {
ULONG a_value1 = *value1 * 1024;
ULONG a_value2 = *value2 * 1024;
if (!SetProcessWorkingSetSize(hndl, a_value1, a_value2))
{
switch (GetLastError())
{
case ERROR_ACCESS_DENIED:
case ERROR_PRIVILEGE_NOT_HELD:
gds__log("Error setting process working set size, access denied.");
break;
case ERROR_INVALID_PARAMETER:
gds__log("Error setting process working set size, improper range.");
break;
case ERROR_NO_SYSTEM_RESOURCES:
gds__log("Error setting process working set size, insufficient memory.");
break;
default:
gds__log("Error setting process working set size, unknown problem.");
}
*value1 = 0;
*value2 = 0;
}
CloseHandle(hndl);
}
}
#endif
break;
}
}
#endif // SUPERSERVER
#ifdef UNIX
#ifdef AIX_PPC
#define _UNIX95

View File

@ -28,9 +28,7 @@
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
*
*/
/*
$Id: isc.h,v 1.6 2003-03-23 16:50:52 alexpeshkoff Exp $
*/
#ifndef _JRD_ISC_H_
#define _JRD_ISC_H_
@ -44,102 +42,6 @@ extern "C" {
#define ISC_SEM_REMOVE 1
#define ISC_MEM_REMOVE 2
/* Defines for tokens in config file */
#define ISCCFG_LOCKMEM "V4_LOCK_MEM_SIZE"
#define ISCCFG_LOCKMEM_DEF 98304
#define ISCCFG_LOCKSEM "V4_LOCK_SEM_COUNT"
#ifdef SINIXZ
#define ISCCFG_LOCKSEM_DEF 25
#else
#define ISCCFG_LOCKSEM_DEF 32
#endif
#define ISCCFG_LOCKSIG "V4_LOCK_SIGNAL"
#define ISCCFG_LOCKSIG_DEF 16
#define ISCCFG_EVNTMEM "V4_EVENT_MEM_SIZE"
#define ISCCFG_EVNTMEM_DEF 32768
#define ISCCFG_DBCACHE "DATABASE_CACHE_PAGES"
#ifdef SUPERSERVER
#define ISCCFG_DBCACHE_DEF 2048
#endif
#ifndef ISCCFG_DBCACHE_DEF
#define ISCCFG_DBCACHE_DEF 75
#endif
#define ISCCFG_PRIORITY "SERVER_PRIORITY_CLASS"
#define ISCCFG_PRIORITY_DEF 1
#define ISCCFG_IPCMAP "SERVER_CLIENT_MAPPING"
#define ISCCFG_IPCMAP_DEF 4096
#define ISCCFG_MEMMIN "SERVER_WORKING_SIZE_MIN"
#define ISCCFG_MEMMIN_DEF 0
#define ISCCFG_MEMMAX "SERVER_WORKING_SIZE_MAX"
#define ISCCFG_MEMMAX_DEF 0
#define ISCCFG_LOCKORDER "V4_LOCK_GRANT_ORDER"
#define ISCCFG_LOCKORDER_DEF 1
#define ISCCFG_ANYLOCKMEM "ANY_LOCK_MEM_SIZE"
#define ISCCFG_ANYLOCKMEM_DEF 98304
#define ISCCFG_ANYLOCKSEM "ANY_LOCK_SEM_COUNT"
#define ISCCFG_ANYLOCKSEM_DEF 32
#define ISCCFG_ANYLOCKSIG "ANY_LOCK_SIGNAL"
#define ISCCFG_ANYLOCKSIG_DEF 16
#define ISCCFG_ANYEVNTMEM "ANY_EVENT_MEM_SIZE"
#define ISCCFG_ANYEVNTMEM_DEF 32768
#define ISCCFG_LOCKHASH "LOCK_HASH_SLOTS"
#define ISCCFG_LOCKHASH_DEF 101
#define ISCCFG_DEADLOCK "DEADLOCK_TIMEOUT"
#define ISCCFG_DEADLOCK_DEF 10
#define ISCCFG_LOCKSPIN "LOCK_ACQUIRE_SPINS"
#define ISCCFG_LOCKSPIN_DEF 0
#define ISCCFG_CONN_TIMEOUT "CONNECTION_TIMEOUT"
#define ISCCFG_CONN_TIMEOUT_DEF 180 /* seconds */
#define ISCCFG_DUMMY_INTRVL "DUMMY_PACKET_INTERVAL"
#define ISCCFG_DUMMY_INTRVL_DEF 60 /* seconds */
#define ISCCFG_TMPDIR "TMP_DIRECTORY"
#define ISCCFG_EXT_FUNC_DIR "EXTERNAL_FUNCTION_DIRECTORY"
#define ISCCFG_TRACE_POOLS "TRACE_MEMORY_POOLS" /* Internal Use only */
#define ISCCFG_TRACE_POOLS_DEF 0 /* Off - Internal Use only */
#define ISCCFG_REMOTE_BUFFER "TCP_REMOTE_BUFFER"
#define ISCCFG_REMOTE_BUFFER_DEF 8192 /* xdr buffer size */
#ifdef SET_TCP_NO_DELAY
#define ISCCFG_NO_NAGLE "TCP_NO_NAGLE"
#define ISCCFG_NO_NAGLE_DEF 0 /*Disable Nagle Algorithm */
#endif
#ifdef WIN_NT
#define ISCCFG_CPU_AFFINITY_TAG "CPU_AFFINITY"
#define ISCCFG_CPU_AFFINITY_DEF 1 /* bit 0 set, only first CPU */
#endif
typedef struct cfgtbl {
TEXT *cfgtbl_keyword;
UCHAR cfgtbl_key;
ULONG cfgtbl_value;
ULONG cfgtbl_def_value;
} CFGTBL;
/* InterBase platform-specific synchronization data structures */
#ifdef VMS

View File

@ -360,28 +360,8 @@ BOOL ReadIBSettings(HWND hDlg)
if (pdwStatus[1])
PrintCfgStatus(pdwStatus, IDS_CFGREAD_FAILED, hDlg);
else {
char *pchTmp = pchResBuf;
short key;
ULONG ulConfigInfo;
if (*pchTmp++ == isc_info_svc_get_config) {
while (key = *pchTmp++) {
ulConfigInfo = (ULONG) isc_vax_integer(pchTmp, sizeof(ULONG));
pchTmp += sizeof(ULONG);
switch (key) {
case ISCCFG_IPCMAP_KEY:
lMapSize = ulConfigInfo;
break;
case ISCCFG_DBCACHE_KEY:
lCachePages = ulConfigInfo;
break;
}
}
}
else {
lMapSize = Config::getIpcMapSize();
lCachePages = Config::getDefaultDbCachePages();
}
lMapSize = Config::getIpcMapSize();
lCachePages = Config::getDefaultDbCachePages();
bSuccess = TRUE;
}
@ -532,6 +512,7 @@ BOOL WriteIBSettings(HWND hDlg)
pchPtr += sizeof(USHORT);
// Fill in all the records
/*
*pchPtr++ = ISCCFG_IPCMAP_KEY;
*pchPtr++ = sizeof(long);
*(ULONG *) pchPtr = isc_vax_integer((SCHAR *) & lMapSize, sizeof(long));
@ -542,7 +523,7 @@ BOOL WriteIBSettings(HWND hDlg)
*(ULONG *) pchPtr =
isc_vax_integer((SCHAR *) & lCachePages, sizeof(long));
pchPtr += sizeof(long);
*/
*psLen = pchPtr - pchSendBuf - sizeof(short) - sizeof(char);
*psLen = (short) isc_vax_integer((SCHAR *) psLen, sizeof(short));
// Query service with set_config