git: 09355a84834e - main - www/freenginx-devel: enable third-party echo module

From: Sergey A. Osokin <osa_at_FreeBSD.org>
Date: Sun, 02 Nov 2025 02:12:28 UTC
The branch main has been updated by osa:

URL: https://cgit.FreeBSD.org/ports/commit/?id=09355a84834e733a48042f825a8c760fd9c3c477

commit 09355a84834e733a48042f825a8c760fd9c3c477
Author:     Sergey A. Osokin <osa@FreeBSD.org>
AuthorDate: 2025-11-02 02:11:07 +0000
Commit:     Sergey A. Osokin <osa@FreeBSD.org>
CommitDate: 2025-11-02 02:12:24 +0000

    www/freenginx-devel: enable third-party echo module
    
    Bump PORTREVISION.
    
    Sponsored by:   tipi.work
---
 www/freenginx-devel/Makefile                       |  2 +-
 www/freenginx-devel/Makefile.extmod                |  1 +
 www/freenginx-devel/Makefile.ignore                |  4 ----
 .../files/extra-patch-ngx_http_echo_timer.c        | 27 ++++++++++++++--------
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/www/freenginx-devel/Makefile b/www/freenginx-devel/Makefile
index feb424a242c1..7829a73dd5e3 100644
--- a/www/freenginx-devel/Makefile
+++ b/www/freenginx-devel/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	freenginx
 PORTVERSION=	${NGINX_VERSION}
 .include "version.mk"
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	www
 MASTER_SITES=	https://freenginx.org/download/ \
 		LOCAL/osa
diff --git a/www/freenginx-devel/Makefile.extmod b/www/freenginx-devel/Makefile.extmod
index 29647aca5692..b2c405f920b5 100644
--- a/www/freenginx-devel/Makefile.extmod
+++ b/www/freenginx-devel/Makefile.extmod
@@ -32,6 +32,7 @@ CACHE_PURGE_VARS=	DSO_EXTMODS+=cache_purge
 
 ECHO_GH_TUPLE=		openresty:echo-nginx-module:4eeda3c:echo
 ECHO_VARS=		DSO_EXTMODS+=echo
+ECHO_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_http_echo_timer.c
 
 DRIZZLE_LIB_DEPENDS=	libdrizzle.so:databases/libdrizzle
 DRIZZLE_CONFIGURE_ENV=	LIBDRIZZLE_INC=${LOCALBASE}/include \
diff --git a/www/freenginx-devel/Makefile.ignore b/www/freenginx-devel/Makefile.ignore
index 7ee53e947393..5197fc544c2d 100644
--- a/www/freenginx-devel/Makefile.ignore
+++ b/www/freenginx-devel/Makefile.ignore
@@ -1,7 +1,3 @@
-.if ${PORT_OPTIONS:MECHO}
-IGNORE=		echo module: patching is required
-.endif
-
 .if ${PORT_OPTIONS:MHTTP_UPLOAD}
 IGNORE=		upload module: patching is required
 .endif
diff --git a/www/freenginx-devel/files/extra-patch-ngx_http_echo_timer.c b/www/freenginx-devel/files/extra-patch-ngx_http_echo_timer.c
index 572581a0f1b6..6c06a58e225e 100644
--- a/www/freenginx-devel/files/extra-patch-ngx_http_echo_timer.c
+++ b/www/freenginx-devel/files/extra-patch-ngx_http_echo_timer.c
@@ -1,14 +1,23 @@
---- ../echo-nginx-module-4eeda3c/src/ngx_http_echo_timer.c.orig	2025-10-21 16:47:54.085370000 -0400
-+++ ../echo-nginx-module-4eeda3c/src/ngx_http_echo_timer.c	2025-10-21 16:50:55.878182000 -0400
-@@ -32,9 +32,8 @@
-         ngx_http_set_ctx(r, ctx, ngx_http_echo_module);
+--- ../echo-nginx-module-4eeda3c/src/ngx_http_echo_timer.c.orig	2024-08-17 08:36:17.000000000 -0400
++++ ../echo-nginx-module-4eeda3c/src/ngx_http_echo_timer.c	2025-11-01 22:07:05.628904000 -0400
+@@ -33,8 +33,20 @@
      }
  
--    if (ctx->timer_begin.sec == 0) {
--        ctx->timer_begin.sec  = r->start_sec;
--        ctx->timer_begin.msec = (ngx_msec_t) r->start_msec;
-+    if (ctx->timer_begin.time == 0) {
-+        ctx->timer_begin.time  = r->start_time;
+     if (ctx->timer_begin.sec == 0) {
++#if defined freenginx
++        tp = ngx_timeofday();
++
++        tp->sec -= (ngx_current_msec - r->start_time) / 1000;
++        tp->msec -= (ngx_current_msec - r->start_time) % 1000;
++        if (tp->msec > NGX_MAX_INT_T_VALUE) {
++            tp->msec += 1000;
++            tp->sec -= 1;
++        }
++        ctx->timer_begin = *tp;
++#else
+         ctx->timer_begin.sec  = r->start_sec;
+         ctx->timer_begin.msec = (ngx_msec_t) r->start_msec;
++#endif
      }
  
      /* force the ngx timer to update */