Browse code

Clean-up: Remove more dead and inactive code paths

These code paths was practically not needed with no locking mechanisms
enabled and was just bloating the source code.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: James Yonan <james@openvpn.net>

David Sommerseth authored on 2010/08/29 03:44:07
Showing 11 changed files
... ...
@@ -298,10 +298,8 @@ gc_malloc (size_t size, bool clear, struct gc_arena *a)
298 298
 #endif
299 299
       check_malloc_return (e);
300 300
       ret = (char *) e + sizeof (struct gc_entry);
301
-      /*mutex_lock_static (L_GC_MALLOC);*/
302 301
       e->next = a->list;
303 302
       a->list = e;
304
-      /*mutex_unlock_static (L_GC_MALLOC);*/
305 303
     }
306 304
   else
307 305
     {
... ...
@@ -323,10 +321,8 @@ void
323 323
 x_gc_free (struct gc_arena *a)
324 324
 {
325 325
   struct gc_entry *e;
326
-  /*mutex_lock_static (L_GC_MALLOC);*/
327 326
   e = a->list;
328 327
   a->list = NULL;
329
-  /*mutex_unlock_static (L_GC_MALLOC);*/
330 328
   
331 329
   while (e != NULL)
332 330
     {
... ...
@@ -454,7 +454,6 @@ encrypt_sign (struct context *c, bool comp_frag)
454 454
    */
455 455
   if (c->c2.tls_multi)
456 456
     {
457
-      /*tls_mutex_lock (c->c2.tls_multi);*/
458 457
       tls_pre_encrypt (c->c2.tls_multi, &c->c2.buf, &c->c2.crypto_options);
459 458
     }
460 459
 #endif
... ...
@@ -482,7 +481,6 @@ encrypt_sign (struct context *c, bool comp_frag)
482 482
   if (c->c2.tls_multi)
483 483
     {
484 484
       tls_post_encrypt (c->c2.tls_multi, &c->c2.buf);
485
-      /*tls_mutex_unlock (c->c2.tls_multi);*/
486 485
     }
487 486
 #endif
488 487
 #endif
... ...
@@ -790,7 +788,6 @@ process_incoming_link (struct context *c)
790 790
 	   * will load crypto_options with the correct encryption key
791 791
 	   * and return false.
792 792
 	   */
793
-	  /*tls_mutex_lock (c->c2.tls_multi);*/
794 793
 	  if (tls_pre_decrypt (c->c2.tls_multi, &c->c2.from, &c->c2.buf, &c->c2.crypto_options))
795 794
 	    {
796 795
 	      interval_action (&c->c2.tmp_int);
... ...
@@ -813,13 +810,6 @@ process_incoming_link (struct context *c)
813 813
       /* authenticate and decrypt the incoming packet */
814 814
       decrypt_status = openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, &c->c2.crypto_options, &c->c2.frame);
815 815
 
816
-#ifdef USE_SSL
817
-      if (c->c2.tls_multi)
818
-	{
819
-	  /*tls_mutex_unlock (c->c2.tls_multi);*/
820
-	}
821
-#endif
822
-      
823 816
       if (!decrypt_status && link_socket_connection_oriented (c->c2.link_socket))
824 817
 	{
825 818
 	  /* decryption errors are fatal in TCP mode */
... ...
@@ -90,7 +90,7 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)
90 90
   if (ms->len == ms->capacity)
91 91
     {
92 92
       struct mbuf_item rm;
93
-      ASSERT (mbuf_extract_item (ms, &rm, false));
93
+      ASSERT (mbuf_extract_item (ms, &rm));
94 94
       mbuf_free_buf (rm.buffer);
95 95
       msg (D_MULTI_DROPPED, "MBUF: mbuf packet dropped");
96 96
     }
... ...
@@ -104,7 +104,7 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)
104 104
 }
105 105
 
106 106
 bool
107
-mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock)
107
+mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item)
108 108
 {
109 109
   bool ret = false;
110 110
   if (ms)
... ...
@@ -73,7 +73,7 @@ void mbuf_free_buf (struct mbuf_buffer *mb);
73 73
 
74 74
 void mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item);
75 75
 
76
-bool mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock);
76
+bool mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item);
77 77
 
78 78
 void mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi);
79 79
 
... ...
@@ -360,7 +360,6 @@ mroute_helper_init (int ageable_ttl_secs)
360 360
 {
361 361
   struct mroute_helper *mh;
362 362
   ALLOC_OBJ_CLEAR (mh, struct mroute_helper);
363
-  /*mutex_init (&mh->mutex);*/
364 363
   mh->ageable_ttl_secs = ageable_ttl_secs;
365 364
   return mh;
366 365
 }
... ...
@@ -398,12 +397,10 @@ mroute_helper_add_iroute (struct mroute_helper *mh, const struct iroute *ir)
398 398
   if (ir->netbits >= 0)
399 399
     {
400 400
       ASSERT (ir->netbits < MR_HELPER_NET_LEN);
401
-      mroute_helper_lock (mh);
402 401
       ++mh->cache_generation;
403 402
       ++mh->net_len_refcount[ir->netbits];
404 403
       if (mh->net_len_refcount[ir->netbits] == 1)
405 404
 	mroute_helper_regenerate (mh);
406
-      mroute_helper_unlock (mh);
407 405
     }
408 406
 }
409 407
 
... ...
@@ -413,20 +410,17 @@ mroute_helper_del_iroute (struct mroute_helper *mh, const struct iroute *ir)
413 413
   if (ir->netbits >= 0)
414 414
     {
415 415
       ASSERT (ir->netbits < MR_HELPER_NET_LEN);
416
-      mroute_helper_lock (mh);
417 416
       ++mh->cache_generation;
418 417
       --mh->net_len_refcount[ir->netbits];
419 418
       ASSERT (mh->net_len_refcount[ir->netbits] >= 0);
420 419
       if (!mh->net_len_refcount[ir->netbits])
421 420
 	mroute_helper_regenerate (mh);
422
-      mroute_helper_unlock (mh);
423 421
     }
424 422
 }
425 423
 
426 424
 void
427 425
 mroute_helper_free (struct mroute_helper *mh)
428 426
 {
429
-  /*mutex_destroy (&mh->mutex);*/
430 427
   free (mh);
431 428
 }
432 429
 
... ...
@@ -91,7 +91,6 @@ struct mroute_addr {
91 91
  * Used to help maintain CIDR routing table.
92 92
  */
93 93
 struct mroute_helper {
94
-  /*MUTEX_DEFINE (mutex);*/
95 94
   unsigned int cache_generation; /* incremented when route added */
96 95
   int ageable_ttl_secs;          /* host route cache entry time-to-live*/
97 96
   int n_net_len;                 /* length of net_len array */
... ...
@@ -159,18 +158,6 @@ mroute_extract_addr_from_packet (struct mroute_addr *src,
159 159
   return ret;
160 160
 }
161 161
 
162
-static inline void
163
-mroute_helper_lock (struct mroute_helper *mh)
164
-{
165
-  /*mutex_lock (&mh->mutex);*/
166
-}
167
-
168
-static inline void
169
-mroute_helper_unlock (struct mroute_helper *mh)
170
-{
171
-  /*mutex_unlock (&mh->mutex);*/
172
-}
173
-
174 162
 static inline bool
175 163
 mroute_addr_equal (const struct mroute_addr *a1, const struct mroute_addr *a2)
176 164
 {
... ...
@@ -264,7 +264,7 @@ multi_tcp_process_outgoing_link_ready (struct multi_context *m, struct multi_ins
264 264
   ASSERT (mi);
265 265
 
266 266
   /* extract from queue */
267
-  if (mbuf_extract_item (mi->tcp_link_out_deferred, &item, true)) /* ciphertext IP packet */
267
+  if (mbuf_extract_item (mi->tcp_link_out_deferred, &item)) /* ciphertext IP packet */
268 268
     {
269 269
       dmsg (D_MULTI_TCP, "MULTI TCP: transmitting previously deferred packet");
270 270
 
... ...
@@ -1000,8 +1000,6 @@ multi_get_instance_by_virtual_addr (struct multi_context *m,
1000 1000
       struct mroute_addr tryaddr;
1001 1001
       int i;
1002 1002
 
1003
-      mroute_helper_lock (rh);
1004
-
1005 1003
       /* cycle through each CIDR length */
1006 1004
       for (i = 0; i < rh->n_net_len; ++i)
1007 1005
 	{
... ...
@@ -1022,8 +1020,6 @@ multi_get_instance_by_virtual_addr (struct multi_context *m,
1022 1022
 	      break;
1023 1023
 	    }
1024 1024
 	}
1025
-      
1026
-      mroute_helper_unlock (rh);
1027 1025
     }
1028 1026
   
1029 1027
 #ifdef ENABLE_DEBUG
... ...
@@ -2240,7 +2236,7 @@ multi_get_queue (struct mbuf_set *ms)
2240 2240
 {
2241 2241
   struct mbuf_item item;
2242 2242
 
2243
-  if (mbuf_extract_item (ms, &item, true)) /* cleartext IP packet */
2243
+  if (mbuf_extract_item (ms, &item)) /* cleartext IP packet */
2244 2244
     {
2245 2245
       unsigned int pipv4_flags = PIPV4_PASSTOS;
2246 2246
 
... ...
@@ -460,9 +460,6 @@ struct context
460 460
   /* true on initial VPN iteration */
461 461
   bool first_time;
462 462
 
463
-  /* used by multi-client code to lock the context */
464
-  /*MUTEX_DEFINE (mutex);*/
465
-
466 463
   /* context modes */
467 464
 # define CM_P2P            0 /* standalone point-to-point session or client */
468 465
 # define CM_TOP            1 /* top level of a multi-client or point-to-multipoint server */
... ...
@@ -3814,8 +3814,6 @@ tls_process (struct tls_multi *multi,
3814 3814
 	msg (D_TLS_DEBUG_LOW, "TLS: tls_process: killed expiring key");
3815 3815
   }
3816 3816
 
3817
-  /*mutex_cycle (multi->mutex);*/
3818
-
3819 3817
   do
3820 3818
     {
3821 3819
       update_time ();
... ...
@@ -4099,7 +4097,6 @@ tls_process (struct tls_multi *multi,
4099 4099
 		}
4100 4100
 	    }
4101 4101
 	}
4102
-      /*mutex_cycle (multi->mutex);*/
4103 4102
     }
4104 4103
   while (state_change);
4105 4104
 
... ...
@@ -4253,7 +4250,6 @@ tls_multi_process (struct tls_multi *multi,
4253 4253
 		reset_session (multi, session);
4254 4254
 	    }
4255 4255
 	}
4256
-      /*mutex_cycle (multi->mutex);*/
4257 4256
     }
4258 4257
 
4259 4258
   update_time ();
... ...
@@ -573,9 +573,6 @@ struct tls_session
573 573
  */
574 574
 struct tls_multi
575 575
 {
576
-  /* used to coordinate access between main thread and TLS thread */
577
-  /*MUTEX_PTR_DEFINE (mutex);*/
578
-
579 576
   /* const options and config info */
580 577
   struct tls_options opt;
581 578