/[rdesktop]/sourceforge.net/trunk/rdesktop/scard.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/scard.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1326 by stargo, Fri Nov 3 18:57:09 2006 UTC revision 1329 by stargo, Sat Nov 4 17:33:15 2006 UTC
# Line 44  Line 44 
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;
# Line 54  static pthread_t queueHandler; Line 54  static pthread_t queueHandler;
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;
# Line 152  scard_enum_devices(uint32 * id, char *op Line 151  scard_enum_devices(uint32 * id, char *op
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          {          {
# Line 2497  SC_deviceControl(PSCThreadData data) Line 2490  SC_deviceControl(PSCThreadData data)
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    
# Line 2628  DEVICE_FNS scard_fns = { Line 2619  DEVICE_FNS scard_fns = {
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

Legend:
Removed from v.1326  
changed lines
  Added in v.1329

  ViewVC Help
Powered by ViewVC 1.1.26