Code clean-up - removing "dead" code.
cover Code clean-up - removing "dead" code.
This is a patch series which tries to do some source code clean-up. After having noticed that ./configure --enable-pthread was simply doing *nothing*, as it was forcefully being disabled in syshead.h, I went through the code and began cleaning up this and some of the related code.
As threading is not buildable in the current code base and OpenVPN 3.x most likely will have a brand new design in regards to the threading, it seemed to be better to clean up this code. This is also to remove false presumptions that OpenVPN supports threads.
kind regards,
David Sommerseth
*** BLURB HERE ***
David Sommerseth (3):
Clean-up: Remove pthread and mutex locking code
Clean-up: Remove more dead and inactive code paths
Clean-up: Removing useless code - hash related functions
Makefile.am | 1 - acinclude.m4 | 224 ----------------------------------------------------- buffer.c | 5 - buffer.h | 1 - config-win32.h | 5 - configure.ac | 38 +--------- crypto.c | 3 - error.c | 39 --------- error.h | 17 ---- forward.c | 10 --- init.c | 50 ------------ list.c | 24 +----- list.h | 33 +------- mbuf.c | 16 +---- mbuf.h | 3 +- misc.c | 23 ------ mroute.c | 6 -- mroute.h | 13 --- mtcp.c | 5 +- mudp.c | 3 - multi.c | 32 +++----- multi.h | 2 - openvpn.h | 3 - options.c | 36 --------- options.h | 5 - otime.c | 2 - otime.h | 1 - perf.c | 4 - pf.c | 2 +- plugin.c | 4 - pool.h | 1 - schedule.c | 4 - schedule.h | 8 -- socket.c | 7 -- ssl.c | 5 - ssl.h | 4 - syshead.h | 18 ---- thread.c | 156 ------------------------------------- thread.h | 235 -------------------------------------------------------- 39 files changed, 26 insertions(+), 1022 deletions(-) delete mode 100644 thread.c delete mode 100644 thread.h
Signature · 1 line
1.7.2.2
PATCH 1/3 Clean-up: Remove pthread and mutex locking code
This code was not activated at all, and hard coded as disabled in syshead.h with this code snippet:
/*
* Pthread support is currently experimental (and quite unfinished).
*/
#if 1 /* JYFIXME -- if defined, disable pthread */
#undef USE_PTHREAD
#endifSo no matter if --enable-pthread when running ./configure or not, this feature was never enabled in reality. Further, by removing the blocker code above made OpenVPN uncompilable in the current state.
As the threading part needs to be completely rewritten and pthreading will not be supported in OpenVPN 2.x, removing this code seems most reasonable.
In addition, a lot of mutex locking code was also removed, as they were practically NOP functions, due to pthreading being forcefully disabled
--- Makefile.am | 1 - acinclude.m4 | 224 ----------------------------------------------------- buffer.c | 1 - buffer.h | 1 - config-win32.h | 5 - configure.ac | 38 +--------- crypto.c | 3 - error.c | 39 --------- error.h | 17 ---- init.c | 50 ------------ list.c | 13 --- list.h | 8 -- mbuf.c | 12 --- mbuf.h | 1 - misc.c | 23 ------ multi.c | 1 - multi.h | 2 - options.c | 36 --------- options.h | 5 - otime.c | 2 - otime.h | 1 - perf.c | 4 - plugin.c | 4 - pool.h | 1 - schedule.c | 4 - schedule.h | 8 -- socket.c | 7 -- ssl.c | 1 - ssl.h | 1 - syshead.h | 18 ---- thread.c | 156 ------------------------------------- thread.h | 235 -------------------------------------------------------- 32 files changed, 1 insertions(+), 921 deletions(-) delete mode 100644 thread.c delete mode 100644 thread.h
Makefile.am +0 -1
@@ -135,7 +135,6 @@ openvpn_SOURCES = \ ssl.c ssl.h \ status.c status.h \ syshead.h \ - thread.c thread.h \ tun.c tun.h \ win32.h win32.c \ cryptoapi.h cryptoapi.c
acinclude.m4 +0 -224
227 lines not on this page · raw message
buffer.c +0 -1
@@ -28,7 +28,6 @@#include "buffer.h" #include "error.h" #include "mtu.h" -#include "thread.h" #include "memdbg.h"
buffer.h +0 -1
@@ -26,7 +26,6 @@#define BUFFER_H #include "basic.h" -#include "thread.h" #define BUF_SIZE_MAX 1000000
config-win32.h +0 -5
@@ -270,11 +270,6 @@ typedef unsigned long in_addr_t;/* Route command */ #define ROUTE_PATH "route" -/* Windows doesn't support PTHREAD yet */ -#ifdef USE_PTHREAD -#error The Windows version of OpenVPN does not support PTHREAD yet -#endif -#ifdef _MSC_VER/* MSVC++ hacks */ #pragma warning(disable:4244) // conversion from 'foo' to 'bar', possible loss of data
configure.ac +1 -37
@@ -152,12 +152,6 @@ AC_ARG_ENABLE(small, [SMALL="no"] ) -AC_ARG_ENABLE(pthread, - [ --enable-pthread Enable pthread support (Experimental for OpenVPN 2.0)], - [PTHREAD="$enableval"], - [PTHREAD="no"] -) - AC_ARG_ENABLE(password-save, [ --enable-password-save Allow --askpass and --auth-user-pass passwords to be read from a file], [PASSWORD_SAVE="$enableval"],
@@ -575,32 +569,6 @@ if test "$MEMCHECK" = "valgrind"; then fi dnl -dnl check for pthread library -dnl - -if test "$PTHREAD" = "yes"; then - AC_CHECKING([for pthread support]) - AC_MSG_RESULT([********* WARNING: pthread support is experimental for OpenVPN 2.0]) - ACX_PTHREAD( - [ - case "$host" in - *openbsd*) - AC_MSG_RESULT([WARNING: pthread support on OpenBSD is unstable!]) - CFLAGS="$CFLAGS -pthread" - ;; - esac - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - CC="$PTHREAD_CC" - AC_DEFINE(USE_PTHREAD, 1, [Use pthread-based multithreading]) - ], - [ - AC_MSG_RESULT([I don't know how to build with pthread support on this platform.]) - AC_MSG_ERROR([try ./configure --disable-pthread]) - ]) -fi - -dnl dnl check for dmalloc library dnl
@@ -609,11 +577,7 @@ if test "$MEMCHECK" = "dmalloc"; then AC_CHECK_HEADER(dmalloc.h, [AC_CHECK_LIB(dmalloc, malloc, [ - if test "$PTHREAD" = "yes"; then - OPENVPN_ADD_LIBS(-ldmallocth) - else - OPENVPN_ADD_LIBS(-ldmalloc) - fi + OPENVPN_ADD_LIBS(-ldmalloc) AC_DEFINE(DMALLOC, 1, [Use dmalloc memory debugging library]) ], [AC_MSG_ERROR([dmalloc library not found.])]
crypto.c +0 -3
@@ -29,7 +29,6 @@#include "crypto.h" #include "error.h" #include "misc.h" -#include "thread.h" #include "memdbg.h"
@@ -1702,7 +1701,6 @@ prng_bytes (uint8_t *output, int len) {EVP_MD_CTX ctx;const int md_size =EVP_MD_size (nonce_md); -mutex_lock_static (L_PRNG );while (len >0 ) {unsigned int outlen =0 ;
@@ -1716,7 +1714,6 @@ prng_bytes (uint8_t *output, int len) output += blen; len -= blen; } -mutex_unlock_static (L_PRNG ); }else RAND_bytes (output, len);
error.c +0 -39
@@ -26,7 +26,6 @@#include "error.h" #include "buffer.h" -#include "thread.h" #include "misc.h" #include "win32.h" #include "socket.h"
@@ -229,8 +228,6 @@ void x_msg (const unsigned int flags, const char *format, ...)gc_init (&gc); -mutex_lock_static (L_MSG ); - m1 = (char *)gc_malloc (ERR_BUF_SIZE , false, &gc); m2 = (char *)gc_malloc (ERR_BUF_SIZE , false, &gc);
@@ -330,22 +327,12 @@ void x_msg (const unsigned int flags, const char *format, ...) }else { -#ifdef USE_PTHREAD -fprintf (fp,"%s [%d] %s%s%s%s" , -time_string (0 ,0 , show_usec, &gc), - (int )openvpn_thread_self (), - prefix, - prefix_sep, - m1, - (flags&M_NOLF ) ?"" :"\n" ); -#else fprintf (fp,"%s %s%s%s%s" ,time_string (0 ,0 , show_usec, &gc), prefix, prefix_sep, m1, (flags&M_NOLF ) ?"" :"\n" ); -#endif }fflush (fp); ++x_msg_line_num;
@@ -355,8 +342,6 @@ void x_msg (const unsigned int flags, const char *format, ...)if (flags &M_FATAL )msg (M_INFO ,"Exiting" ); -mutex_unlock_static (L_MSG ); -if (flags &M_FATAL )openvpn_exit (OPENVPN_EXIT_STATUS_ERROR );/* exit point */
@@ -645,10 +630,6 @@ x_check_status (int status,*/ const char *x_msg_prefix;/* GLOBAL */ -#ifdef USE_PTHREAD -pthread_key_t x_msg_prefix_key;/* GLOBAL */ -#endif -/* * Allow MSG to be redirected through a virtual_output object */
@@ -656,26 +637,6 @@ pthread_key_t x_msg_prefix_key; /* GLOBAL */const struct virtual_output *x_msg_virtual_output;/* GLOBAL */ /* -* Init thread-local variables -*/ - -void -msg_thread_init (void ) -{ -#ifdef USE_PTHREAD -ASSERT (!pthread_key_create (&x_msg_prefix_key,NULL )); -#endif -} - -void -msg_thread_uninit (void ) -{ -#ifdef USE_PTHREAD -pthread_key_delete (x_msg_prefix_key); -#endif -} - -/* * Exiting. */
error.h +0 -17
@@ -26,7 +26,6 @@#define ERROR_H #include "basic.h" -#include "thread.h" /* #define ABORT_ON_ERROR */
@@ -282,34 +281,18 @@ set_check_status_error_delay (unsigned int milliseconds)extern const char *x_msg_prefix; -#ifdef USE_PTHREAD -extern pthread_key_t x_msg_prefix_key; -#endif -void msg_thread_init (void );void msg_thread_uninit (void );static inline void msg_set_prefix (const char *prefix) { -#ifdef USE_PTHREAD -if (openvpn_thread_enabled ()) - { -ASSERT (!pthread_setspecific (x_msg_prefix_key, prefix)); - } - else -#endif x_msg_prefix = prefix; }static inline const char *msg_get_prefix (void ) { -#ifdef USE_PTHREAD -if (openvpn_thread_enabled ()) -return (const char *)pthread_getspecific (x_msg_prefix_key); - else -#endif return x_msg_prefix; }
init.c +0 -50
81 lines not on this page · raw message
list.c +0 -13
@@ -52,7 +52,6 @@ hash_init (const int n_buckets, {struct hash_bucket *b = &h->buckets[i]; b->list =NULL ; -mutex_init (&b->mutex); }return h; }
@@ -66,7 +65,6 @@ hash_free (struct hash *hash)struct hash_bucket *b = &hash->buckets[i];struct hash_element *he = b->list; -mutex_destroy (&b->mutex);while (he) {struct hash_element *next = he->next;
@@ -148,7 +146,6 @@ hash_add (struct hash *hash, const void *key, void *value, bool replace) hv =hash_value (hash, key); bucket = &hash->buckets[hv & hash->mask]; -mutex_lock (&bucket->mutex);if ((he =hash_lookup_fast (hash, bucket, key, hv)))/* already exists? */ {
@@ -164,8 +161,6 @@ hash_add (struct hash *hash, const void *key, void *value, bool replace) ret = true; } -mutex_unlock (&bucket->mutex); -return ret; }
@@ -257,10 +252,6 @@ hash_iterator_init (struct hash *hash,static inline void hash_iterator_lock (struct hash_iterator *hi,struct hash_bucket *b) { -if (hi->autolock) - { -mutex_lock (&b->mutex); - } hi->bucket = b; hi->last =NULL ; hi->bucket_marked = false;
@@ -276,10 +267,6 @@ hash_iterator_unlock (struct hash_iterator *hi)hash_remove_marked (hi->hash, hi->bucket); hi->bucket_marked = false; } -if (hi->autolock) - { -mutex_unlock (&hi->bucket->mutex); - } hi->bucket =NULL ; hi->last =NULL ; }
list.h +0 -8
@@ -40,7 +40,6 @@/*#define LIST_TEST*/ #include "basic.h" -#include "thread.h" #include "buffer.h" #define hashsize (n) ((uint32_t)1<<(n))
@@ -56,7 +55,6 @@ struct hash_elementstruct hash_bucket { -MUTEX_DEFINE (mutex);struct hash_element *list; };
@@ -152,13 +150,11 @@ hash_bucket (struct hash *hash, uint32_t hv)static inline void hash_bucket_lock (struct hash_bucket *bucket) { -mutex_lock (&bucket->mutex); }static inline void hash_bucket_unlock (struct hash_bucket *bucket) { -mutex_unlock (&bucket->mutex); } static inline void *
@@ -168,11 +164,9 @@ hash_lookup_lock (struct hash *hash, const void *key, uint32_t hv)struct hash_element *he;struct hash_bucket *bucket = &hash->buckets[hv & hash->mask]; -mutex_lock (&bucket->mutex); he =hash_lookup_fast (hash, bucket, key, hv);if (he) ret = he->value; -mutex_unlock (&bucket->mutex);return ret; }
@@ -211,9 +205,7 @@ hash_remove (struct hash *hash, const void *key) hv =hash_value (hash, key); bucket = &hash->buckets[hv & hash->mask]; -mutex_lock (&bucket->mutex); ret =hash_remove_fast (hash, bucket, key, hv); -mutex_unlock (&bucket->mutex);return ret; }
mbuf.c +0 -12
@@ -38,7 +38,6 @@ mbuf_init (unsigned int size) {struct mbuf_set *ret; ALLOC_OBJ_CLEAR (ret, struct mbuf_set); -mutex_init (&ret->mutex); ret->capacity =adjust_power_of_2 (size); ALLOC_ARRAY (ret->array, struct mbuf_item, ret->capacity);return ret;
@@ -56,7 +55,6 @@ mbuf_free (struct mbuf_set *ms)mbuf_free_buf (item->buffer); }free (ms->array); -mutex_destroy (&ms->mutex);free (ms); } }
@@ -89,7 +87,6 @@ void mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item) {ASSERT (ms); -mutex_lock (&ms->mutex);if (ms->len == ms->capacity) {struct mbuf_item rm;
@@ -104,7 +101,6 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)if (++ms->len > ms->max_queued) ms->max_queued = ms->len; ++item->buffer->refcount; -mutex_unlock (&ms->mutex); }bool
@@ -113,8 +109,6 @@ mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock)bool ret = false;if (ms) { -if (lock) -mutex_lock (&ms->mutex);while (ms->len) { *item = ms->array[ms->head];
@@ -126,8 +120,6 @@ mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock)break ; } } -if (lock) -mutex_unlock (&ms->mutex); }return ret; }
@@ -139,7 +131,6 @@ mbuf_peek_dowork (struct mbuf_set *ms)if (ms) {int i; -mutex_lock (&ms->mutex);for (i =0 ; i < (int ) ms->len; ++i) {struct mbuf_item *item = &ms->array[MBUF_INDEX (ms->head, i, ms->capacity)];
@@ -149,7 +140,6 @@ mbuf_peek_dowork (struct mbuf_set *ms)break ; } } -mutex_unlock (&ms->mutex); }return ret; }
@@ -160,7 +150,6 @@ mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi)if (ms) {int i; -mutex_lock (&ms->mutex);for (i =0 ; i < (int ) ms->len; ++i) {struct mbuf_item *item = &ms->array[MBUF_INDEX (ms->head, i, ms->capacity)];
@@ -172,7 +161,6 @@ mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi)msg (D_MBUF ,"MBUF: dereferenced queued packet" ); } } -mutex_unlock (&ms->mutex); } }
mbuf.h +0 -1
@@ -58,7 +58,6 @@ struct mbuf_itemstruct mbuf_set { -MUTEX_DEFINE (mutex);unsigned int head;unsigned int len;unsigned int capacity;
misc.c +0 -23
@@ -28,7 +28,6 @@#include "misc.h" #include "tun.h" #include "error.h" -#include "thread.h" #include "otime.h" #include "plugin.h" #include "options.h"
@@ -636,9 +635,7 @@ strerror_ts (int errnum, struct gc_arena *gc)#ifdef HAVE_STRERROR struct buffer out =alloc_buf_gc (256 , gc); -mutex_lock_static (L_STRERR );buf_printf (&out,"%s" ,openvpn_strerror (errnum, gc)); -mutex_unlock_static (L_STRERR );return BSTR (&out);#else return "[error string unavailable]" ;
@@ -776,18 +773,15 @@ struct env_set * env_set_create (struct gc_arena *gc) {struct env_set *es; -mutex_lock_static (L_ENV_SET ); ALLOC_OBJ_CLEAR_GC (es, struct env_set, gc); es->list =NULL ; es->gc = gc; -mutex_unlock_static (L_ENV_SET );return es; }void env_set_destroy (struct env_set *es) { -mutex_lock_static (L_ENV_SET );if (es && es->gc ==NULL ) {struct env_item *e = es->list;
@@ -800,7 +794,6 @@ env_set_destroy (struct env_set *es) }free (es); } -mutex_unlock_static (L_ENV_SET ); }bool
@@ -809,9 +802,7 @@ env_set_del (struct env_set *es, const char *str)bool ret;ASSERT (es);ASSERT (str); -mutex_lock_static (L_ENV_SET ); ret =env_set_del_nolock (es, str); -mutex_unlock_static (L_ENV_SET );return ret; }
@@ -820,9 +811,7 @@ env_set_add (struct env_set *es, const char *str) {ASSERT (es);ASSERT (str); -mutex_lock_static (L_ENV_SET );env_set_add_nolock (es, str); -mutex_unlock_static (L_ENV_SET ); }void
@@ -835,7 +824,6 @@ env_set_print (int msglevel, const struct env_set *es)if (es) { -mutex_lock_static (L_ENV_SET ); e = es->list; i =0 ;
@@ -846,7 +834,6 @@ env_set_print (int msglevel, const struct env_set *es) ++i; e = e->next; } -mutex_unlock_static (L_ENV_SET ); } } }
@@ -860,14 +847,12 @@ env_set_inherit (struct env_set *es, const struct env_set *src)if (src) { -mutex_lock_static (L_ENV_SET ); e = src->list;while (e) {env_set_add_nolock (es, e->string); e = e->next; } -mutex_unlock_static (L_ENV_SET ); } }
@@ -879,7 +864,6 @@ env_set_add_to_environment (const struct env_set *es)struct gc_arena gc =gc_new ();const struct env_item *e; -mutex_lock_static (L_ENV_SET ); e = es->list;while (e)
@@ -892,7 +876,6 @@ env_set_add_to_environment (const struct env_set *es) e = e->next; } -mutex_unlock_static (L_ENV_SET );gc_free (&gc); } }
@@ -905,7 +888,6 @@ env_set_remove_from_environment (const struct env_set *es)struct gc_arena gc =gc_new ();const struct env_item *e; -mutex_lock_static (L_ENV_SET ); e = es->list;while (e)
@@ -918,7 +900,6 @@ env_set_remove_from_environment (const struct env_set *es) e = e->next; } -mutex_unlock_static (L_ENV_SET );gc_free (&gc); } }
@@ -1037,12 +1018,10 @@ setenv_str_ex (struct env_set *es,char *str =construct_name_value (name_tmp, val_tmp,NULL );int status; -mutex_lock_static (L_PUTENV ); status =putenv (str);/*msg (M_INFO, "PUTENV '%s'", str);*/ if (!status)manage_env (str); -mutex_unlock_static (L_PUTENV );if (status)msg (M_WARN |M_ERRNO ,"putenv('%s') failed" , str); }
@@ -1179,9 +1158,7 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gcconst char *rndstr; ++attempts; -mutex_lock_static (L_CREATE_TEMP ); ++counter; -mutex_unlock_static (L_CREATE_TEMP );prng_bytes (rndbytes,sizeof rndbytes); rndstr =format_hex_ex (rndbytes,sizeof rndbytes,40 ,0 ,NULL , gc);
multi.c +0 -1
@@ -633,7 +633,6 @@ multi_create_instance (struct multi_context *m, const struct mroute_addr *real) ALLOC_OBJ_CLEAR (mi, struct multi_instance); -mutex_init (&mi->mutex); mi->gc =gc_new ();multi_instance_inc_refcount (mi); mi->vaddr_handle =-1 ;
multi.h +0 -2
@@ -56,7 +56,6 @@ struct multi_reapstruct multi_instance {struct schedule_entry se;/* this must be the first element of the structure */ struct gc_arena gc; -MUTEX_DEFINE (mutex);bool defined;bool halt;int refcount;
@@ -274,7 +273,6 @@ multi_instance_dec_refcount (struct multi_instance *mi)if (--mi->refcount <=0 ) {gc_free (&mi->gc); -mutex_destroy (&mi->mutex);free (mi); } }
options.c +0 -36
@@ -67,9 +67,6 @@ const char title_string[] =#ifdef PRODUCT_TAP_DEBUG " [TAPDBG]"#endif -#ifdef USE_PTHREAD - " [PTHREAD]" -#endif #ifdef ENABLE_PKCS11 " [PKCS11]"#endif
@@ -287,13 +284,6 @@ static const char usage_message[] ="--suppress-timestamps : Don't log timestamps to stdout/stderr.\n" "--writepid file : Write main process ID to file.\n" "--nice n : Change process priority (>0 = lower, <0 = higher).\n" -#if 0 -#ifdef USE_PTHREAD -"--nice-work n : Change thread priority of work thread. The work\n" -" thread is used for background processing such as\n" - " RSA key number crunching.\n" -#endif -#endif "--echo [parms ...] : Echo parameters to log output.\n" "--verb n : Set output verbosity to n (default=%d):\n" " (Level 3 is recommended if you want a good summary\n"
@@ -719,9 +709,6 @@ init_options (struct options *o, const bool init_gc) o->tuntap_options.dhcp_masq_offset =0 ;/* use network address as internal DHCP server address */ o->route_method =ROUTE_METHOD_ADAPTIVE ;#endif -#ifdef USE_PTHREAD - o->n_threads =1 ; -#endif #if P2MP_SERVER o->real_hash_size =256 ; o->virtual_hash_size =256 ;
@@ -870,9 +857,6 @@ is_persist_option (const struct options *o) || o->persist_key || o->persist_local_ip || o->persist_remote_ip -#ifdef USE_PTHREAD - || o->n_threads >=2 -#endif ; }
@@ -4197,26 +4181,6 @@ add_option (struct options *options, goto err;#endif } -#ifdef USE_PTHREAD - else if (streq (p[0], "nice-work") && p[1]) - { -VERIFY_PERMISSION (OPT_P_NICE ); - options->nice_work =atoi (p[1 ]); - } - else if (streq (p[0], "threads") && p[1]) - { -int n_threads; - -VERIFY_PERMISSION (OPT_P_GENERAL ); - n_threads =positive_atoi (p[1 ]); -if (n_threads <1 ) - { -msg (msglevel,"--threads parameter must be at least 1" ); - goto err; - } - options->n_threads = n_threads; - } -#endif else if (streq (p[0 ],"shaper" ) && p[1 ]) {#ifdef HAVE_GETTIMEOFDAY
options.h +0 -5
@@ -352,11 +352,6 @@ struct optionsstruct plugin_option_list *plugin_list;#endif -#ifdef USE_PTHREAD -int n_threads; -int nice_work; -#endif -#if P2MP #if P2MP_SERVER
otime.c +0 -2
@@ -123,10 +123,8 @@ time_string (time_t t, int usec, bool show_usec, struct gc_arena *gc) } } -mutex_lock_static (L_CTIME ); t = tv.tv_sec;buf_printf (&out,"%s" ,ctime (&t)); -mutex_unlock_static (L_CTIME );buf_rmtail (&out,'\n' );if (show_usec && tv.tv_usec)
otime.h +0 -1
@@ -28,7 +28,6 @@#include "common.h" #include "integer.h" #include "buffer.h" -#include "thread.h" struct frequency_limit {
perf.c +0 -4
@@ -33,10 +33,6 @@#include "memdbg.h" -#ifdef USE_PTHREAD -#error ENABLE_PERFORMANCE_METRICS is incompatible with USE_PTHREAD -#endif -static const char *metric_names[] = {"PERF_BIO_READ_PLAINTEXT" ,"PERF_BIO_WRITE_PLAINTEXT" ,
plugin.c +0 -4
@@ -558,8 +558,6 @@ plugin_call (const struct plugin_list *pl,bool error = false;bool deferred = false; -mutex_lock_static (L_PLUGIN ); -setenv_del (es,"script_type" ); envp =make_env_array (es, false, &gc);
@@ -588,8 +586,6 @@ plugin_call (const struct plugin_list *pl,if (pr) pr->n = i; -mutex_unlock_static (L_PLUGIN ); -gc_free (&gc);if (type ==OPENVPN_PLUGIN_ENABLE_PF && success)
pool.h +0 -1
@@ -31,7 +31,6 @@#include "basic.h" #include "status.h" -#include "thread.h" #define IFCONFIG_POOL_MAX 65536#define IFCONFIG_POOL_MIN_NETBITS 16
schedule.c +0 -4
@@ -363,24 +363,20 @@ schedule_init (void)struct schedule *s; ALLOC_OBJ_CLEAR (s, struct schedule); -mutex_init (&s->mutex);return s; }void schedule_free (struct schedule *s) { -mutex_destroy (&s->mutex);free (s); }void schedule_remove_entry (struct schedule *s,struct schedule_entry *e) { -mutex_lock (&s->mutex); s->earliest_wakeup =NULL ;/* invalidate cache */ schedule_remove_node (s, e); -mutex_unlock (&s->mutex); }/*
schedule.h +0 -8
@@ -42,7 +42,6 @@/*#define SCHEDULE_TEST*/ #include "otime.h" -#include "thread.h" #include "error.h" struct schedule_entry
@@ -56,7 +55,6 @@ struct schedule_entrystruct schedule { -MUTEX_DEFINE (mutex);struct schedule_entry *earliest_wakeup;/* cached earliest wakeup */ struct schedule_entry *root;/* the root of the treap (btree) */ };
@@ -100,14 +98,12 @@ schedule_add_entry (struct schedule *s,const struct timeval *tv, unsigned int sigma) { - mutex_lock (&s->mutex); if (!IN_TREE (e) || !sigma || !tv_within_sigma (tv, &e->tv, sigma)) { e->tv = *tv;schedule_add_modify (s, e); s->earliest_wakeup =NULL ;/* invalidate cache */ } -mutex_unlock (&s->mutex); }/*
@@ -122,8 +118,6 @@ schedule_get_earliest_wakeup (struct schedule *s, {struct schedule_entry *ret; -mutex_lock (&s->mutex); -/* cache result */ if (!s->earliest_wakeup) s->earliest_wakeup =schedule_find_least (s->root);
@@ -131,8 +125,6 @@ schedule_get_earliest_wakeup (struct schedule *s,if (ret) *wakeup = ret->tv; -mutex_unlock (&s->mutex); -return ret; }
socket.c +0 -7
@@ -26,7 +26,6 @@#include "socket.h" #include "fdmisc.h" -#include "thread.h" #include "misc.h" #include "gremlin.h" #include "plugin.h"
@@ -1934,10 +1933,8 @@ print_sockaddr_ex (const struct openvpn_sockaddr *addr,struct buffer out =alloc_buf_gc (64 , gc);const int port =ntohs (addr->sa.sin_port); -mutex_lock_static (L_INET_NTOA );if (!(flags &PS_DONT_SHOW_ADDR ))buf_printf (&out,"%s" , (addr_defined (addr) ?inet_ntoa (addr->sa.sin_addr) :"[undef]" )); -mutex_unlock_static (L_INET_NTOA );if (((flags &PS_SHOW_PORT ) || (addr_defined (addr) && (flags &PS_SHOW_PORT_IF_DEFINED ))) && port)
@@ -1999,9 +1996,7 @@ print_in_addr_t (in_addr_t addr, unsigned int flags, struct gc_arena *gc)CLEAR (ia); ia.s_addr = (flags &IA_NET_ORDER ) ? addr :htonl (addr); -mutex_lock_static (L_INET_NTOA );buf_printf (&out,"%s" ,inet_ntoa (ia)); -mutex_unlock_static (L_INET_NTOA ); }return BSTR (&out); }
@@ -2017,9 +2012,7 @@ setenv_sockaddr (struct env_set *es, const char *name_prefix, const struct openvelse openvpn_snprintf (name_buf,sizeof (name_buf),"%s" , name_prefix); -mutex_lock_static (L_INET_NTOA );setenv_str (es, name_buf,inet_ntoa (addr->sa.sin_addr)); -mutex_unlock_static (L_INET_NTOA );if ((flags &SA_IP_PORT ) && addr->sa.sin_port) {
ssl.c +0 -1
@@ -39,7 +39,6 @@#include "common.h" #include "integer.h" #include "socket.h" -#include "thread.h" #include "misc.h" #include "fdmisc.h" #include "interval.h"
ssl.h +0 -1
@@ -42,7 +42,6 @@#include "reliable.h" #include "socket.h" #include "mtu.h" -#include "thread.h" #include "options.h" #include "plugin.h"
syshead.h +0 -18
@@ -542,24 +542,6 @@ socket_defined (const socket_descriptor_t sd)#endif /* -* Do we have pthread capability? -*/ -#ifdef USE_PTHREAD -#if defined(USE_CRYPTO ) && defined(USE_SSL ) &&P2MP -#include <pthread.h> -#else -#undef USE_PTHREAD -#endif -#endif - -/* -* Pthread support is currently experimental (and quite unfinished). -*/ -#if 1 /* JYFIXME -- if defined, disable pthread */ -#undef USE_PTHREAD -#endif - -/* * Should we include OCC (options consistency check) code? */ #ifndef ENABLE_SMALL
thread.c deleted +0 -156
156 lines not on this page · raw message
thread.h deleted +0 -235
235 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH 2/3 Clean-up: Remove more dead and inactive code paths
In reply to David SommersethThese code paths was practically not needed with no locking mechanisms enabled and was just bloating the source code.
--- buffer.c | 4 ---- forward.c | 10 ---------- mbuf.c | 4 ++-- mbuf.h | 2 +- mroute.c | 6 ------ mroute.h | 13 ------------- mtcp.c | 2 +- multi.c | 6 +----- openvpn.h | 3 --- ssl.c | 4 ---- ssl.h | 3 --- 11 files changed, 5 insertions(+), 52 deletions(-)
buffer.c +0 -4
@@ -298,10 +298,8 @@ gc_malloc (size_t size, bool clear, struct gc_arena *a)#endif check_malloc_return (e); ret = (char *) e +sizeof (struct gc_entry ); -/*mutex_lock_static (L_GC_MALLOC);*/ e->next = a->list; a->list = e; -/*mutex_unlock_static (L_GC_MALLOC);*/ }else {
@@ -323,10 +321,8 @@ void x_gc_free (struct gc_arena *a) {struct gc_entry *e; -/*mutex_lock_static (L_GC_MALLOC);*/ e = a->list; a->list =NULL ; -/*mutex_unlock_static (L_GC_MALLOC);*/ while (e !=NULL ) {
forward.c +0 -10
@@ -454,7 +454,6 @@ encrypt_sign (struct context *c, bool comp_frag)*/ if (c->c2.tls_multi) { -/*tls_mutex_lock (c->c2.tls_multi);*/ tls_pre_encrypt (c->c2.tls_multi, &c->c2.buf, &c->c2.crypto_options); }#endif
@@ -482,7 +481,6 @@ encrypt_sign (struct context *c, bool comp_frag)if (c->c2.tls_multi) {tls_post_encrypt (c->c2.tls_multi, &c->c2.buf); -/*tls_mutex_unlock (c->c2.tls_multi);*/ }#endif #endif
@@ -801,7 +799,6 @@ process_incoming_link (struct context *c)* will load crypto_options with the correct encryption key * and return false. */ -/*tls_mutex_lock (c->c2.tls_multi);*/ if (tls_pre_decrypt (c->c2.tls_multi, &c->c2.from, &c->c2.buf, &c->c2.crypto_options)) {interval_action (&c->c2.tmp_int);
@@ -824,13 +821,6 @@ process_incoming_link (struct context *c)/* authenticate and decrypt the incoming packet */ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, &c->c2.crypto_options, &c->c2.frame); -#ifdef USE_SSL -if (c->c2.tls_multi) - { -/*tls_mutex_unlock (c->c2.tls_multi);*/ - } -#endif -if (!decrypt_status &&link_socket_connection_oriented (c->c2.link_socket)) {/* decryption errors are fatal in TCP mode */
mbuf.c +2 -2
@@ -90,7 +90,7 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)if (ms->len == ms->capacity) {struct mbuf_item rm; -ASSERT (mbuf_extract_item (ms, &rm, false)); +ASSERT (mbuf_extract_item (ms, &rm));mbuf_free_buf (rm.buffer);msg (D_MULTI_DROPPED ,"MBUF: mbuf packet dropped" ); }
@@ -104,7 +104,7 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item) }bool -mbuf_extract_item (struct mbuf_set *ms,struct mbuf_item *item,const bool lock) +mbuf_extract_item (struct mbuf_set *ms,struct mbuf_item *item) {bool ret = false;if (ms)
mbuf.h +1 -1
@@ -73,7 +73,7 @@ void mbuf_free_buf (struct mbuf_buffer *mb);void mbuf_add_item (struct mbuf_set *ms,const struct mbuf_item *item); -bool mbuf_extract_item (struct mbuf_set *ms,struct mbuf_item *item,const bool lock); +bool mbuf_extract_item (struct mbuf_set *ms,struct mbuf_item *item);void mbuf_dereference_instance (struct mbuf_set *ms,struct multi_instance *mi);
mroute.c +0 -6
@@ -360,7 +360,6 @@ mroute_helper_init (int ageable_ttl_secs) {struct mroute_helper *mh; ALLOC_OBJ_CLEAR (mh, struct mroute_helper); -/*mutex_init (&mh->mutex);*/ mh->ageable_ttl_secs = ageable_ttl_secs;return mh; }
@@ -398,12 +397,10 @@ mroute_helper_add_iroute (struct mroute_helper *mh, const struct iroute *ir)if (ir->netbits >=0 ) {ASSERT (ir->netbits <MR_HELPER_NET_LEN ); -mroute_helper_lock (mh); ++mh->cache_generation; ++mh->net_len_refcount[ir->netbits];if (mh->net_len_refcount[ir->netbits] ==1 )mroute_helper_regenerate (mh); -mroute_helper_unlock (mh); } }
@@ -413,20 +410,17 @@ mroute_helper_del_iroute (struct mroute_helper *mh, const struct iroute *ir)if (ir->netbits >=0 ) {ASSERT (ir->netbits <MR_HELPER_NET_LEN ); -mroute_helper_lock (mh); ++mh->cache_generation; --mh->net_len_refcount[ir->netbits];ASSERT (mh->net_len_refcount[ir->netbits] >=0 );if (!mh->net_len_refcount[ir->netbits])mroute_helper_regenerate (mh); -mroute_helper_unlock (mh); } }void mroute_helper_free (struct mroute_helper *mh) { -/*mutex_destroy (&mh->mutex);*/ free (mh); }
mroute.h +0 -13
@@ -91,7 +91,6 @@ struct mroute_addr {* Used to help maintain CIDR routing table. */ struct mroute_helper { -/*MUTEX_DEFINE (mutex);*/ unsigned int cache_generation;/* incremented when route added */ int ageable_ttl_secs;/* host route cache entry time-to-live*/ int n_net_len;/* length of net_len array */
@@ -159,18 +158,6 @@ mroute_extract_addr_from_packet (struct mroute_addr *src,return ret; } -static inline void -mroute_helper_lock (struct mroute_helper *mh) -{ -/*mutex_lock (&mh->mutex);*/ -} - -static inline void -mroute_helper_unlock (struct mroute_helper *mh) -{ -/*mutex_unlock (&mh->mutex);*/ -} -static inline bool mroute_addr_equal (const struct mroute_addr *a1,const struct mroute_addr *a2) {
mtcp.c +1 -1
@@ -264,7 +264,7 @@ multi_tcp_process_outgoing_link_ready (struct multi_context *m, struct multi_insASSERT (mi);/* extract from queue */ -if (mbuf_extract_item (mi->tcp_link_out_deferred, &item, true))/* ciphertext IP packet */ +if (mbuf_extract_item (mi->tcp_link_out_deferred, &item))/* ciphertext IP packet */ {dmsg (D_MULTI_TCP ,"MULTI TCP: transmitting previously deferred packet" );
multi.c +1 -5
@@ -1000,8 +1000,6 @@ multi_get_instance_by_virtual_addr (struct multi_context *m,struct mroute_addr tryaddr;int i; -mroute_helper_lock (rh); -/* cycle through each CIDR length */ for (i =0 ; i < rh->n_net_len; ++i) {
@@ -1022,8 +1020,6 @@ multi_get_instance_by_virtual_addr (struct multi_context *m,break ; } } - -mroute_helper_unlock (rh); }#ifdef ENABLE_DEBUG
@@ -2248,7 +2244,7 @@ multi_get_queue (struct mbuf_set *ms) {struct mbuf_item item; -if (mbuf_extract_item (ms, &item, true))/* cleartext IP packet */ +if (mbuf_extract_item (ms, &item))/* cleartext IP packet */ {unsigned int pipv4_flags =PIPV4_PASSTOS ;
openvpn.h +0 -3
@@ -460,9 +460,6 @@ struct context/* true on initial VPN iteration */ bool first_time; -/* used by multi-client code to lock the context */ -/*MUTEX_DEFINE (mutex);*/ -/* context modes */ # define CM_P2P 0/* standalone point-to-point session or client */ # define CM_TOP 1/* top level of a multi-client or point-to-multipoint server */
ssl.c +0 -4
@@ -3907,8 +3907,6 @@ tls_process (struct tls_multi *multi,msg (D_TLS_DEBUG_LOW ,"TLS: tls_process: killed expiring key" ); } -/*mutex_cycle (multi->mutex);*/ - do { update_time ();
@@ -4192,7 +4190,6 @@ tls_process (struct tls_multi *multi, } } } -/*mutex_cycle (multi->mutex);*/ }while (state_change);
@@ -4346,7 +4343,6 @@ tls_multi_process (struct tls_multi *multi,reset_session (multi, session); } } -/*mutex_cycle (multi->mutex);*/ }update_time ();
ssl.h +0 -3
@@ -572,9 +572,6 @@ struct tls_session*/ struct tls_multi { -/* used to coordinate access between main thread and TLS thread */ -/*MUTEX_PTR_DEFINE (mutex);*/ -/* const options and config info */ struct tls_options opt;
Signature · 1 line
1.7.2.2
PATCH 3/3 Clean-up: Removing useless code - hash related functions
In reply to David SommersethRemoved even more function which where practically empty and took away some function arguments which were not used.
--- list.c | 11 ++++------- list.h | 25 ++++--------------------- mtcp.c | 3 --- mudp.c | 3 --- multi.c | 25 +++++++++++-------------- pf.c | 2 +- 6 files changed, 20 insertions(+), 49 deletions(-)
list.c +4 -7
@@ -165,12 +165,12 @@ hash_add (struct hash *hash, const void *key, void *value, bool replace) }void -hash_remove_by_value (struct hash *hash,void *value,bool autolock) +hash_remove_by_value (struct hash *hash,void *value) {struct hash_iterator hi;struct hash_element *he; -hash_iterator_init (hash, &hi, autolock); +hash_iterator_init (hash, &hi);while ((he =hash_iterator_next (&hi))) {if (he->value == value)
@@ -221,7 +221,6 @@ void_ptr_compare_function (const void *key1, const void *key2)void hash_iterator_init_range (struct hash *hash,struct hash_iterator *hi, -bool autolock,int start_bucket,int end_bucket) {
@@ -233,7 +232,6 @@ hash_iterator_init_range (struct hash *hash, hi->hash = hash; hi->elem =NULL ; hi->bucket =NULL ; - hi->autolock = autolock; hi->last =NULL ; hi->bucket_marked = false; hi->bucket_index_start = start_bucket;
@@ -243,10 +241,9 @@ hash_iterator_init_range (struct hash *hash,void hash_iterator_init (struct hash *hash, -struct hash_iterator *hi, -bool autolock) +struct hash_iterator *hi) { -hash_iterator_init_range (hash, hi, autolock,0 , hash->n_buckets); +hash_iterator_init_range (hash, hi,0 , hash->n_buckets); } static inline void
list.h +4 -21
@@ -88,7 +88,7 @@ bool hash_remove_fast (struct hash *hash,const void *key, uint32_t hv); -void hash_remove_by_value (struct hash *hash,void *value,bool autolock); +void hash_remove_by_value (struct hash *hash,void *value);struct hash_iterator {
@@ -98,18 +98,16 @@ struct hash_iteratorstruct hash_element *elem;struct hash_element *last;bool bucket_marked; -bool autolock;int bucket_index_start;int bucket_index_end; };void hash_iterator_init_range (struct hash *hash,struct hash_iterator *hi, -bool autolock,int start_bucket,int end_bucket); -void hash_iterator_init (struct hash *hash,struct hash_iterator *iter,bool autolock); +void hash_iterator_init (struct hash *hash,struct hash_iterator *iter);struct hash_element *hash_iterator_next (struct hash_iterator *hi);void hash_iterator_delete_element (struct hash_iterator *hi);void hash_iterator_free (struct hash_iterator *hi);
@@ -147,21 +145,12 @@ hash_bucket (struct hash *hash, uint32_t hv)return &hash->buckets[hv & hash->mask]; } -static inline void -hash_bucket_lock (struct hash_bucket *bucket) -{ -} - -static inline void -hash_bucket_unlock (struct hash_bucket *bucket) -{ -} -static inline void * -hash_lookup_lock (struct hash *hash,const void *key,uint32_t hv) +hash_lookup (struct hash *hash,const void *key) {void *ret =NULL ;struct hash_element *he; +uint32_t hv =hash_value (hash, key);struct hash_bucket *bucket = &hash->buckets[hv & hash->mask]; he =hash_lookup_fast (hash, bucket, key, hv);
@@ -171,12 +160,6 @@ hash_lookup_lock (struct hash *hash, const void *key, uint32_t hv)return ret; } -static inline void * -hash_lookup (struct hash *hash,const void *key) -{ -return hash_lookup_lock (hash, key,hash_value (hash, key)); -} -/* NOTE: assumes that key is not a duplicate */ static inline void hash_add_fast (struct hash *hash,
mtcp.c +0 -3
@@ -112,7 +112,6 @@ multi_create_instance_tcp (struct multi_context *m)const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv); -hash_bucket_lock (bucket); he =hash_lookup_fast (hash, bucket, &mi->real, hv);if (he)
@@ -128,8 +127,6 @@ multi_create_instance_tcp (struct multi_context *m)hash_add_fast (hash, bucket, &mi->real, hv, mi); mi->did_real_hash = true; - -hash_bucket_unlock (bucket); }#ifdef ENABLE_DEBUG
mudp.c +0 -3
@@ -51,7 +51,6 @@ multi_get_create_instance_udp (struct multi_context *m)const uint32_t hv =hash_value (hash, &real);struct hash_bucket *bucket =hash_bucket (hash, hv); -hash_bucket_lock (bucket); he =hash_lookup_fast (hash, bucket, &real, hv);if (he)
@@ -81,8 +80,6 @@ multi_get_create_instance_udp (struct multi_context *m) } } -hash_bucket_unlock (bucket); -#ifdef ENABLE_DEBUG if (check_debug_level (D_MULTI_DEBUG )) {
multi.c +11 -14
@@ -146,7 +146,7 @@ multi_reap_range (const struct multi_context *m, }dmsg (D_MULTI_DEBUG ,"MULTI: REAP range %d -> %d" , start_bucket, end_bucket); -hash_iterator_init_range (m->vhash, &hi, true, start_bucket, end_bucket); +hash_iterator_init_range (m->vhash, &hi, start_bucket, end_bucket);while ((he =hash_iterator_next (&hi)) !=NULL ) {struct multi_route *r = (struct multi_route *) he->value;
@@ -587,7 +587,7 @@ multi_uninit (struct multi_context *m)struct hash_iterator hi;struct hash_element *he; -hash_iterator_init (m->iter, &hi, true); +hash_iterator_init (m->iter, &hi);while ((he =hash_iterator_next (&hi))) {struct multi_instance *mi = (struct multi_instance *) he->value;
@@ -723,7 +723,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const intstatus_printf (so,"OpenVPN CLIENT LIST" );status_printf (so,"Updated,%s" ,time_string (0 ,0 , false, &gc_top));status_printf (so,"Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since" ); -hash_iterator_init (m->hash, &hi, true); +hash_iterator_init (m->hash, &hi);while ((he =hash_iterator_next (&hi))) {struct gc_arena gc =gc_new ();
@@ -744,7 +744,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const intstatus_printf (so,"ROUTING TABLE" );status_printf (so,"Virtual Address,Common Name,Real Address,Last Ref" ); -hash_iterator_init (m->vhash, &hi, true); +hash_iterator_init (m->vhash, &hi);while ((he =hash_iterator_next (&hi))) {struct gc_arena gc =gc_new ();
@@ -787,7 +787,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const intstatus_printf (so,"TIME%c%s%c%u" , sep,time_string (now,0 , false, &gc_top), sep, (unsigned int )now);status_printf (so,"HEADER%cCLIENT_LIST%cCommon Name%cReal Address%cVirtual Address%cBytes Received%cBytes Sent%cConnected Since%cConnected Since (time_t)" , sep, sep, sep, sep, sep, sep, sep, sep); -hash_iterator_init (m->hash, &hi, true); +hash_iterator_init (m->hash, &hi);while ((he =hash_iterator_next (&hi))) {struct gc_arena gc =gc_new ();
@@ -810,7 +810,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const intstatus_printf (so,"HEADER%cROUTING_TABLE%cVirtual Address%cCommon Name%cReal Address%cLast Ref%cLast Ref (time_t)" , sep, sep, sep, sep, sep, sep); -hash_iterator_init (m->vhash, &hi, true); +hash_iterator_init (m->vhash, &hi);while ((he =hash_iterator_next (&hi))) {struct gc_arena gc =gc_new ();
@@ -849,7 +849,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int#ifdef PACKET_TRUNCATION_CHECK {status_printf (so,"HEADER,ERRORS,Common Name,TUN Read Trunc,TUN Write Trunc,Pre-encrypt Trunc,Post-decrypt Trunc" ); -hash_iterator_init (m->hash, &hi, true); +hash_iterator_init (m->hash, &hi);while ((he =hash_iterator_next (&hi))) {struct gc_arena gc =gc_new ();
@@ -895,8 +895,6 @@ multi_learn_addr (struct multi_context *m,struct multi_route *oldroute =NULL ;struct multi_instance *owner =NULL ; -hash_bucket_lock (bucket); -/* if route currently exists, get the instance which owns it */ he =hash_lookup_fast (m->vhash, bucket, addr, hv);if (he)
@@ -966,7 +964,6 @@ multi_learn_addr (struct multi_context *m,gc_free (&gc); } -hash_bucket_unlock (bucket);return owner; }
@@ -1130,7 +1127,7 @@ multi_delete_dup (struct multi_context *m, struct multi_instance *new_mi)struct hash_element *he;int count =0 ; -hash_iterator_init (m->iter, &hi, true); +hash_iterator_init (m->iter, &hi);while ((he =hash_iterator_next (&hi))) {struct multi_instance *mi = (struct multi_instance *) he->value;
@@ -1776,7 +1773,7 @@ multi_bcast (struct multi_context *m,printf ("BCAST len=%d\n" ,BLEN (buf));#endif mb =mbuf_alloc_buf (buf); -hash_iterator_init (m->iter, &hi, true); +hash_iterator_init (m->iter, &hi);while ((he =hash_iterator_next (&hi))) {
@@ -2470,7 +2467,7 @@ management_callback_kill_by_cn (void *arg, const char *del_cn)struct hash_element *he;int count =0 ; -hash_iterator_init (m->iter, &hi, true); +hash_iterator_init (m->iter, &hi);while ((he =hash_iterator_next (&hi))) {struct multi_instance *mi = (struct multi_instance *) he->value;
@@ -2504,7 +2501,7 @@ management_callback_kill_by_addr (void *arg, const in_addr_t addr, const int por saddr.sa.sin_port =htons (port);if (mroute_extract_openvpn_sockaddr (&maddr, &saddr, true)) { -hash_iterator_init (m->iter, &hi, true); +hash_iterator_init (m->iter, &hi);while ((he =hash_iterator_next (&hi))) {struct multi_instance *mi = (struct multi_instance *) he->value;
pf.c +1 -1
@@ -644,7 +644,7 @@ pf_cn_set_print (const struct pf_cn_set *s, const int lev)if (s->hash_table) { -hash_iterator_init (s->hash_table, &hi, false); +hash_iterator_init (s->hash_table, &hi);while ((he =hash_iterator_next (&hi))) {struct pf_cn *e = (struct pf_cn *)he->value;
Signature · 1 line
1.7.2.2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 56 lines · David Sommerseth
This is a patch series which tries to do some source code clean-up. After having noticed that ./configure --enable-pthread was simply doing *nothing*, as it was forcefully being disabled in
syshead.h, I went through the code and began cleaning up this and some of the related code.As threading is not buildable in the current code base and OpenVPN 3.x most likely will have a brand new design in regards to the threading, it seemed to be better to clean up this code. This is also to remove false presumptions that OpenVPN supports threads.
kind regards,
David Sommerseth
*** BLURB HERE ***
David Sommerseth (3):
Clean-up: Remove pthread and mutex locking code
Clean-up: Remove more dead and inactive code paths
Clean-up: Removing useless code - hash related functionsMakefile.am | 1 - acinclude.m4 | 224 ----------------------------------------------------- buffer.c | 5 - buffer.h | 1 - config-win32.h | 5 - configure.ac | 38 +--------- crypto.c | 3 - error.c | 39 --------- error.h | 17 ---- forward.c | 10 --- init.c | 50 ------------ list.c | 24 +----- list.h | 33 +------- mbuf.c | 16 +---- mbuf.h | 3 +- misc.c | 23 ------ mroute.c | 6 -- mroute.h | 13 --- mtcp.c | 5 +- mudp.c | 3 - multi.c | 32 +++----- multi.h | 2 - openvpn.h | 3 - options.c | 36 --------- options.h | 5 - otime.c | 2 - otime.h | 1 - perf.c | 4 - pf.c | 2 +- plugin.c | 4 - pool.h | 1 - schedule.c | 4 - schedule.h | 8 -- socket.c | 7 --
Quoted 8 lines
ssl.c | 5 - ssl.h | 4 - syshead.h | 18 ---- thread.c | 156 ------------------------------------- thread.h | 235 -------------------------------------------------------- 39 files changed, 26 insertions(+), 1022 deletions(-) delete mode 100644 thread.c delete mode 100644 thread.h
Seems like this patch set was never really added to the tree. It received an ACK in the weekly IRC meeting Sept. 2, 2010. Applied to feat_misc, to be merged into allmerged and beta2.2.
commit 6af422162fbc1c505526157ecf630e37694dbc7b
Author: David Sommerseth <[email protected]...> Date: Sat Aug 28 20:52:19 2010 +0200
Clean-up: Removing useless code - hash related functions
Removed even more function which where practically empty and took away some function arguments which were not used.
commit cc88a2695f4a54e27143efeae62de24fec8e26a1
Author: David Sommerseth <[email protected]...> Date: Sat Aug 28 20:44:07 2010 +0200
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.
commit 7aa6c12a4424d00ea0add0a849f8a5b31a2de6a1
Author: David Sommerseth <[email protected]...> Date: Sat Aug 28 20:14:36 2010 +0200
Clean-up: Remove pthread and mutex locking code
This code was not activated at all, and hard coded as disabled in syshead.h with this code snippet:
/*
* Pthread support is currently experimental (and quite
* unfinished).
*/
#if 1 /* JYFIXME -- if defined, disable pthread */ #undef USE_PTHREAD
#endif
So no matter if --enable-pthread when running ./configure or not, this feature was never enabled in reality. Further, by removing the blocker code above made OpenVPN uncompilable in the current state.
As the threading part needs to be completely rewritten and pthreading will not be supported in OpenVPN 2.x, removing this code seems most reasonable.
In addition, a lot of mutex locking code was also removed, as they were practically NOP functions, due to pthreading being forcefully disabled
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkzgXrUACgkQDC186MBRfrrPhwCeIEuhScmqsTjL2+bnyhTkbO3i 8DcAn3THx0jIiYt7dDv/e4+HFopMae71
=+VXi
-----END PGP SIGNATURE-----