Disable the communication socket when UI is disabled
The communication socket is added to support the UI, when UI is not built, also disable the socket. Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
99ae256d02
commit
4342acd8d7
11
configure.ac
11
configure.ac
|
@ -41,10 +41,13 @@ AC_C_INLINE
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
|
|
||||||
AC_ARG_WITH([irqbalance-ui],
|
AC_ARG_WITH([irqbalance-ui],
|
||||||
[AC_HELP_STRING([--without-irqbalance-ui],
|
[AS_HELP_STRING([--without-irqbalance-ui],
|
||||||
[Dont build the irqbalance ui component])],
|
[Dont build the irqbalance ui component])],
|
||||||
[with_irqbalanceui=$withval], [with_irqbalanceui=yes])
|
[with_irqbalanceui=$withval], [with_irqbalanceui=yes])
|
||||||
|
AS_IF(
|
||||||
|
[test "x$with_irqbalanceui" = "xyes"], [
|
||||||
|
AC_DEFINE([HAVE_IRQBALANCEUI], 1, [Build irqbalance ui component.])
|
||||||
|
])
|
||||||
AM_CONDITIONAL([IRQBALANCEUI], [test x$with_irqbalanceui = xyes])
|
AM_CONDITIONAL([IRQBALANCEUI], [test x$with_irqbalanceui = xyes])
|
||||||
|
|
||||||
AC_ARG_WITH([systemd],
|
AC_ARG_WITH([systemd],
|
||||||
|
|
|
@ -39,7 +39,9 @@
|
||||||
|
|
||||||
#include "irqbalance.h"
|
#include "irqbalance.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
extern char *banned_cpumask_from_ui;
|
extern char *banned_cpumask_from_ui;
|
||||||
|
#endif
|
||||||
extern char *cpu_ban_string;
|
extern char *cpu_ban_string;
|
||||||
|
|
||||||
GList *cpus;
|
GList *cpus;
|
||||||
|
@ -113,12 +115,14 @@ static void setup_banned_cpus(void)
|
||||||
cpumask_t isolated_cpus;
|
cpumask_t isolated_cpus;
|
||||||
char *env = NULL;
|
char *env = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
/* A manually specified cpumask overrides auto-detection. */
|
/* A manually specified cpumask overrides auto-detection. */
|
||||||
if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) {
|
if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) {
|
||||||
cpulist_parse(banned_cpumask_from_ui,
|
cpulist_parse(banned_cpumask_from_ui,
|
||||||
strlen(banned_cpumask_from_ui), banned_cpus);
|
strlen(banned_cpumask_from_ui), banned_cpus);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notes:
|
* Notes:
|
||||||
|
|
23
irqbalance.c
23
irqbalance.c
|
@ -31,22 +31,21 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBCAP_NG
|
#ifdef HAVE_LIBCAP_NG
|
||||||
#include <cap-ng.h>
|
#include <cap-ng.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
#include "irqbalance.h"
|
#include "irqbalance.h"
|
||||||
|
|
||||||
volatile int keep_going = 1;
|
volatile int keep_going = 1;
|
||||||
int socket_fd;
|
|
||||||
char socket_name[64];
|
|
||||||
int one_shot_mode;
|
int one_shot_mode;
|
||||||
int debug_mode;
|
int debug_mode;
|
||||||
int foreground_mode;
|
int foreground_mode;
|
||||||
|
@ -67,9 +66,14 @@ int last_interval;
|
||||||
GMainLoop *main_loop;
|
GMainLoop *main_loop;
|
||||||
|
|
||||||
char *cpu_ban_string = NULL;
|
char *cpu_ban_string = NULL;
|
||||||
char *banned_cpumask_from_ui = NULL;
|
|
||||||
unsigned long migrate_ratio = 0;
|
unsigned long migrate_ratio = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
|
int socket_fd;
|
||||||
|
char socket_name[64];
|
||||||
|
char *banned_cpumask_from_ui = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void sleep_approx(int seconds)
|
static void sleep_approx(int seconds)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
@ -405,6 +409,7 @@ void get_object_stat(struct topo_obj *object, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused)))
|
gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused)))
|
||||||
{
|
{
|
||||||
char buff[500];
|
char buff[500];
|
||||||
|
@ -585,6 +590,7 @@ int init_socket()
|
||||||
g_unix_fd_add(socket_fd, G_IO_IN, sock_handle, NULL);
|
g_unix_fd_add(socket_fd, G_IO_IN, sock_handle, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -688,10 +694,12 @@ int main(int argc, char** argv)
|
||||||
parse_proc_interrupts();
|
parse_proc_interrupts();
|
||||||
parse_proc_stat();
|
parse_proc_stat();
|
||||||
|
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
if (init_socket()) {
|
if (init_socket()) {
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
main_loop = g_main_loop_new(NULL, FALSE);
|
main_loop = g_main_loop_new(NULL, FALSE);
|
||||||
last_interval = sleep_interval;
|
last_interval = sleep_interval;
|
||||||
g_timeout_add_seconds(sleep_interval, scan, NULL);
|
g_timeout_add_seconds(sleep_interval, scan, NULL);
|
||||||
|
@ -707,11 +715,12 @@ out:
|
||||||
/* Remove pidfile */
|
/* Remove pidfile */
|
||||||
if (!foreground_mode && pidfile)
|
if (!foreground_mode && pidfile)
|
||||||
unlink(pidfile);
|
unlink(pidfile);
|
||||||
|
#ifdef HAVE_IRQBALANCEUI
|
||||||
/* Remove socket */
|
/* Remove socket */
|
||||||
if (socket_fd > 0)
|
if (socket_fd > 0)
|
||||||
close(socket_fd);
|
close(socket_fd);
|
||||||
if (socket_name[0])
|
if (socket_name[0])
|
||||||
unlink(socket_name);
|
unlink(socket_name);
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue