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



15 years ago
15 years ago


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



Firefox Tracking Flags

(Not tracked)



(3 attachments)



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.


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

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

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
Assignee: jpierre → relyea
Target Milestone: 3.8 → 3.7

Comment 3

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

patch 1: pk11wrap changes.

Comment 4

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

Export our new file...

Comment 5

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

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-

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-

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
cvs diff -uN to generate the patch.
The -N option includes the new files in the patch.

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.

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

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

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.

Comment 12

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