[Pcsclite-muscle] resource management in pyscard and python-pcsclite
Mark Kohler
mark.kohler
Wed Dec 17 13:23:30 PST 2014
I've been using the smartcard.scard module, part of the pyscard package,
and one thing that isn't clear to me is whether clients of
smartcard.scard are reponsible for calling SCardReleaseContext and
SCardDisconnect, in order to free the resources acquired by
SCardEstablishContext and SCardConnect, respectively.
I'm not 100% clear on the pcsclite architecture, but it seems to me
that, with the pcsclite C API, it would be possible for a client
application to cause leaks in the pcscd daemon, if the application does
not call SCardReleaseContext and SCardDisconnect diligently.
Assuming that is true, I'm wondering if it is also the case that
applications using the smartcard.scard Python wrapper can cause similar
leaks.
The fact that the SCardEstablishContext and SCardConnect return
integers, as opposed to a ref-counted object, also make me think that
there is not any code that tells the Python garbage collector when and
how to release PCSCD resources.
Can anyone confirm this?
---
By contrast, it appears that python-pcsclite library does use the Python
garbage collector to automatically free PCSC resources. I believe that
is the purpose of the Context_dealloc() and Card_dealloc() routines in
pcsclite.c.
Again, can anyone confirm this?
---
And thanks to the authors of both libraries!
Mark
More information about the pcsclite-muscle
mailing list