From b4aa5bcc4c79bccabc3d6aa78eace33582c39f97 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Sat, 2 Nov 2013 22:06:20 -0700 Subject: [PATCH] TIVI-1933, TIVI-1957: Enable socket activation support. Change-Id: I9e79031a01a74dac03b0aa18405417f983e91244 Signed-off-by: Ossama Othman --- configure.ac | 2 +- packaging/settingsd.changes | 24 ++++++++++++++++++++++++ packaging/settingsd.service | 6 +----- packaging/settingsd.socket | 6 ++---- packaging/settingsd.spec | 10 ++++++---- src/daemon.cpp | 25 +++++++++++++++++++------ 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 2c7599b..59a97b6 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ]) -AC_INIT([settingsd], [0.1], [ossama.othman@intel.com]) +AC_INIT([settingsd], [0.2], [ossama.othman@intel.com]) AM_INIT_AUTOMAKE([1.11.1 foreign -Wall -Werror silent-rules]) LT_INIT([disable-static dlopen]) diff --git a/packaging/settingsd.changes b/packaging/settingsd.changes index 37b6d10..4203ac9 100644 --- a/packaging/settingsd.changes +++ b/packaging/settingsd.changes @@ -1,3 +1,27 @@ +* Wed Nov 06 2013 Ossama Othman accepted/tizen/20131003.220350@f0010ff +- TIVI-1933, TIVI-1957: Enable socket activation support. +- [dbus_connection] Improved exception safety. +- Fixed libwebsocket_context race condition. +- [connman] Share a single connection to D-Bus system bus. +- Make git ignore Doxygen generated documentation. +- Removed obsolete 'todo' comment. +- [smart_ptr] Don't reinvent the wheel. Leverage std::unique_ptr<>. +- Removed unused reverse_lock.hpp header. +- Changed the event JSON format to be more generic. +- Refactored connman signal callback to generic D-Bus signal callback. +- Added D-Bus introspection XML for settingsd connman Agent. +- Effectively make connman_manager a singleton. +- Implemented event reporting to settings daemon clients. +- [smart_ptr] Corrected documentation: s/typename/class/ +- Removed unnecessary include directives. +- Add new line at end of exception log message. +- Do not continue with initialization if no plugins are found. +- [manager] Return immediately on empty request. +- Added missing return value in assignment operator. +- Do not return in functions with void return types. +- Updated autoconf-archive boost and C++11 macros to later version. +- Enable Doxygen doc generation. + * Thu Oct 03 2013 Ossama Othman 5c4d6b7 - TIVI-1924: Initial commit of IVI settings daemon. diff --git a/packaging/settingsd.service b/packaging/settingsd.service index 8fffad2..435b68d 100644 --- a/packaging/settingsd.service +++ b/packaging/settingsd.service @@ -1,11 +1,7 @@ [Unit] Description=Tizen IVI Settings Daemon -Requires=connman.service -After=connman.service,weston.target +After=connman.service [Service] ExecStart=/usr/bin/settingsd Restart=on-failure - -[Install] -WantedBy=weston.target diff --git a/packaging/settingsd.socket b/packaging/settingsd.socket index 8d07b26..4ad1468 100644 --- a/packaging/settingsd.socket +++ b/packaging/settingsd.socket @@ -4,7 +4,5 @@ Description=Tizen IVI Settings Daemon Activation Socket [Socket] ListenStream=127.0.0.1:16000 -# Only allow connections through the loopback network interface. -BindToDevice=lo - -ReusePort=true +[Install] +WantedBy=sockets.target diff --git a/packaging/settingsd.spec b/packaging/settingsd.spec index c3f0c32..90fb6b2 100644 --- a/packaging/settingsd.spec +++ b/packaging/settingsd.spec @@ -1,6 +1,6 @@ Name: settingsd Summary: Tizen IVI Settings Daemon -Version: 0.1 +Version: 0.2 Release: 1 Group: Application Framework/Settings License: LGPL-2.1 @@ -63,9 +63,10 @@ make %{?_smp_mflags} rm %{buildroot}%{pkglibdir}/test_setting.so mkdir -p %{buildroot}%{_unitdir_user} -install -d %{buildroot}/%{_unitdir_user}/weston.target.wants +install -d %{buildroot}/%{_unitdir_user}/sockets.target.wants install -m 644 %{SOURCE1} %{buildroot}%{_unitdir_user}/settingsd.service -ln -sf ../settingsd.service %{buildroot}/%{_unitdir_user}/weston.target.wants/ +install -m 644 %{SOURCE2} %{buildroot}%{_unitdir_user}/settingsd.socket +ln -sf ../settingsd.socket %{buildroot}/%{_unitdir_user}/sockets.target.wants/ %clean @@ -83,7 +84,8 @@ ln -sf ../settingsd.service %{buildroot}/%{_unitdir_user}/weston.target.wants/ %{pkglibdir}/*.so %config %{_sysconfdir}/%{name}/* %{_unitdir_user}/settingsd.service -%{_unitdir_user}/weston.target.wants/settingsd.service +%{_unitdir_user}/settingsd.socket +%{_unitdir_user}/sockets.target.wants/settingsd.socket %files devel %manifest %{name}.manifest diff --git a/src/daemon.cpp b/src/daemon.cpp index 17b52d7..b403ca4 100644 --- a/src/daemon.cpp +++ b/src/daemon.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -56,12 +57,24 @@ main(int argc, char * argv[]) // The websocket server will run in its own thread. std::thread( [&config, &manager](){ - // Tie the lifetime of the websocket_server to this thread, - // not the main thread, so that we have no lifetime related - // race conditions with respect to the underlying - // libwebsocket_context object. - settings::websocket_server server(config, manager); - server.run(); + // Exceptions are not propagated to other threads with out + // explicit code to do that. Handle exceptions in this + // thread. + try { + // Tie the lifetime of the websocket_server to this thread, + // not the main thread, so that we have no lifetime related + // race conditions with respect to the underlying + // libwebsocket_context object. + settings::websocket_server server(config, manager); + server.run(); + } + catch (std::exception & e) { + std::cerr << e.what() << '\n'; + + // Probably not something from which we can recover. Just + // terminate the daemon. + std::exit(EXIT_FAILURE); + } }).detach(); // Glib related events, including GDbus related signal handlers, -- 2.7.4