git: 12a219fc28ea - main - sysutils/conmon: fix socket buffering for console i/o

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Sat, 22 Jul 2023 12:37:59 UTC
The branch main has been updated by dfr:

URL: https://cgit.FreeBSD.org/ports/commit/?id=12a219fc28ea2cb5c9ee67abc222646a424cc9bb

commit 12a219fc28ea2cb5c9ee67abc222646a424cc9bb
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-07-07 12:07:37 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-07-22 12:36:46 +0000

    sysutils/conmon: fix socket buffering for console i/o
    
    Approved by: lwhsu
---
 sysutils/conmon/Makefile                     |  2 +-
 sysutils/conmon/files/patch-src_conn__sock.c | 44 ++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/sysutils/conmon/Makefile b/sysutils/conmon/Makefile
index 5114574ede56..ebd4733aa269 100644
--- a/sysutils/conmon/Makefile
+++ b/sysutils/conmon/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	conmon
 DISTVERSIONPREFIX=	v
 DISTVERSION=	2.1.7
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	sysutils
 
 MAINTAINER=	dfr@FreeBSD.org
diff --git a/sysutils/conmon/files/patch-src_conn__sock.c b/sysutils/conmon/files/patch-src_conn__sock.c
new file mode 100644
index 000000000000..f033e0fb88dd
--- /dev/null
+++ b/sysutils/conmon/files/patch-src_conn__sock.c
@@ -0,0 +1,44 @@
+--- src/conn_sock.c.orig	2023-07-07 12:04:59 UTC
++++ src/conn_sock.c
+@@ -110,6 +110,14 @@ static void bind_relative_to_dir(int dir_fd, int sock_
+ 	if (bind(sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+ 		pexit("Failed to bind to console-socket");
+ }
++
++static void set_socket_buffers(G_GNUC_UNUSED int fd)
++{
++	/*
++	 * Nothing needed here for Linux - the default buffer sizes for unix domain sockets are large enough.
++	 */
++}
++
+ #endif
+ 
+ #ifdef __FreeBSD__
+@@ -135,6 +143,18 @@ static void bind_relative_to_dir(int dir_fd, int sock_
+ 	if (fchmodat(dir_fd, addr.sun_path, 0700, AT_SYMLINK_NOFOLLOW))
+ 		pexit("Failed to change console-socket permissions");
+ }
++
++static void set_socket_buffers(int fd)
++{
++	int sz = CONN_SOCK_BUF_SIZE;
++	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz))) {
++		nwarn("failed to set socket receive buffer size");
++	}
++	if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sz, sizeof(sz))) {
++		nwarn("failed to set socket send buffer size");
++	}
++}
++
+ #endif
+ 
+ static char *setup_socket(int *fd, const char *path)
+@@ -357,6 +377,7 @@ static gboolean attach_cb(int fd, G_GNUC_UNUSED GIOCon
+ 			nwarn("Failed to accept client connection on attach socket");
+ 	} else {
+ 		struct remote_sock_s *remote_sock;
++		set_socket_buffers(new_fd);
+ 		if (srcsock->dest->readers == NULL) {
+ 			srcsock->dest->readers = g_ptr_array_new_with_free_func(free);
+ 		}