Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jun 2024 02:15:25 GMT
From:      Wen Heping <wen@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 2b4304b08890 - main - www/uwsgi: Fix SOCK_NONBLOCK handling for FreeBSD, copied from NetBSD.
Message-ID:  <202406050215.4552FPqX098547@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by wen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2b4304b08890a2c8c4c765a74c8ed993d2ecb8a4

commit 2b4304b08890a2c8c4c765a74c8ed993d2ecb8a4
Author:     Wen Heping <wen@FreeBSD.org>
AuthorDate: 2024-06-05 02:10:33 +0000
Commit:     Wen Heping <wen@FreeBSD.org>
CommitDate: 2024-06-05 02:15:11 +0000

    www/uwsgi: Fix SOCK_NONBLOCK handling for FreeBSD, copied from NetBSD.
    
    Reported by:    Joerg Sonnenberger <joerg@bec.de>
---
 www/uwsgi/Makefile                                 |  1 +
 www/uwsgi/files/patch-core_socket.c                | 48 ++++++++++++++++++++++
 .../files/patch-plugins_corerouter_corerouter.c    | 12 ++++++
 www/uwsgi/files/patch-proto_base.c                 | 12 ++++++
 4 files changed, 73 insertions(+)

diff --git a/www/uwsgi/Makefile b/www/uwsgi/Makefile
index 403d4f8fe20b..13afa802ef5f 100644
--- a/www/uwsgi/Makefile
+++ b/www/uwsgi/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	uwsgi
 PORTVERSION=	2.0.26
+PORTREVISION=	1
 CATEGORIES=	www python
 PKGNAMESUFFIX=	${PYTHON_PKGNAMESUFFIX}
 
diff --git a/www/uwsgi/files/patch-core_socket.c b/www/uwsgi/files/patch-core_socket.c
new file mode 100644
index 000000000000..323b47236506
--- /dev/null
+++ b/www/uwsgi/files/patch-core_socket.c
@@ -0,0 +1,48 @@
+Fix SOCK_NONBLOCK handling for FreeBSD, copied from NetBSD.
+--- core/socket.c.orig	2024-06-05 01:53:18 UTC
++++ core/socket.c
+@@ -413,7 +413,7 @@ static int connect_to_unix(char *socket_name, int time
+ 		memcpy(uws_addr.sun_path, socket_name, UMIN(strlen(socket_name), 102));
+ 	}
+ 
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 	uwsgi_poll.fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
+ #else
+ 	uwsgi_poll.fd = socket(AF_UNIX, SOCK_STREAM, 0);
+@@ -453,7 +453,7 @@ static int connect_to_tcp(char *socket_name, int port,
+ 		uws_addr.sin_addr.s_addr = inet_addr(socket_name);
+ 	}
+ 
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 	uwsgi_poll.fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
+ #else
+ 	uwsgi_poll.fd = socket(AF_INET, SOCK_STREAM, 0);
+@@ -827,7 +827,7 @@ int timed_connect(struct pollfd *fdpoll, const struct 
+ 	int cnt;
+ 	/* set non-blocking socket */
+ 
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 	// hmm, nothing to do, as we are already non-blocking
+ #else
+ 	int arg = fcntl(fdpoll->fd, F_GETFL, NULL);
+@@ -861,7 +861,7 @@ int timed_connect(struct pollfd *fdpoll, const struct 
+ 	}
+ 
+ 
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 	uwsgi_socket_b(fdpoll->fd);
+ #else
+ 	/* re-set blocking socket */
+@@ -1907,7 +1907,7 @@ int uwsgi_accept(int server_fd) {
+ 	struct sockaddr_un client_src;
+         memset(&client_src, 0, sizeof(struct sockaddr_un));
+         socklen_t client_src_len = 0;
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+         return accept4(server_fd, (struct sockaddr *) &client_src, &client_src_len, SOCK_NONBLOCK);
+ #elif defined(__linux__)
+         int client_fd = accept(server_fd, (struct sockaddr *) &client_src, &client_src_len);
diff --git a/www/uwsgi/files/patch-plugins_corerouter_corerouter.c b/www/uwsgi/files/patch-plugins_corerouter_corerouter.c
new file mode 100644
index 000000000000..91fa5f7a228a
--- /dev/null
+++ b/www/uwsgi/files/patch-plugins_corerouter_corerouter.c
@@ -0,0 +1,12 @@
+Fix SOCK_NONBLOCK handling for FreeBSD, copied from NetBSD.
+--- plugins/corerouter/corerouter.c.orig	2024-06-05 01:59:02 UTC
++++ plugins/corerouter/corerouter.c
+@@ -822,7 +822,7 @@ void uwsgi_corerouter_loop(int id, void *data) {
+ 			while (ugs) {
+ 				if (ugs->gateway == &ushared->gateways[id] && ucr->interesting_fd == ugs->fd) {
+ 					if (!ugs->subscription) {
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) || defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 						new_connection = accept4(ucr->interesting_fd, (struct sockaddr *) &cr_addr, &cr_addr_len, SOCK_NONBLOCK);
+ 						if (new_connection < 0) {
+ 							taken = 1;
diff --git a/www/uwsgi/files/patch-proto_base.c b/www/uwsgi/files/patch-proto_base.c
new file mode 100644
index 000000000000..9b3f6abe60c5
--- /dev/null
+++ b/www/uwsgi/files/patch-proto_base.c
@@ -0,0 +1,12 @@
+Fix SOCK_NONBLOCK handling for FreeBSD, copied from NetBSD.
+--- proto/base.c.orig	2024-06-05 02:00:36 UTC
++++ proto/base.c
+@@ -97,7 +97,7 @@ int uwsgi_proto_base_accept(struct wsgi_request *wsgi_
+ int uwsgi_proto_base_accept(struct wsgi_request *wsgi_req, int fd) {
+ 
+ 	wsgi_req->c_len = sizeof(struct sockaddr_un);
+-#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
++#if (defined(__linux__) ||defined(__FreeBSD__)) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
+ 	return accept4(fd, (struct sockaddr *) &wsgi_req->client_addr, (socklen_t *) & wsgi_req->c_len, SOCK_NONBLOCK);
+ #elif defined(__linux__)
+ 	int client_fd = accept(fd, (struct sockaddr *) &wsgi_req->client_addr, (socklen_t *) & wsgi_req->c_len);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202406050215.4552FPqX098547>