Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Delphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old March 11th, 2008, 12:11 PM
steward
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Range Check Error ?

In the function below, I am using the Windows LockFile API.

Caclulating which byte to lock comes from other logic, and the numbers can
be large. I am getting a "range check error" on assignment.

Yet, as I understand it, a DWRD is:

Longword 04294967295 unsigned 32-bit

The value which throws the exception is 429,496,5455
This is less than the documented max of 429,496,7295

Any ideas on how to debug greatly appreciated, thank you.



const
{
Row/Slot numbers are 0-origin
Station/Task numbers are 1-origin
A resource name determines a row/slot.
1st byte in region is "held exclusive"
Remainder of region has 1 byte for every Station/Task.
}
EZMAXRW = 19; // EZSEMTAB data area
EZPAGESIZE = 512; // EZSEMTAB data block
EZBASE = EZMAXRW * EZPAGESIZE;
EZRSCSIZE = 10;
EZMAXTASK = 16;
EZMAXSTATIN= 512;
EZMAXSLT = 51;
EZSLTSIZE = 1+(EZMAXTASK * EZMAXSTATIN); // Exclusive + one for
everybody
EZRWSIZE = (EZMAXSLT * EZSLTSIZE);



function TIMSPlusTask.Exclusive(rsc:string; const
Table:TDataSet=nil):Boolean;
var
lower,upper:DWRD;
begin

Result:=False;
while not Result do
begin
EZSEMTAB.Mutex := TRUE;
// An exclusive lock requires a shared lock
if not FLockList.Shared[iRow,iSlot] then
begin
if not EZSEMTAB.isLocked(iRegion,1) then
EZSEMTAB.Lock(iByte) // Got shared access
else
begin
// Can't get shared
EZSEMTAB.Mutex := False;
if RetryDialog then continue else break;
end;
end;
{ Are we now the only ones holding this resource?
We should be able to lock either sides of this slot:
everything outside our own task byte.
iRegion < iByte <= (iRegion+EZSLTSIZE-1)
If yes, we may lock the iRegion EXCLUSIVE byte now.
}

lower := iByte - iRegion;
upper := iRegion + (EZSLTSIZE-1) - iByte; RANGE CHECK ERRR
HERE

if (EZSEMTAB.isLocked(iRegion,lower)) or
(EZSEMTAB.isLocked(iByte+1,upper)) then
begin
EZSEMTAB.Mutex:=False;
EZSEMTAB.UnLock(iByte);
if RetryDialog then continue else break;
end else
begin
// Gotcha exclusive
EZSEMTAB.Lock(iRegion);
Result:=True;
break;
end;
end;
EZSEMTAB.Mutex:=False;

if Result then
begin
FLockList.Exclusive[iRow,iSlot]:=True;
FLockList.Shared[iRow,iSlot]:=True;
end else
begin
// We lost our shared hold when we put up the retry dialog form
FLockList.Shared[iRow,iSlot]:=False;
end;

end;

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Delphi > Range Check Error ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT