Add a new function that blocks the calling thread until a token is removed

RESOLVED FIXED in 3.7

Status

NSS
Libraries
P1
enhancement
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: Wan-Teh Chang, Assigned: Robert Relyea)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

15 years ago
Since PKCS #11 does not have a notification mechanism
for the token removal events, we will need to resort
to a polling mechanism.

This RFE proposes that we add a function that polls
the slots periodically for token presence.  It returns
to the caller as soon as a token is found to be removed.

The application needs to provide the thread to call
this function.
(Reporter)

Updated

15 years ago
Priority: -- → P1
Target Milestone: --- → 3.7
Version: 3.5 → unspecified
(Reporter)

Comment 1

15 years ago
Moved to target milestone 3.8 because the original
NSS 3.7 release has been renamed 3.8.
Target Milestone: 3.7 → 3.8
(Reporter)

Comment 2

15 years ago
We decided to include this new function in the 3.7
release, and Bob will implement it.

Bob, please write a description of the function for
review.
Assignee: jpierre → relyea
Target Milestone: 3.8 → 3.7
(Assignee)

Comment 3

15 years ago
Created attachment 108935 [details] [diff] [review]
patch 1: pk11wrap changes.

patch 1: pk11wrap changes.
(Assignee)

Comment 4

15 years ago
Created attachment 108936 [details] [diff] [review]
patch 2: changes to nss.def 

Export our new file...
(Assignee)

Comment 5

15 years ago
Created attachment 108937 [details]
Test program...
(Assignee)

Comment 6

15 years ago
Ready for review for an early morning checking.
Comment on attachment 108936 [details] [diff] [review]
patch 2: changes to nss.def 

trailing semicolon missing
Attachment #108936 - Flags: review-
(Reporter)

Comment 8

15 years ago
Comment on attachment 108935 [details] [diff] [review]
patch 1: pk11wrap changes.

I found two bugs in the handling of timeout.
I suggest adding some comments to explain the
token statuses and events, in particular the
"changed" status, and how this function is
supposed to be used.

Bob, I left a copy of this patch with my comments
at your desk.
Attachment #108935 - Flags: review-
(Reporter)

Comment 9

15 years ago
Comment on attachment 108937 [details]
Test program...

Bob, you can consider adding this test (remtest.c) to the new
mozilla/security/nss/cmd/tests directory.

Also, instead of attaching a zip file, you can cvs add the new files and then
use
cvs diff -uN to generate the patch.
The -N option includes the new files in the patch.
(Reporter)

Comment 10

15 years ago
Bob, should the test call PK11_IsPresent before it
enters the do-while loop calling PK11_WaitForTokenEvent?
Seems like you should call PK11_IsPresent to obtain
the initial token status.
(Reporter)

Comment 11

15 years ago
Comment on attachment 108935 [details] [diff] [review]
patch 1: pk11wrap changes.

Another issue with this patch is that the detection
of the "changed" event is unreliable if some other
thread is calling PK11_IsPresent (directly or via
other NSS functions) at the same time.

The "changed" event is detected by a change in the
slot series.  At the beginning of PK11_WaitForTokenEvent
we call PK11_GetSlotSeries to get the old slot series.
If another thread calls PK11_IsPresent before our
PK11_GetSlotSeries call, we will get the new slot
series instead and won't see the change in the slot
series.

Here is a proposed solution.

1. Modify the PK11_WaitForTokenEvent function prototype.
The caller passes in the old slot series as an argument.
If the "present" or "changed" status is returned, the
function also returns the current slot series to the
caller.

2. It would be good to have a variant of the
PK11_IsPresent function that also returns the current
slot series if the token is present.  This is because
we should get the slot series and the token presence
info *atomically* to get the most accurate slot series.
(Assignee)

Comment 12

15 years ago
patches checked in (to tip and 3.7)
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.