Referted the 'Fireofox 1.5' fix in log.c and replaced it by letting a blocking C_WaitForSlotEvent() return CKR_FUNCTION_NOT_SUPPORTED. This isn't a solution for the multihread problems (things hang or try to log to a released context) but at least it solves the Ff 1.5 problems
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2777 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
e56c7a9110
commit
551bcc89fa
|
@ -70,20 +70,14 @@ void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const
|
||||||
int (*display_fn)(sc_context_t *, const char *);
|
int (*display_fn)(sc_context_t *, const char *);
|
||||||
char buf[1536], *p;
|
char buf[1536], *p;
|
||||||
const char *tag = "";
|
const char *tag = "";
|
||||||
int r, suppress_errors;
|
int r;
|
||||||
size_t left;
|
size_t left;
|
||||||
|
|
||||||
/* In case of multiple threads, this function could be called in one thread
|
assert(ctx != NULL);
|
||||||
* while another thread already release the context and set it to NULL.
|
|
||||||
* This is the case with our pkcs11 lib in e.g. Firefox 1.5. */
|
|
||||||
if (ctx == NULL)
|
|
||||||
suppress_errors = 0;
|
|
||||||
else
|
|
||||||
suppress_errors = ctx->suppress_errors;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SC_LOG_TYPE_ERROR:
|
case SC_LOG_TYPE_ERROR:
|
||||||
if (!suppress_errors) {
|
if (!ctx->suppress_errors) {
|
||||||
display_fn = &sc_ui_display_error;
|
display_fn = &sc_ui_display_error;
|
||||||
tag = "error:";
|
tag = "error:";
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +88,7 @@ void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const
|
||||||
type = SC_LOG_TYPE_DEBUG;
|
type = SC_LOG_TYPE_DEBUG;
|
||||||
|
|
||||||
case SC_LOG_TYPE_DEBUG:
|
case SC_LOG_TYPE_DEBUG:
|
||||||
if (ctx != NULL && ctx->debug == 0)
|
if (ctx->debug == 0)
|
||||||
return;
|
return;
|
||||||
display_fn = &sc_ui_display_debug;
|
display_fn = &sc_ui_display_debug;
|
||||||
break;
|
break;
|
||||||
|
@ -119,10 +113,7 @@ void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const
|
||||||
p += r;
|
p += r;
|
||||||
left -= r;
|
left -= r;
|
||||||
|
|
||||||
if (ctx != NULL)
|
|
||||||
display_fn(ctx, buf);
|
display_fn(ctx, buf);
|
||||||
else
|
|
||||||
fprintf(stderr, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sc_hex_dump(sc_context_t *ctx, const u8 * in, size_t count, char *buf, size_t len)
|
void sc_hex_dump(sc_context_t *ctx, const u8 * in, size_t count, char *buf, size_t len)
|
||||||
|
|
|
@ -346,6 +346,18 @@ CK_RV C_WaitForSlotEvent(CK_FLAGS flags, /* blocking/nonblocking flag */
|
||||||
unsigned int mask, events;
|
unsigned int mask, events;
|
||||||
CK_RV rv;
|
CK_RV rv;
|
||||||
|
|
||||||
|
/* Firefox 1.5 calls this function (blocking) from a seperate thread,
|
||||||
|
* which gives 2 problems:
|
||||||
|
* - on Windows/Mac: this waiting thread will log to a NULL context
|
||||||
|
* after the 'main' thread does a C_Finalize() and sets the ctx to NULL.
|
||||||
|
* - on Linux, things just hang (at least on Debian 'sid')
|
||||||
|
* So we just return CKR_FUNCTION_NOT_SUPPORTED on a blocking call,
|
||||||
|
* in which case Ff just seems to default to polling in the main thread
|
||||||
|
* as the Mozilla family of browsers did before.
|
||||||
|
*/
|
||||||
|
if (!(flags & CKF_DONT_BLOCK))
|
||||||
|
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||||
|
|
||||||
rv = sc_pkcs11_lock();
|
rv = sc_pkcs11_lock();
|
||||||
if (rv != CKR_OK)
|
if (rv != CKR_OK)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
Loading…
Reference in New Issue