Commit 9a0697cc authored by Jens Georg's avatar Jens Georg
Browse files

Fallback to Linux CM if available

If one of the other dynamic context managers was not available, we would
fall-back to the static CM.

This patch changes this so we fall-back to the dynamic Linux CM instead
if it's available.
parent 35bf8d2f
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -74,6 +74,22 @@ if test "x$with_context_manager" = "xnone"; then
        esac
fi

AC_CHECK_HEADERS([sys/socket.h linux/rtnetlink.h],
                [ HAVE_NETLINK=yes ],
                [ HAVE_NETLINK=no ],
                [ #ifdef HAVE_SYS_SOCKET_H
                  #include <sys/socket.h>
                  #endif
                ])
AM_CONDITIONAL([HAVE_NETLINK], [test "x$HAVE_NETLINK" = "xyes"])
AC_SUBST(HAVE_NETLINK)

AC_CHECK_HEADERS([linux/wireless.h], [], [],
                [ #ifdef HAVE_SYS_SOCKET_H
                  #include <sys/socket.h>
                  #endif
                ])

AC_MSG_CHECKING([Context Manager backend to use])
AC_MSG_RESULT([${with_context_manager}])

@@ -90,27 +106,11 @@ if test "x$with_context_manager" = "xconnman"; then
fi

USE_NETLINK=no
if test "x$with_context_manager" = "xlinux"; then
       dnl check for netlink (Linux)
       AC_CHECK_HEADERS([sys/socket.h linux/rtnetlink.h],
                        [ USE_NETLINK=yes ],
                        [ USE_NETLINK=no ],
                        [ #ifdef HAVE_SYS_SOCKET_H
                          #include <sys/socket.h>
                          #endif
                        ])
       if test "x$USE_NETLINK" = "xno"
       then
               AC_MSG_NOTICE([No rtnetlink found, falling back to unix context
                              manager])
       else
               AC_CHECK_HEADERS([linux/wireless.h], [], [],
                                [ #ifdef HAVE_SYS_SOCKET_H
                                  #include <sys/socket.h>
                                  #endif
                                ])
       fi
fi
AS_IF([test "x$with_context_manager" = "xlinux"],
      [AS_IF([test "x$HAVE_NETLINK" = "xno"],
             [AC_MSG_NOTICE([No rtnetlink found, falling back to static context manager])],
             [USE_NETLINK=yes])
      ],[])

AM_CONDITIONAL(USE_NETLINK, test "x$USE_NETLINK" = "xyes")
AC_SUBST(USE_NETLINK)
+6 −3
Original line number Diff line number Diff line
@@ -14,11 +14,14 @@ CONTEXT_MANAGER_CFLAGS = -DUSE_CONNMAN
endif
endif

if USE_NETLINK
NETLINK_CFLAGS = -DUSE_NETLINK
if HAVE_NETLINK
CONTEXT_MANAGER_IMPL += \
	gupnp-linux-context-manager.c \
	gupnp-linux-context-manager.h
endif

if USE_NETLINK
NETLINK_CFLAGS = -DUSE_NETLINK
else
NETLINK_CFLAGS =
endif
+11 −4
Original line number Diff line number Diff line
@@ -313,6 +313,10 @@ gupnp_context_manager_new (GMainContext *main_context,
    return gupnp_context_manager_create (port);
}

#ifdef HAVE_LINUX_RTNETLINK_H
#include "gupnp-linux-context-manager.h"
#endif

/**
 * gupnp_context_manager_create:
 * @port: Port to create contexts for, or 0 if you don't care what port is used.
@@ -345,14 +349,17 @@ gupnp_context_manager_create (guint port)

       if (gupnp_connman_manager_is_available ())
                impl_type = GUPNP_TYPE_CONNMAN_MANAGER;

#elif USE_NETLINK
#include "gupnp-linux-context-manager.h"
        impl_type = GUPNP_TYPE_LINUX_CONTEXT_MANAGER;
#endif

        if (impl_type == G_TYPE_INVALID)
            /* Either user requested us to use the Linux CM explicitly or we
             * are using one of the DBus managers but it's not available, so we
             * fall-back to it. */
#if defined (USE_NETLINK) || defined (HAVE_LINUX_RTNETLINK_H)
                impl_type = GUPNP_TYPE_LINUX_CONTEXT_MANAGER;
#else
                impl_type = GUPNP_TYPE_UNIX_CONTEXT_MANAGER;
#endif

        impl = g_object_new (impl_type,
                             "port", port,