scd: acquire lock in new_reader_slot.
authorWerner Koch <wk@gnupg.org>
Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)
committerWerner Koch <wk@gnupg.org>
Mon, 10 Mar 2014 15:07:46 +0000 (16:07 +0100)
commit9ab9f414fb919f0bc87c301c3e36180715d0aa4e
tree89a066adf4d4d878d9f118a26e1673ae508fb8dd
parent8e9b1aa563040e272840a2e5df73971a1f03401d
scd: acquire lock in new_reader_slot.

* scd/apdu.c (new_reader_slot): Acquire lock.
(open_ct_reader, open_pcsc_reader_direct, open_pcsc_reader_wrapped)
(open_ccid_reader, open_rapdu_reader): Release lock.
(lock_slot, trylock_slot, unlock_slot): Move more to the top.

--
Fixes a test case of:
   No libpcsclite1 installed.
   Run gpg-agent
   Run command "gpg-connect-agent learn /bye" with no card/token
   Sometimes it fails: ERR 100663356 Not supported <SCD>
   While it should be always: ERR 100663404 Card error <SCD>

(cherry picked from commit 4f557cb9c2ebe274d6aacc60a09cd919055d01ed)

Resolved conflicts:
scd/apdu.c: pth/npth changes. Move lock helpers to the top.
                    Take care of removed pcsc_no_service.
scd/apdu.c