[meego-commits] 15245: Changes to Trunk/dsme

Peter Zhu no_reply at build.meego.com
Fri Mar 25 11:18:40 UTC 2011


Hi,
I have made the following changes to dsme in project Trunk. Please review and accept ASAP.

Thank You,
Peter Zhu

[This message was auto-generated]

---

Request #15245:

  submit:   Trunk:Testing/dsme(r2) -> Trunk/dsme


Message:
    Move to Trunk

State:   new          2011-03-25T04:18:33 peter
Comment: None



changes files:
--------------
--- dsme.changes
+++ dsme.changes
@@ -0,0 +1,3 @@
+* Wed Mar 23 2011 Markus Lehtonen <markus.lehtonen at nokia.com> - 0.61.28
+- Add dbus-autoconnector.patch (fixes BMC#13368)
+

new:
----
  dbus-autoconnector.patch

spec files:
-----------
--- dsme.spec
+++ dsme.spec
@@ -19,6 +19,7 @@
 Patch2:     pwrkeymonitor.patch
 Patch3:     meego-state-to-runlevel-mapping.patch
 Patch4:     dbus-policy-fix.patch
+Patch5:     dbus-autoconnector.patch
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(dbus-glib-1)
@@ -46,6 +47,8 @@
 %patch3 -p1
 # dbus-policy-fix.patch
 %patch4 -p1
+# dbus-autoconnector.patch
+%patch5 -p1
 # >> setup
 # << setup
 

other changes:
--------------

++++++ dbus-autoconnector.patch (new)
--- dbus-autoconnector.patch
+++ dbus-autoconnector.patch
+From eb864b40fa2b5ae8941775c84071cefbb79b4bf6 Mon Sep 17 00:00:00 2001
+From: Semi Malinen <semi.malinen at nokia.com>
+Date: Fri, 4 Mar 2011 18:26:34 +0200
+Subject: [PATCH] Add a module to automatically connect dsme to D-Bus System bus
+
+---
+ modules/Makefile.am         |    7 ++-
+ modules/dbusautoconnector.c |  186 +++++++++++++++++++++++++++++++++++++++++++
+ modules/dsme_dbus.c         |    8 ++-
+ modules/dsme_dbus.h         |    2 +
+ modules/startup.c           |    1 +
+ 5 files changed, 202 insertions(+), 2 deletions(-)
+ create mode 100644 modules/dbusautoconnector.c
+
+Index: src/modules/Makefile.am
+===================================================================
+--- src.orig/modules/Makefile.am	2011-03-24 09:49:10.709169123 +0200
++++ src/modules/Makefile.am	2011-03-24 09:50:45.041137546 +0200
+@@ -16,7 +16,8 @@
+                      libemergencycalltracker.la \
+                      libusbtracker.la           \
+                      libiphbservice.la                 \
+-                     librebootloopdetector.la
++                     librebootloopdetector.la   \
++		     libdbusautoconnector.la
+ 
+ noinst_HEADERS = dsme_dbus.h \
+                  runlevel.h \
+@@ -97,6 +98,10 @@
+ 
+ librebootloopdetector_la_SOURCES = rebootloopdetector.c
+ 
++libdbusautoconnector_la_SOURCES = dbusautoconnector.c
++libdbusautoconnector_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
++libdbusautoconnector_la_LIBADD = $(GLIB_LIBS)
++
+ if WANT_BMEIPC
+ libthermalobject_surface_la_SOURCES = thermalobject_surface.c \
+                                       thermalsensor_battery.c \
+Index: src/modules/dbusautoconnector.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ src/modules/dbusautoconnector.c	2011-03-24 09:50:45.051137753 +0200
+@@ -0,0 +1,186 @@
++/**
++   @file dbusautoconnector.c
++
++   Automatically connect Dsme to D-Bus System Bus when it is available.
++   <p>
++   Copyright (C) 2010 Nokia Corporation.
++
++   @author Semi Malinen <semi.malinen at nokia.com>
++
++   This file is part of Dsme.
++
++   Dsme is free software; you can redistribute it and/or modify
++   it under the terms of the GNU Lesser General Public License
++   version 2.1 as published by the Free Software Foundation.
++
++   Dsme is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with Dsme.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#define _GNU_SOURCE
++
++#include "dsme_dbus.h"
++#include "dbusproxy.h"
++#include "dsme/modules.h"
++#include "dsme/logging.h"
++
++#include <dsme/protocol.h>
++#include <unistd.h>
++#include <errno.h>
++#include <sys/inotify.h>
++#include <glib.h>
++#include <stdio.h>
++#include <stdlib.h>
++
++
++#define DSME_SYSTEM_BUS_DIR "/var/run/dbus"
++#define DSME_SYSTEM_BUS_FILE "system_bus_socket"
++#define DSME_INOTIFY_BUF_SIZE (sizeof(struct inotify_event) + PATH_MAX + 1)
++
++
++static void stop_dbus_watch(void);
++
++
++int         inotify_fd = -1;
++int         watch_fd   = -1;
++GIOChannel* channel    =  0;
++
++
++static void connect_to_dbus(void)
++{
++    DSM_MSGTYPE_DBUS_CONNECT msg = DSME_MSG_INIT(DSM_MSGTYPE_DBUS_CONNECT);
++
++    broadcast_internally(&msg);
++}
++
++static gboolean handle_inotify_event(GIOChannel*  source,
++                                     GIOCondition condition,
++                                     gpointer     data)
++{
++    bool keep_watching = true;
++
++    if (condition & G_IO_IN) {
++        dsme_log(LOG_NOTICE, "Got D-Bus dir inotify watch event");
++
++        char buf[DSME_INOTIFY_BUF_SIZE];
++        int  n;
++
++        n = TEMP_FAILURE_RETRY(read(inotify_fd, buf, DSME_INOTIFY_BUF_SIZE));
++        if (n < sizeof(struct inotify_event)) {
++            dsme_log(LOG_ERR, "Error receiving D-Bus dir inotify watch event");
++            keep_watching = false;
++        } else {
++            struct inotify_event* event = (struct inotify_event*)&buf[0];
++
++            if (event->mask & IN_CREATE &&
++                event->len > 0          &&
++                strcmp(event->name, DSME_SYSTEM_BUS_FILE) == 0)
++            {
++                dsme_log(LOG_INFO, "D-Bus System bus socket created; connect");
++                connect_to_dbus();
++                keep_watching = false; // TODO: add support for re-connect
++            }
++        }
++    }
++    if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
++        dsme_log(LOG_ERR, "ERR, HUP or NVAL on D-Bus dir inotify watch");
++        keep_watching = false;
++    }
++
++    if(!keep_watching) {
++        stop_dbus_watch();
++    }
++
++    return keep_watching;
++}
++
++static bool set_up_watch_for_dbus(void)
++{
++    dsme_log(LOG_DEBUG, "setting up a watch for D-Bus System bus socket dir");
++
++    if ((inotify_fd = inotify_init()) == -1) {
++        dsme_log(LOG_ERR, "Error initializing inotify for D-Bus: %m");
++        goto fail;
++    }
++    if ((watch_fd = inotify_add_watch(inotify_fd,
++                                      DSME_SYSTEM_BUS_DIR,
++                                      IN_CREATE))
++                  == -1)
++    {
++        dsme_log(LOG_ERR, "Error adding inotify watch for D-Bus: %m");
++        goto close_inotify_and_fail;
++    }
++
++    if ((channel = g_io_channel_unix_new(inotify_fd)) == 0) {
++        dsme_log(LOG_ERR, "Error creating channel to watch for D-Bus");
++        goto close_fds_and_fail;
++    }
++    g_io_channel_set_close_on_unref(channel, FALSE);
++
++    guint watch = 0;
++    watch = g_io_add_watch(channel,
++                           (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
++                           handle_inotify_event,
++                           0);
++    g_io_channel_unref(channel);
++    if (!watch) {
++        dsme_log(LOG_ERR, "Error adding watch for D-Bus");
++        goto close_inotify_and_fail;
++    }
++
++    return true;
++
++
++close_fds_and_fail:
++    inotify_rm_watch(inotify_fd, watch_fd);
++close_inotify_and_fail:
++    close(inotify_fd);
++fail:
++    return false;
++}
++
++static void stop_dbus_watch(void)
++{
++    dsme_log(LOG_DEBUG, "stopping D-Bus System bus dir watching");
++
++    if (channel) {
++        g_io_channel_shutdown(channel, FALSE, 0);
++        channel = 0;
++    }
(83 more lines skipped)

++++++ dsme.yaml
--- dsme.yaml
+++ dsme.yaml
@@ -24,6 +24,7 @@
     - "pwrkeymonitor.patch"
     - "meego-state-to-runlevel-mapping.patch"
     - "dbus-policy-fix.patch"
+    - "dbus-autoconnector.patch"
 
 PkgConfigBR:
     - glib-2.0




More information about the MeeGo-commits mailing list