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

Comments.

This commit is contained in:
robocop 2009-11-23 09:13:38 +00:00
parent 19356f022c
commit f0249e6cb1
3 changed files with 71 additions and 75 deletions

View File

@ -52,7 +52,7 @@ struct sdl_arg
const IPTR* sdl_arg_end; const IPTR* sdl_arg_end;
}; };
/* Structure to computes ranges */ // Structure to compute ranges
// Let's stop this insanity! The header rng.h defined rng for the purposes // Let's stop this insanity! The header rng.h defined rng for the purposes
// of refresh range and emulation of file-based data formats like Pdx. // of refresh range and emulation of file-based data formats like Pdx.
@ -291,10 +291,11 @@ const UCHAR* SDL_prepare_slice(const UCHAR* sdl, USHORT sdl_length)
if (new_sdl == old_sdl) if (new_sdl == old_sdl)
{ {
UCHAR* temp_sdl = (UCHAR*)gds__alloc((SLONG) sdl_length); UCHAR* temp_sdl = (UCHAR*)gds__alloc((SLONG) sdl_length);
/* FREE: apparently never freed */ // FREE: apparently never freed
if (!temp_sdl) if (!temp_sdl)
{ /* NOMEM: ignore operation */ {
fb_assert_continue(FALSE); /* no real error handling */ // NOMEM: ignore operation
fb_assert_continue(FALSE); // no real error handling
return old_sdl; return old_sdl;
} }
memcpy(temp_sdl, old_sdl, sdl_length); memcpy(temp_sdl, old_sdl, sdl_length);
@ -389,7 +390,7 @@ int SDL_walk(ISC_STATUS* status_vector,
break; break;
default: default:
/* Check that element is in range of valid SDL */ // Check that element is in range of valid SDL
fb_assert_continue(*(p - 1) >= isc_sdl_version1 && *(p - 1) <= isc_sdl_element); fb_assert_continue(*(p - 1) >= isc_sdl_version1 && *(p - 1) <= isc_sdl_element);
arg.sdl_arg_next = arg.sdl_arg_compiled; arg.sdl_arg_next = arg.sdl_arg_compiled;
@ -444,11 +445,11 @@ static const UCHAR* compile(const UCHAR* sdl, sdl_arg* arg)
else else
{ {
ptr1 = p; ptr1 = p;
COMPILE(p, 0); /* skip over lower bound */ COMPILE(p, 0); // skip over lower bound
} }
COMPILE(p, arg); /* upper bound */ COMPILE(p, arg); // upper bound
if (op == isc_sdl_do3) { if (op == isc_sdl_do3) {
COMPILE(p, arg); /* increment */ COMPILE(p, arg); // increment
} }
else else
{ {
@ -456,18 +457,18 @@ static const UCHAR* compile(const UCHAR* sdl, sdl_arg* arg)
STUFF(1, arg); STUFF(1, arg);
} }
if (ptr1) { if (ptr1) {
COMPILE(ptr1, arg); /* initial value */ COMPILE(ptr1, arg); // initial value
} }
else else
{ {
STUFF(op_literal, arg); /* default initial value */ STUFF(op_literal, arg); // default initial value
STUFF(1, arg); STUFF(1, arg);
} }
STUFF(op_loop, arg); STUFF(op_loop, arg);
if (!(label = stuff(op_iterate, arg))) if (!(label = stuff(op_iterate, arg)))
return NULL; return NULL;
STUFF(variable, arg); STUFF(variable, arg);
STUFF(0, arg); /* future branch out address */ STUFF(0, arg); // future branch out address
if (!(p = compile(p, arg))) if (!(p = compile(p, arg)))
return NULL; return NULL;
STUFF(op_goto, arg); STUFF(op_goto, arg);
@ -546,7 +547,7 @@ static const UCHAR* compile(const UCHAR* sdl, sdl_arg* arg)
if (arg && count != 1) if (arg && count != 1)
{ {
error(arg->sdl_arg_status_vector, Arg::Gds(isc_datnotsup)); error(arg->sdl_arg_status_vector, Arg::Gds(isc_datnotsup));
/* Msg107: "data operation not supported" (arrays of structures) */ // Msg107: "data operation not supported" (arrays of structures)
return NULL; return NULL;
} }
expr = expressions; expr = expressions;
@ -680,7 +681,7 @@ static bool execute(sdl_arg* arg)
case op_scalar: case op_scalar:
{ {
value = *next++; value = *next++;
next++; /* Skip count, unsupported. */ next++; // Skip count, unsupported.
SLONG subscript = 0; SLONG subscript = 0;
for (const Ods::InternalArrayDesc::iad_repeat* range = array_desc->iad_rpt; for (const Ods::InternalArrayDesc::iad_repeat* range = array_desc->iad_rpt;
range < range_end; ++range) range < range_end; ++range)
@ -697,7 +698,7 @@ static bool execute(sdl_arg* arg)
element_desc.dsc_address = arg->sdl_arg_array + (IPTR) element_desc.dsc_address + element_desc.dsc_address = arg->sdl_arg_array + (IPTR) element_desc.dsc_address +
(array_desc->iad_element_length * subscript); (array_desc->iad_element_length * subscript);
/* Is this element within the array bounds? */ // Is this element within the array bounds?
fb_assert_continue(element_desc.dsc_address >= arg->sdl_arg_array); fb_assert_continue(element_desc.dsc_address >= arg->sdl_arg_array);
fb_assert_continue(element_desc.dsc_address + element_desc.dsc_length <= fb_assert_continue(element_desc.dsc_address + element_desc.dsc_length <=
arg->sdl_arg_array + array_desc->iad_total_length); arg->sdl_arg_array + array_desc->iad_total_length);
@ -708,13 +709,13 @@ static bool execute(sdl_arg* arg)
count = *next++; count = *next++;
if (arg->sdl_arg_argument->slice_direction == array_slice::slc_writing_array) if (arg->sdl_arg_argument->slice_direction == array_slice::slc_writing_array)
{ {
/* Storing INTO array */ // Storing INTO array
(*arg->sdl_arg_callback) (arg->sdl_arg_argument, count, &element_desc); (*arg->sdl_arg_callback) (arg->sdl_arg_argument, count, &element_desc);
} }
else else
{ {
/* Fetching FROM array */ // Fetching FROM array
if (element_desc.dsc_address < arg->sdl_arg_argument->slice_high_water) if (element_desc.dsc_address < arg->sdl_arg_argument->slice_high_water)
{ {
@ -1009,7 +1010,7 @@ static IPTR* stuff(IPTR value, sdl_arg* arg)
if (arg->sdl_arg_next >= arg->sdl_arg_end) if (arg->sdl_arg_next >= arg->sdl_arg_end)
error(arg->sdl_arg_status_vector, Arg::Gds(isc_virmemexh)); error(arg->sdl_arg_status_vector, Arg::Gds(isc_virmemexh));
/* unable to allocate memory from operating system */ // unable to allocate memory from operating system
*(arg->sdl_arg_next)++ = value; *(arg->sdl_arg_next)++ = value;

View File

@ -87,7 +87,7 @@ bool SHUT_blocking_ast(thread_db* tdbb)
const SSHORT flag = data.data_items.flag; const SSHORT flag = data.data_items.flag;
const SSHORT delay = data.data_items.delay; const SSHORT delay = data.data_items.delay;
/* Database shutdown has been cancelled. */ // Database shutdown has been cancelled.
// Delay of -1 means we're going online // Delay of -1 means we're going online
if (delay == -1) if (delay == -1)
@ -145,8 +145,7 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay)
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
Jrd::Attachment* attachment = tdbb->getAttachment(); Jrd::Attachment* attachment = tdbb->getAttachment();
/* Only platform's user locksmith can shutdown or bring online // Only platform's user locksmith can shutdown or bring online a database.
a database. */
if (!attachment->locksmith()) if (!attachment->locksmith())
{ {
@ -212,18 +211,17 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay)
attachment->att_flags |= ATT_shutdown_manager; attachment->att_flags |= ATT_shutdown_manager;
--dbb->dbb_use_count; --dbb->dbb_use_count;
/* Database is being shutdown. First notification gives shutdown // Database is being shutdown. First notification gives shutdown type and delay in seconds.
type and delay in seconds. */
bool exclusive = notify_shutdown(tdbb, flag, delay); bool exclusive = notify_shutdown(tdbb, flag, delay);
/* Notify local attachments */ // Notify local attachments
SHUT_blocking_ast(tdbb); SHUT_blocking_ast(tdbb);
/* Try to get exclusive database lock periodically up to specified delay. If we // Try to get exclusive database lock periodically up to specified delay. If we
haven't gotten it report shutdown error for weaker forms. For forced shutdown // haven't gotten it report shutdown error for weaker forms. For forced shutdown
keep notifying until successful. */ // keep notifying until successful.
SSHORT timeout = delay - SHUT_WAIT_TIME; SSHORT timeout = delay - SHUT_WAIT_TIME;
@ -241,15 +239,14 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay)
if (!exclusive && (timeout > 0 || flag & (isc_dpb_shut_attachment | isc_dpb_shut_transaction))) if (!exclusive && (timeout > 0 || flag & (isc_dpb_shut_attachment | isc_dpb_shut_transaction)))
{ {
notify_shutdown(tdbb, 0, 0); /* Tell everyone we're giving up */ notify_shutdown(tdbb, 0, 0); // Tell everyone we're giving up
SHUT_blocking_ast(tdbb); SHUT_blocking_ast(tdbb);
attachment->att_flags &= ~ATT_shutdown_manager; attachment->att_flags &= ~ATT_shutdown_manager;
++dbb->dbb_use_count; ++dbb->dbb_use_count;
ERR_post(Arg::Gds(isc_shutfail)); ERR_post(Arg::Gds(isc_shutfail));
} }
/* Once there are no more transactions active, force all remaining // Once there are no more transactions active, force all remaining attachments to shutdown.
attachments to shutdown. */
if (flag & isc_dpb_shut_transaction) if (flag & isc_dpb_shut_transaction)
{ {
@ -343,8 +340,7 @@ void SHUT_online(thread_db* tdbb, SSHORT flag)
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
Jrd::Attachment* attachment = tdbb->getAttachment(); Jrd::Attachment* attachment = tdbb->getAttachment();
/* Only platform's user locksmith can shutdown or bring online // Only platform's user locksmith can shutdown or bring online a database.
a database. */
if (!attachment->att_user->locksmith()) if (!attachment->att_user->locksmith())
{ {
@ -404,7 +400,7 @@ void SHUT_online(thread_db* tdbb, SSHORT flag)
check_backup_state(tdbb); check_backup_state(tdbb);
} }
/* Clear shutdown flag on database header page */ // Clear shutdown flag on database header page
WIN window(HEADER_PAGE_NUMBER); WIN window(HEADER_PAGE_NUMBER);
Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
@ -429,13 +425,12 @@ void SHUT_online(thread_db* tdbb, SSHORT flag)
} }
CCH_RELEASE(tdbb, &window); CCH_RELEASE(tdbb, &window);
/* Notify existing database clients that a currently // Notify existing database clients that a currently scheduled shutdown is cancelled.
scheduled shutdown is cancelled. */
if (notify_shutdown(tdbb, shut_mode, -1)) if (notify_shutdown(tdbb, shut_mode, -1))
CCH_release_exclusive(tdbb); CCH_release_exclusive(tdbb);
/* Notify local attachments */ // Notify local attachments
SHUT_blocking_ast(tdbb); SHUT_blocking_ast(tdbb);
} }
@ -494,7 +489,7 @@ static bool notify_shutdown(thread_db* tdbb, SSHORT flag, SSHORT delay)
LCK_write_data(tdbb, dbb->dbb_lock, data.data_long); LCK_write_data(tdbb, dbb->dbb_lock, data.data_long);
/* Send blocking ASTs to database users */ // Send blocking ASTs to database users
const bool exclusive = CCH_exclusive(tdbb, LCK_PW, delay > 0 ? -SHUT_WAIT_TIME : -1); const bool exclusive = CCH_exclusive(tdbb, LCK_PW, delay > 0 ? -SHUT_WAIT_TIME : -1);
@ -528,7 +523,7 @@ static bool shutdown_locks(thread_db* tdbb, SSHORT flag)
**************************************/ **************************************/
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
/* Mark database and all active attachments as shutdown. */ // Mark database and all active attachments as shutdown.
dbb->dbb_ast_flags &= ~(DBB_shutdown | DBB_shutdown_single | DBB_shutdown_full); dbb->dbb_ast_flags &= ~(DBB_shutdown | DBB_shutdown_single | DBB_shutdown_full);
@ -574,8 +569,8 @@ static bool shutdown_locks(thread_db* tdbb, SSHORT flag)
return false; return false;
} }
/* Since no attachment is actively running, release all // Since no attachment is actively running, release all
attachment-specfic locks while they're not looking. */ // attachment-specfic locks while they're not looking.
const Jrd::Attachment* shut_attachment = NULL; const Jrd::Attachment* shut_attachment = NULL;
@ -593,16 +588,16 @@ static bool shutdown_locks(thread_db* tdbb, SSHORT flag)
TRA_shutdown_attachment(tdbb, attachment); TRA_shutdown_attachment(tdbb, attachment);
} }
/* Release database locks that are shared by all attachments. // Release database locks that are shared by all attachments.
These include relation and index existence locks, as well // These include relation and index existence locks, as well
as, relation interest and record locking locks for PC semantic // as, relation interest and record locking locks for PC semantic
record locking. */ // record locking.
CMP_shutdown_database(tdbb); CMP_shutdown_database(tdbb);
/* If shutdown manager is here, leave enough database lock context // If shutdown manager is here, leave enough database lock context
to run as a normal attachment. Otherwise, get rid of the rest // to run as a normal attachment. Otherwise, get rid of the rest
of the database locks.*/ // of the database locks.
if (!shut_attachment) if (!shut_attachment)
{ {

View File

@ -48,7 +48,7 @@ USHORT SQZ_apply_differences(Record* record, const SCHAR* differences, const SCH
if (end - differences > MAX_DIFFERENCES) if (end - differences > MAX_DIFFERENCES)
{ {
BUGCHECK(176); /* msg 176 bad difference record */ BUGCHECK(176); // msg 176 bad difference record
} }
SCHAR* p = (SCHAR*) record->rec_data; SCHAR* p = (SCHAR*) record->rec_data;
@ -61,7 +61,7 @@ USHORT SQZ_apply_differences(Record* record, const SCHAR* differences, const SCH
{ {
if (p + l > p_end) if (p + l > p_end)
{ {
BUGCHECK(177); /* msg 177 applied differences will not fit in record */ BUGCHECK(177); // msg 177 applied differences will not fit in record
} }
memcpy(p, differences, l); memcpy(p, differences, l);
p += l; p += l;
@ -77,7 +77,7 @@ USHORT SQZ_apply_differences(Record* record, const SCHAR* differences, const SCH
if (length > record->rec_length || differences < end) if (length > record->rec_length || differences < end)
{ {
BUGCHECK(177); /* msg 177 applied differences will not fit in record */ BUGCHECK(177); // msg 177 applied differences will not fit in record
} }
return length; return length;
@ -223,7 +223,7 @@ UCHAR* SQZ_decompress(const UCHAR* input,
if ((output - len) > output_end) if ((output - len) > output_end)
{ {
BUGCHECK(179); /* msg 179 decompression overran buffer */ BUGCHECK(179); // msg 179 decompression overran buffer
} }
memset(output, c, (-1 * len)); memset(output, c, (-1 * len));
output -= len; output -= len;
@ -232,7 +232,7 @@ UCHAR* SQZ_decompress(const UCHAR* input,
{ {
if ((output + len) > output_end) if ((output + len) > output_end)
{ {
BUGCHECK(179); /* msg 179 decompression overran buffer */ BUGCHECK(179); // msg 179 decompression overran buffer
} }
memcpy(output, input, len); memcpy(output, input, len);
output += len; output += len;
@ -242,7 +242,7 @@ UCHAR* SQZ_decompress(const UCHAR* input,
if (output > output_end) if (output > output_end)
{ {
BUGCHECK(179); /* msg 179 decompression overran buffer */ BUGCHECK(179); // msg 179 decompression overran buffer
} }
return output; return output;
@ -302,12 +302,12 @@ USHORT SQZ_differences(const SCHAR* rec1,
**************************************/ **************************************/
SCHAR *p; SCHAR *p;
// SLONG l; Moved to the proper scope. Comment immediately below still applies. // SLONG l; Moved to the proper scope. Comment immediately below still applies.
/* This "l" could be more than 32K since the Old and New records // This "l" could be more than 32K since the Old and New records
could be the same for more than 32K characters. // could be the same for more than 32K characters.
MAX record size is currently 64K. Hence it is defined as a SLONG */ // MAX record size is currently 64K. Hence it is defined as a SLONG
#define STUFF(val) if (out < end) *out++ = val; else return 32000; #define STUFF(val) if (out < end) *out++ = val; else return 32000;
/* WHY IS THIS RETURNING 32000 ??? /* WHY IS THIS RETURNING 32000 ???
* It returns a large Positive value to indicate to the caller that we ran out * It returns a large Positive value to indicate to the caller that we ran out
* of buffer space in the 'out' argument. Thus we could not create a * of buffer space in the 'out' argument. Thus we could not create a
* successful differences record. Now it is upto the caller to check the * successful differences record. Now it is upto the caller to check the
@ -332,8 +332,8 @@ USHORT SQZ_differences(const SCHAR* rec1,
{ {
p = out++; p = out++;
/* cast this to LONG to take care of OS/2 pointer arithmetic // cast this to LONG to take care of OS/2 pointer arithmetic
when rec1 is at the end of a segment, to avoid wrapping around */ // when rec1 is at the end of a segment, to avoid wrapping around
const SCHAR* yellow = (SCHAR *) MIN((U_IPTR) end1, ((U_IPTR) rec1 + 127)) - 1; const SCHAR* yellow = (SCHAR *) MIN((U_IPTR) end1, ((U_IPTR) rec1 + 127)) - 1;
while (rec1 <= yellow && (rec1[0] != rec2[0] || (rec1[1] != rec2[1] && rec1 < yellow))) while (rec1 <= yellow && (rec1[0] != rec2[0] || (rec1[1] != rec2[1] && rec1 < yellow)))
@ -364,8 +364,8 @@ USHORT SQZ_differences(const SCHAR* rec1,
{ {
p = out++; p = out++;
/* cast this to LONG to take care of OS/2 pointer arithmetic // cast this to LONG to take care of OS/2 pointer arithmetic
when rec1 is at the end of a segment, to avoid wrapping around */ // when rec1 is at the end of a segment, to avoid wrapping around
const SCHAR* yellow = (SCHAR *) MIN((U_IPTR) end2, ((U_IPTR) rec2 + 127)); const SCHAR* yellow = (SCHAR *) MIN((U_IPTR) end2, ((U_IPTR) rec2 + 127));
while (rec2 < yellow) while (rec2 < yellow)
@ -441,7 +441,7 @@ USHORT SQZ_length(const SCHAR* data, int length, DataComprControl* dcc)
{ {
const SCHAR* start = data; const SCHAR* start = data;
/* Find length of non-compressable run */ // Find length of non-compressable run
if ((max = count - 1) > 1) if ((max = count - 1) > 1)
{ {
@ -459,7 +459,7 @@ USHORT SQZ_length(const SCHAR* data, int length, DataComprControl* dcc)
} }
data = start + count; data = start + count;
/* Non-compressable runs are limited to 127 bytes */ // Non-compressable runs are limited to 127 bytes
while (count) while (count)
{ {
@ -469,7 +469,7 @@ USHORT SQZ_length(const SCHAR* data, int length, DataComprControl* dcc)
*control++ = max; *control++ = max;
} }
/* Find compressible run. Compressable runs are limited to 128 bytes */ // Find compressible run. Compressable runs are limited to 128 bytes
if ((max = MIN(128, end - data)) >= 3) if ((max = MIN(128, end - data)) >= 3)
{ {