Hello,
On 12/06/2015 16:33, Ludovic Rousseau wrote:
> Are you using threads in your application?
Yes
> Does each thread use its own PC/SC context (SCardEstablishContext)?
No, we use javax.smartcardio based on SCardEstablishContext called by
PCSCTerminals.initContext().
initContext() is called at the time the shared object (libpcsc.so*) is
opened.
The implementation of initContext() keeps the result in a singleton.
<code from="openjdk-7-fcs-src-b147-27_jun_2011">
static synchronized void initContext() throws PCSCException {
if (contextId == 0) {
contextId = SCardEstablishContext(SCARD_SCOPE_USER);
}
</code>
> Why do you use this configuration?
(DAEMON_ARGS="--max-card-handle-per-reader 1")
With the attached file PcscdTest.java, we have stressed the web
application over ab (apache2-utils), and we
have determined that this configuration
On 12/06/2015 16:33, Ludovic Rousseau wrote:
> 2015-06-11 17:39 GMT+02:00 <[email protected]>:
>> Hello,
> Hello,
>
>> We've got some troubles with "libpcsclite". Perhaps, you could help us.
>>
>> Context :
>> ----------
>> We use 3 card readers (SCM SCR 3310) with pcscd on Debian Linux with
>> java environment.
>>
>> We 've made a regular backport from latest release of 1.8.13 (remove
>> dependencies
>> to systemd named bpo60+1oab2) on squeeze (debian 6) Linux machines.
>>
>> Here is a description of our environment, we are in a Java environment
>> (1.6.0_31) :
>> * Frontal : Apache / Tomcat
>> * Backend : Web application with API javax.smartcardio initialized with :
>> System.setProperty("sun.security.smartcardio.library",
>> /usr/lib/libpcsclite.so);
>>
>> At the frequency of 5 seconds, we monitor cards on reader (haproxy check).
>>
>> The problem :
>> Sometimes, a sigsegv occurs on libpcsclite on winscard_clnt.c:979
>> (void)pthread_mutex_unlock(¤tContextMap->mMutex);
>>
>> This sigsegv implies sudden death of Tomcat (cf java_frames).
>>
>> This part of code ( winscard_clnt.c:971) seems a bit strange :
>>
>> /* the hCard handle is now invalid
>> * -> another thread may have called SCardReleaseContext
>> * so the mMutex has been unlocked (and is now invalid)
>> * -> another thread may have called SCardDisconnect
>> * so the mMutex is STILL locked
>> * since we don't know just unlock the mutex */
>>
>> Why releasing mutex since "mMutex has been unlocked (and is now invalid)" ?
> Good point. I will check that again.
>
> Are you using threads in your application?
> Does each thread use its own PC/SC context (SCardEstablishContext)?
>
>> Here is the configuration of the machine.
>>
>> CCID driver version (dpkg -l | grep -i ccid)
>> -------------------------
>> libccid 1.3.11-2
>>
>> pcsc-lite version
>> ---------------------
>> ii libpcsclite-dev 1.8.13~bpo60+1oab2 Middleware to access a
>> smart card using PC/SC (development files)
>> ii libpcsclite1 1.8.13~bpo60+1oab2 Middleware to access a
>> smart card using PC/SC (library)
>> ii libpcsclite1-dbg 1.8.13~bpo60+1oab2 Middleware to access a
>> smart card using PC/SC (debugging symbols)
>> ii pcscd 1.8.13~bpo60+1oab2 Middleware to access
>> a smart card using PC/SC (daemon side)
>>
>> smart card reader name
>> --------------------------------
>> 0: SCM SCR 3310 [CCID Interface] 00 00
>> 1: SCM SCR 3310 [CCID Interface] 01 00
>> 2: SCM SCR 3310 [CCID Interface] 02 00
>>
>> the output of the command "/usr/sbin/pcscd --version"
>> ------------------------------------
>> pcsc-lite version 1.8.13.
>> Copyright (C) 1999-2002 by David Corcoran <[email protected]>.
>> Copyright (C) 2001-2011 by Ludovic Rousseau <[email protected]>.
>> Copyright (C) 2003-2004 by Damien Sauveron <[email protected]>.
>> Report bugs to <[email protected]>.
>> Enabled features: Linux x86_64-pc-linux-gnu serial usb libudev
>> usbdropdir=/usr/lib/pcsc/drivers ipcdir=/var/run/pcscd
>> configdir=/etc/reader.conf.d
>>
>> configuration of pcscd : /etc/default/pcscd
>> -----------------------------
>> DAEMON_ARGS="--max-card-handle-per-reader 1"
> Why do you use this configuration?
>
> Bye
>
--
Luc Mazardo
Orange Applications for Business
_________________________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou
falsifie. Merci.
This message and its attachments may contain confidential or privileged
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been
modified, changed or falsified.
Thank you.
import java.util.List;
import javax.smartcardio.*;
public class PcscdTest {
public static void main(String[] args) {
while (true) {
try {
// Display the list of terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// Use the first terminal
for (int idx = 0; idx < terminals.size(); idx ++) {
CardTerminal terminal = terminals.get(idx);
// Connect wit hthe card
Card card = terminal.connect("*");
System.out.println("card: " + card);
CardChannel channel = card.getBasicChannel();
// Send Select Applet command
byte[] aid = {(byte)0xA0, 0x00, 0x00, 0x00, 0x62, 0x03, 0x01, 0x0C, 0x06, 0x01};
ResponseAPDU answer = channel.transmit(new CommandAPDU(0x00, 0xA4, 0x04, 0x00, aid));
System.out.println("answer: " + answer.toString());
// Send test command
answer = channel.transmit(new CommandAPDU(0x00, 0x00, 0x00, 0x00));
System.out.println("answer: " + answer.toString());
byte r[] = answer.getData();
for (int i=0; i<r.length; i++)
System.out.print((char)r[i]);
System.out.println();
// Disconnect the card
card.disconnect(false);
}
} catch(Exception e) {
if (! e.toString().matches(".*connect.*")) {
System.out.println("Ouch: " + e.toString());
System.exit(1);
}
}
}
}
}
_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle