Closed Bug 463562 Opened 16 years ago Closed 15 years ago

unnecessary dependency on mmtimer.lib

Categories

(NSPR :: NSPR, defect)

ARM
Windows CE
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: blassey, Assigned: blassey)

Details

(Keywords: mobile)

Attachments

(2 files, 2 obsolete files)

we're linking in mmtimer.lib simply to use timeGetTime() for _PR_MD_GET_INTERVAL(). It appears that GetTickCount() will do the same thing without the additional dependency.

Additionally, the dependancy on mmtimer is causing nss to fail to load softokn3.dll on wince, resulting in a crash when trying to start an https connection.
Attachment #346842 - Flags: review?(pavlov)
Please elaborate on the statement: "the dependancy on mmtimer is causing nss 
to fail to load softokn3.dll on wince".
softokn3.dll was failing to load with error code 0x7e, which a missing dependency.  I looked at the dependency tree with depends.exe and saw that nspr was depending on mmtimer.dll, which I didn't see in my system path.  Rebuilding nspr and relinking nss with this patch fixed the problem of softokn3.dll's load failure.
Comment on attachment 346842 [details] [diff] [review]
uses GetTickCount instead of timeGetTime

why do we want to do this?
timeGetTime has 1ms precision vs GetTickCount which has 10ms.
please say you filed a bug w/ a real stack for the actual crash.
(In reply to comment #4)
> (From update of attachment 346842 [details] [diff] [review])
> why do we want to do this?
> timeGetTime has 1ms precision vs GetTickCount which has 10ms.

According to the MSDN documentation, GetTickCount returns a number
whose units are milliseconds since startup (mod 2^32), but its 
resolution is platform dependent, and is said to be 60hz on many 
WinXXX platforms, meaning that it updates in multiples of 16.66... :) 

If that's good enough for WinCE, then I think this patch is OK, otherwise...
This patch seems to include at least one unrelated file modification.
yes, it does.  Please ignore the change to map.cpp
This will use timeGetTime if mmtimer exists, if not it'll fall back on GetTickCount
Attachment #346842 - Attachment is obsolete: true
Attachment #347331 - Flags: review?(pavlov)
Attachment #346842 - Flags: review?(pavlov)
Comment on attachment 347331 [details] [diff] [review]
does a little proc address magic

We should seperate this out into two patches -- one for our wince tools, one for nspr?

what about the vs8 tools?  http://mxr.mozilla.org/mozilla-central/search?string=mmtimer

should we put timeGetTime() in the shunt?  it seems to also be used in:

/js/tamarin/platform/win32/OSDepWin.cpp
Attachment #347331 - Flags: superreview?(wtc)
Attachment #347331 - Flags: review?(pavlov)
Attachment #347331 - Flags: review+
Comment on attachment 347331 [details] [diff] [review]
does a little proc address magic

This code dynamically loads a system library under some circumstances.
Where's the code to do the corresponding unload when NSPR is shut down?
according to msdn:

> The system maintains a per-process reference count on all loaded modules.
> Calling LoadLibrary increments the reference count. Calling the FreeLibrary or
> FreeLibraryAndExitThread function decrements the reference count. The system 
> unloads a module when its reference count reaches zero or when the process 
> terminates (regardless of the reference count).

I believe the unload on process termination is the behavior we want
Fennec may desire this behavior, but I don't believe that means that all 
users of NSPR on WinCE will.  

In general, it is not the practice of NSPR to leak dynamically loaded 
libraries.  Shutting down NSPR should leave the process very much in the
same state as before NSPR is initialized.
Comment on attachment 347331 [details] [diff] [review]
does a little proc address magic

You should initialize 'intervalFunc' in _PR_MD_INTERVAL_INIT(),
which is called once during NSPR initialization.

The way you initialize 'intervalFunc' lazily in _PR_MD_GET_INTERVAL()
may not be thread-safe.

You can also consider just using GetTickCount.  It's usually bad
to behave differently on different machines unless the feature
is highly desirable.
Attachment #347331 - Flags: superreview?(wtc) → superreview-
Attached patch NSPR patch v2 (obsolete) — Splinter Review
Brad, please review and test this NSPR patch.
Attachment #347689 - Flags: review?(blassey)
Wan-Teh, I've got your patch in my tree but can't test it right now because of a js crash.
Comment on attachment 347689 [details] [diff] [review]
NSPR patch v2

looks good and works for me
Attachment #347689 - Flags: review?(blassey) → review+
I added an XXX comment to note that the mmtimer.dll library handle
is leaked.  I checked in the patch on the NSPR trunk (NSPR 4.7.4).

Checking in ntinrval.c;
/cvsroot/mozilla/nsprpub/pr/src/md/windows/ntinrval.c,v  <--  ntinrval.c
new revision: 3.14; previous revision: 3.13
done

This will eventually make it into mozilla-central.  Brad, you need to
check in your change to build/wince/tools/vs9ppc2003arm/arm-wince-link.c
yourself.
Attachment #347689 - Attachment is obsolete: true
I'm targetting Windows CE support at NSPR 4.8 now.  So the
NSPR patch v2 (attachment 349479 [details] [diff] [review]) won't be in NSPR 4.7.4.
(This is just a version number change.  Don't worry about
it.)
Target Milestone: --- → 4.8
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: