Blame SOURCES/irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch

7fcf55
From 4342acd8d7862e862e0b661135b10671ffeac119 Mon Sep 17 00:00:00 2001
7fcf55
From: Kairui Song <kasong@redhat.com>
7fcf55
Date: Thu, 22 Jul 2021 03:05:59 +0800
7fcf55
Subject: [PATCH] Disable the communication socket when UI is disabled
7fcf55
7fcf55
The communication socket is added to support the UI, when UI is not
7fcf55
built, also disable the socket.
7fcf55
7fcf55
Signed-off-by: Kairui Song <kasong@redhat.com>
7fcf55
---
7fcf55
 configure.ac | 11 +++++++----
7fcf55
 cputree.c    |  4 ++++
7fcf55
 irqbalance.c | 23 ++++++++++++++++-------
7fcf55
 3 files changed, 27 insertions(+), 11 deletions(-)
7fcf55
7fcf55
diff --git a/configure.ac b/configure.ac
7fcf55
index 92a5113..c45b9ce 100644
7fcf55
--- a/configure.ac
7fcf55
+++ b/configure.ac
7fcf55
@@ -41,10 +41,13 @@ AC_C_INLINE
7fcf55
 AM_PROG_CC_C_O
7fcf55
 
7fcf55
 AC_ARG_WITH([irqbalance-ui],
7fcf55
-	[AC_HELP_STRING([--without-irqbalance-ui],
7fcf55
-			[Dont build the irqbalance ui component])],
7fcf55
-			[with_irqbalanceui=$withval], [with_irqbalanceui=yes])
7fcf55
-
7fcf55
+  [AS_HELP_STRING([--without-irqbalance-ui],
7fcf55
+    [Dont build the irqbalance ui component])],
7fcf55
+    [with_irqbalanceui=$withval], [with_irqbalanceui=yes])
7fcf55
+AS_IF(
7fcf55
+  [test "x$with_irqbalanceui" = "xyes"], [
7fcf55
+    AC_DEFINE([HAVE_IRQBALANCEUI], 1, [Build irqbalance ui component.])
7fcf55
+])
7fcf55
 AM_CONDITIONAL([IRQBALANCEUI], [test x$with_irqbalanceui = xyes])
7fcf55
 
7fcf55
 AC_ARG_WITH([systemd],
7fcf55
diff --git a/cputree.c b/cputree.c
7fcf55
index e4695f2..b716a8f 100644
7fcf55
--- a/cputree.c
7fcf55
+++ b/cputree.c
7fcf55
@@ -39,7 +39,9 @@
7fcf55
 
7fcf55
 #include "irqbalance.h"
7fcf55
 
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
 extern char *banned_cpumask_from_ui;
7fcf55
+#endif
7fcf55
 extern char *cpu_ban_string;
7fcf55
 
7fcf55
 GList *cpus;
7fcf55
@@ -113,12 +115,14 @@ static void setup_banned_cpus(void)
7fcf55
 	cpumask_t isolated_cpus;
7fcf55
 	char *env = NULL;
7fcf55
 
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
 	/* A manually specified cpumask overrides auto-detection. */
7fcf55
 	if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) {
7fcf55
 		cpulist_parse(banned_cpumask_from_ui,
7fcf55
 			strlen(banned_cpumask_from_ui), banned_cpus);
7fcf55
 		goto out;
7fcf55
 	}
7fcf55
+#endif
7fcf55
 
7fcf55
 	/*
7fcf55
 	 * Notes:
7fcf55
diff --git a/irqbalance.c b/irqbalance.c
7fcf55
index 3f94847..07a245f 100644
7fcf55
--- a/irqbalance.c
7fcf55
+++ b/irqbalance.c
7fcf55
@@ -31,22 +31,21 @@
7fcf55
 #include <time.h>
7fcf55
 #include <sys/types.h>
7fcf55
 #include <sys/stat.h>
7fcf55
-#include <sys/socket.h>
7fcf55
-#include <sys/un.h>
7fcf55
 #include <fcntl.h>
7fcf55
 #include <inttypes.h>
7fcf55
 #ifdef HAVE_GETOPT_LONG 
7fcf55
 #include <getopt.h>
7fcf55
 #endif
7fcf55
-
7fcf55
 #ifdef HAVE_LIBCAP_NG
7fcf55
 #include <cap-ng.h>
7fcf55
 #endif
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
+#include <sys/un.h>
7fcf55
+#include <sys/socket.h>
7fcf55
+#endif
7fcf55
 #include "irqbalance.h"
7fcf55
 
7fcf55
 volatile int keep_going = 1;
7fcf55
-int socket_fd;
7fcf55
-char socket_name[64];
7fcf55
 int one_shot_mode;
7fcf55
 int debug_mode;
7fcf55
 int foreground_mode;
7fcf55
@@ -67,9 +66,14 @@ int last_interval;
7fcf55
 GMainLoop *main_loop;
7fcf55
 
7fcf55
 char *cpu_ban_string = NULL;
7fcf55
-char *banned_cpumask_from_ui = NULL;
7fcf55
 unsigned long migrate_ratio = 0;
7fcf55
 
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
+int socket_fd;
7fcf55
+char socket_name[64];
7fcf55
+char *banned_cpumask_from_ui = NULL;
7fcf55
+#endif
7fcf55
+
7fcf55
 static void sleep_approx(int seconds)
7fcf55
 {
7fcf55
 	struct timespec ts;
7fcf55
@@ -405,6 +409,7 @@ void get_object_stat(struct topo_obj *object, void *data)
7fcf55
 	}
7fcf55
 }
7fcf55
 
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
 gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused)))
7fcf55
 {
7fcf55
 	char buff[500];
7fcf55
@@ -585,6 +590,7 @@ int init_socket()
7fcf55
 	g_unix_fd_add(socket_fd, G_IO_IN, sock_handle, NULL);
7fcf55
 	return 0;
7fcf55
 }
7fcf55
+#endif
7fcf55
 
7fcf55
 int main(int argc, char** argv)
7fcf55
 {
7fcf55
@@ -688,10 +694,12 @@ int main(int argc, char** argv)
7fcf55
 	parse_proc_interrupts();
7fcf55
 	parse_proc_stat();
7fcf55
 
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
 	if (init_socket()) {
7fcf55
 		ret = EXIT_FAILURE;
7fcf55
 		goto out;
7fcf55
 	}
7fcf55
+#endif
7fcf55
 	main_loop = g_main_loop_new(NULL, FALSE);
7fcf55
 	last_interval = sleep_interval;
7fcf55
 	g_timeout_add_seconds(sleep_interval, scan, NULL);
7fcf55
@@ -707,11 +715,12 @@ out:
7fcf55
 	/* Remove pidfile */
7fcf55
 	if (!foreground_mode && pidfile)
7fcf55
 		unlink(pidfile);
7fcf55
+#ifdef HAVE_IRQBALANCEUI
7fcf55
 	/* Remove socket */
7fcf55
 	if (socket_fd > 0)
7fcf55
 		close(socket_fd);
7fcf55
 	if (socket_name[0])
7fcf55
 		unlink(socket_name);
7fcf55
-
7fcf55
+#endif
7fcf55
 	return ret;
7fcf55
 }
7fcf55
-- 
7fcf55
2.31.1
7fcf55