Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld,
I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1039?usp=email to review the following change. Change subject: Multi-socket: local_list clean-up ...................................................................... Multi-socket: local_list clean-up Optimize the current local_list implementation by replacing the static array with a resizable one, as the static allocation serves no real purpose, particularly on the client side. Github: #682 Change-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463 Signed-off-by: Gianmarco De Gregori <gianma...@mandelbit.com> --- M src/openvpn/options.c M src/openvpn/options.h 2 files changed, 14 insertions(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/39/1039/1 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 6ea01d4..70337b1 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2212,12 +2212,20 @@ struct local_list *l = alloc_local_list_if_undef(ce, gc); struct local_entry *e; - if (l->len >= CONNECTION_LIST_SIZE) + if (l->len >= l->capacity) { - msg(msglevel, "Maximum number of 'local' options (%d) exceeded", - CONNECTION_LIST_SIZE); + const int new_cap = l->capacity + 1; + const size_t elem_size = sizeof(*l->array); - return NULL; + struct local_entry **new_array = gc_realloc(l->array, new_cap * elem_size, gc); + if (!new_array) + { + msg(msglevel, "Unable to process more local options: out of memory. Number of entries = %d", l->len); + return NULL; + } + + l->array = new_array; + l->capacity = new_cap; } ALLOC_OBJ_CLEAR_GC(e, struct local_entry, gc); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index b28ad58..46ec32b 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -188,8 +188,9 @@ struct local_list { + int capacity; int len; - struct local_entry *array[CONNECTION_LIST_SIZE]; + struct local_entry **array; }; struct connection_list -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1039?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463 Gerrit-Change-Number: 1039 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan <gianma...@mandelbit.com> Gerrit-Reviewer: flichtenheld <fr...@lichtenheld.com> Gerrit-Reviewer: plaisthos <arne-open...@rfc2549.org> Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net> Gerrit-Attention: plaisthos <arne-open...@rfc2549.org> Gerrit-Attention: flichtenheld <fr...@lichtenheld.com> Gerrit-MessageType: newchange
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel