44 |
|
|
45 |
static struct stream out[STREAM_COUNT]; |
static struct stream out[STREAM_COUNT]; |
46 |
static int cur_stream_id = 0; |
static int cur_stream_id = 0; |
47 |
static pthread_mutex_t *tcp_sendcontrol_mutex = NULL; |
static pthread_mutex_t **scard_mutex = NULL; |
48 |
|
|
49 |
static uint32 curDevice = 0, curId = 0, curBytesOut = 0; |
static uint32 curDevice = 0, curId = 0, curBytesOut = 0; |
50 |
static PSCNameMapRec nameMapList = NULL; |
static PSCNameMapRec nameMapList = NULL; |
54 |
static pthread_mutex_t queueAccess; |
static pthread_mutex_t queueAccess; |
55 |
static pthread_mutex_t queueEmpty; |
static pthread_mutex_t queueEmpty; |
56 |
static pthread_mutex_t hcardAccess; |
static pthread_mutex_t hcardAccess; |
|
static pthread_mutex_t sendControl; |
|
57 |
|
|
58 |
static PMEM_HANDLE threadListHandle = NULL; |
static PMEM_HANDLE threadListHandle = NULL; |
59 |
static PThreadListElement threadList = NULL; |
static PThreadListElement threadList = NULL; |
151 |
return 0; |
return 0; |
152 |
} |
} |
153 |
|
|
|
if (0 != pthread_mutex_init(&sendControl, NULL)) |
|
|
{ |
|
|
error("[SMART CARD: Can't initialize send control mutex]\n"); |
|
|
return 0; |
|
|
} |
|
|
|
|
154 |
if (0 != |
if (0 != |
155 |
pthread_create(&queueHandler, NULL, (void *(*)(void *)) queue_handler_function, NULL)) |
pthread_create(&queueHandler, NULL, (void *(*)(void *)) queue_handler_function, NULL)) |
156 |
{ |
{ |
2490 |
size_t buffer_len = 0; |
size_t buffer_len = 0; |
2491 |
scard_device_control(data->handle, data->request, data->in, data->out); |
scard_device_control(data->handle, data->request, data->in, data->out); |
2492 |
buffer_len = (size_t) data->out->p - (size_t) data->out->data; |
buffer_len = (size_t) data->out->p - (size_t) data->out->data; |
|
pthread_mutex_lock(&sendControl); |
|
2493 |
rdpdr_send_completion(data->device, data->id, 0, buffer_len, data->out->data, buffer_len); |
rdpdr_send_completion(data->device, data->id, 0, buffer_len, data->out->data, buffer_len); |
|
pthread_mutex_unlock(&sendControl); |
|
2494 |
SC_destroyThreadData(data); |
SC_destroyThreadData(data); |
2495 |
} |
} |
2496 |
|
|
2619 |
#endif /* MAKE_PROTO */ |
#endif /* MAKE_PROTO */ |
2620 |
|
|
2621 |
void |
void |
2622 |
scard_tcp_lock(void) |
scard_lock(int lock) |
2623 |
{ |
{ |
2624 |
if (!tcp_sendcontrol_mutex) |
if (!scard_mutex) |
2625 |
|
{ |
2626 |
|
int i; |
2627 |
|
|
2628 |
|
scard_mutex = |
2629 |
|
(pthread_mutex_t **) xmalloc(sizeof(pthread_mutex_t *) * SCARD_LOCK_LAST); |
2630 |
|
|
2631 |
|
for (i = 0; i < SCARD_LOCK_LAST; i++) |
2632 |
|
{ |
2633 |
|
scard_mutex[i] = NULL; |
2634 |
|
} |
2635 |
|
} |
2636 |
|
|
2637 |
|
if (!scard_mutex[lock]) |
2638 |
{ |
{ |
2639 |
tcp_sendcontrol_mutex = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t)); |
scard_mutex[lock] = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t)); |
2640 |
pthread_mutex_init(tcp_sendcontrol_mutex, NULL); |
pthread_mutex_init(scard_mutex[lock], NULL); |
2641 |
} |
} |
2642 |
|
|
2643 |
pthread_mutex_lock(tcp_sendcontrol_mutex); |
pthread_mutex_lock(scard_mutex[lock]); |
2644 |
} |
} |
2645 |
|
|
2646 |
void |
void |
2647 |
scard_tcp_unlock(void) |
scard_unlock(int lock) |
2648 |
{ |
{ |
2649 |
pthread_mutex_unlock(tcp_sendcontrol_mutex); |
pthread_mutex_unlock(scard_mutex[lock]); |
2650 |
} |
} |
2651 |
|
|
2652 |
STREAM |
STREAM |