Hi,

On Fri, Jun 24, 2022 at 5:10 AM Antonio Quartulli <a...@unstable.cc> wrote:

> GetOverlappedResultEx is not available on ming32 therefore we must
> provide some compat layer before being able to use this function.
>

I suppose "mingw32" here refers to I mingw-w64 for 32 bit (i686) target.

This symbol has been exported in kernel32.lib since version 7.0 release of
mingw-w64 (~ 2019). Current release is version 10. Do we need to support
older versions given that mingw build is now used only for development by a
few of us?

I use debian which probably is the slowest to get new versions -- bullseye
has version 8 (gcc version 10), on buster I use unstable which gives
version 8. Ubuntu 20.04 has version 7, 22.04 has version 8.

Even if we must support 6.0 and older, let's not unconditionally use the
compat layer proposed here.


>
> Signed-off-by: Antonio Quartulli <a...@unstable.cc>
> Signed-off-by: Lev Stipakov <l...@openvpn.net>
> ---
>  src/compat/Makefile.am                        |  3 +-
>  src/compat/compat-dco_get_overlapped_result.c | 46 +++++++++++++++++++
>  src/compat/compat.h                           |  8 ++++
>  src/compat/compat.vcxproj                     |  1 +
>  src/compat/compat.vcxproj.filters             |  3 ++
>  5 files changed, 60 insertions(+), 1 deletion(-)
>  create mode 100644 src/compat/compat-dco_get_overlapped_result.c
>
> diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am
> index 6eb991dc..6dba08aa 100644
> --- a/src/compat/Makefile.am
> +++ b/src/compat/Makefile.am
> @@ -28,4 +28,5 @@ libcompat_la_SOURCES = \
>         compat-gettimeofday.c \
>         compat-daemon.c \
>         compat-strsep.c \
> -       compat-versionhelpers.h
> +       compat-versionhelpers.h \
> +       compat-dco_get_overlapped_result.c
> diff --git a/src/compat/compat-dco_get_overlapped_result.c
> b/src/compat/compat-dco_get_overlapped_result.c
> new file mode 100644
> index 00000000..e14ce976
> --- /dev/null
> +++ b/src/compat/compat-dco_get_overlapped_result.c
> @@ -0,0 +1,46 @@
> +/*
> + *  OpenVPN -- An application to securely tunnel IP networks
> + *             over a single UDP port, with support for SSL/TLS-based
> + *             session authentication and key exchange,
> + *             packet encryption, packet authentication, and
> + *             packet compression.
> + *
> + *  Copyright (C) 2021-2022 Lev Stipakov <l...@openvpn.net>
> + *  Copyright (C) 2021-2022 OpenVPN Inc <sa...@openvpn.net>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2
> + *  as published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program (see the file COPYING included with this
> + *  distribution); if not, write to the Free Software Foundation, Inc.,
> + *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#elif defined(_MSC_VER)
> +#include "config-msvc.h"
> +#endif
> +
> +#include "compat.h"
> +
> +#if defined(__MINGW32__) && !defined(__MINGW64__)
> +BOOL
> +dco_get_overlapped_result(HANDLE handle, OVERLAPPED *ov, DWORD
> *transferred,
> +                          DWORD delay_millisec, BOOL unused)
> +{
> +    BOOL res = GetOverlappedResult(handle, ov, transferred, FALSE);
> +    if ((res == 0) && (GetLastError() == ERROR_IO_INCOMPLETE))
> +    {
> +        Sleep(delay_millisec);


While this may be ok assuming it's not inside any performance critical
loops, no need to force this on newer versions of mingw-w64.

Alternatively, we could use AC_CHECK_FUNC to make this conditional or find
the symbol GetOverlappedResultEx at runtime. But, imo, we do not need any
of this as supporting mingw-w64 version 7+ should be enough.

Regards,

Selva
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to