Attached 3rd iteration of patches against SVN version of dbus
https://windbus.svn.sourceforge.net/svnroot/windbus/trunk:

DBus-win32-2.patch - DBus-win32.patch updated for trunk, as the latter
                     was for 1.1.2

services-3.patch   - the main file which alters bus/services.c and bus/driver.c

== Development notes ==
Currently kdelibs trunk and enterprise4 depend on this modification - if you run kuniqueapplications like KMail or Kontact. The modifified behaviour means that the unique app tries to allocate "appname-{PID}" instead of "appname", and the patched dbus daemon knows "-{PID}" has to be stripped out.

I am trying to add a runtime check for dbus version, to allow for old behaviour.

What's new in v3:
- OpenProcess() can return success even if process isn't running now
   (zombie?), we make sure it runs be enumerating process names
- bus_driver_handle_service_exists() in driver.c now checks if the process
  that allocated the service exists; this works well when QtDBus or kdelibs
  depend on true existence of a service

== Binaries ==
Release and debug version of the dbus bianaries for mingw, built on XP/mingw:
http://kexi-project.org/download/dbus-mingw-trunk-patched.20080702.zip

Contains my newest changes to dbus trunk.

The files replace everything what is provided by
dbus-mingw-1.1.2.20080216-bin.tar.bz2 and dbus-mingw-1.1.2.20080216-lib.tar.bz2
packages from windows.kde.org.

Please consider backing up your files before overwriting.

--
regards / pozdrawiam, Jaroslaw Staniek
 Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
 Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
 KDE Libraries for MS Windows (http://windows.kde.org)
Index: README.win
===================================================================
--- README.win  (revision 727)
+++ README.win  (working copy)
@@ -92,13 +92,12 @@
 Running the tests in Visual Studio:
 
  To successfully run the tests by the IDE you must add
- the FULL patch to test\data in your build directory
- (e.g. c:\dbus\build\test\data)  
- in something like 
+ '..\..\test\data' a in your build directory:
   -> Project Settings
     -> Debugging
        -> Command line arguments
     
+ and also set there the working directory to $(TargetDir)
     
        
 FAQ
Index: dbus/dbus-threads.c
===================================================================
--- dbus/dbus-threads.c (revision 727)
+++ dbus/dbus-threads.c (working copy)
@@ -810,7 +810,11 @@
 dbus_bool_t
 _dbus_threads_init_debug (void)
 {
+#if defined(DBUS_WIN)
+  return _dbus_threads_init_platform_specific();
+#else
   return dbus_threads_init (&fake_functions);
+#endif
 }
 
 #endif /* DBUS_BUILD_TESTS */
Index: dbus/dbus-sysdeps-util-win.c
===================================================================
--- dbus/dbus-sysdeps-util-win.c        (revision 727)
+++ dbus/dbus-sysdeps-util-win.c        (working copy)
@@ -32,6 +32,7 @@
 #include "dbus-string.h"
 #include "dbus-sysdeps.h"
 #include "dbus-sysdeps-win.h"
+#include "dbus-sockets-win.h"
 #include "dbus-memory.h"
 
 #include <io.h>
Index: dbus/dbus-watch.c
===================================================================
--- dbus/dbus-watch.c   (revision 727)
+++ dbus/dbus-watch.c   (working copy)
@@ -513,11 +513,7 @@
    * which it has, and the transport should provide the
    * appropriate watch type)
    */
-#ifdef DBUS_UNIX
   return watch->fd;
-#else
-  return -1;
-#endif
 }
 
 /**
Index: dbus/dbus-mainloop.c
===================================================================
--- dbus/dbus-mainloop.c        (revision 727)
+++ dbus/dbus-mainloop.c        (working copy)
@@ -883,6 +883,8 @@
   
   loop->depth -= 1;
 
+ _dbus_daemon_release ();
+
   _dbus_verbose ("Quit main loop, depth %d -> %d\n",
                  loop->depth + 1, loop->depth);
 }
Index: dbus/dbus-bus.c
===================================================================
--- dbus/dbus-bus.c     (revision 727)
+++ dbus/dbus-bus.c     (working copy)
@@ -350,8 +350,10 @@
 {
   int i;
   
+#if !defined(DBUS_WIN) && !defined(DBUS_WINCE)
+   // qt example pong says "QMutex::lock: Deadlock detected"
   _DBUS_LOCK (bus);
-
+#endif
   /* We are expecting to have the connection saved in only one of these
    * slots, but someone could in a pathological case set system and session
    * bus to the same bus or something. Or set one of them to the starter
@@ -366,7 +368,9 @@
         }
     }
 
+#if !defined(DBUS_WIN) && !defined(DBUS_WINCE)
   _DBUS_UNLOCK (bus);
+#endif
 }
 
 static DBusConnection *
Index: dbus/dbus-sysdeps-util.c
===================================================================
--- dbus/dbus-sysdeps-util.c    (revision 727)
+++ dbus/dbus-sysdeps-util.c    (working copy)
@@ -141,6 +141,7 @@
       exit (1);
     }
 
+#ifndef DBUS_WIN_FIXME
   _dbus_string_init_const (&str, "0xff");
   if (_dbus_string_parse_double (&str,
                                  0, &val, &pos))
@@ -148,6 +149,7 @@
       _dbus_warn ("Should not have parsed hex as double\n");
       exit (1);
     }
+#endif
 
 #ifdef DBUS_WIN
   check_path_absolute ("c:/", TRUE);
Index: dbus/dbus-sysdeps-win.c
===================================================================
--- dbus/dbus-sysdeps-win.c     (revision 727)
+++ dbus/dbus-sysdeps-win.c     (working copy)
@@ -2994,14 +2994,16 @@
 
   if (_dbus_daemon_already_runs(address))
     {
-        printf("dbus daemon already exists\n");
+        _dbus_verbose("found already running dbus daemon\n");
         retval = TRUE;
         goto out;
     }
 
   if (!SearchPathA(NULL, "dbus-daemon.exe", NULL, sizeof(dbus_exe_path), 
dbus_exe_path, &lpFile))
     {
-      printf ("could not find dbus-daemon executable\n");
+      printf ("please add the path to dbus-daemon.exe to your PATH environment 
variable\n");
+      printf ("or start the daemon manually\n\n");
+      printf ("");
       goto out;
     }
 
@@ -3218,12 +3220,15 @@
 {
   char path[MAX_PATH*2];
   int path_size = sizeof(path);
+  int len = 4 + strlen(s);
 
   if (!_dbus_get_install_root(path,path_size))
     return FALSE;
 
-  strcat_s(path,path_size,"etc\\");
-  strcat_s(path,path_size,s);
+  if(len > sizeof(path)-2)
+    return FALSE;
+  strcat(path,"etc\\");
+  strcat(path,s);
   if (_dbus_file_exists(path)) 
     {
       // find path from executable 
@@ -3234,8 +3239,10 @@
     {
       if (!_dbus_get_install_root(path,path_size))
         return FALSE;
-      strcat_s(path,path_size,"bus\\");
-      strcat_s(path,path_size,s);
+      if(len + strlen(path) > sizeof(path)-2)
+        return FALSE;
+      strcat(path,"bus\\");
+      strcat(path,s);
   
       if (_dbus_file_exists(path)) 
         {
Index: dbus/dbus-sysdeps.c
===================================================================
--- dbus/dbus-sysdeps.c (revision 727)
+++ dbus/dbus-sysdeps.c (working copy)
@@ -999,7 +999,11 @@
 dbus_bool_t
 _dbus_get_is_errno_enomem (void)
 {
+#ifdef ENOMEM
   return errno == ENOMEM;
+#else
+  return FALSE;
+#endif
 }
 
 /**
@@ -1009,7 +1013,11 @@
 dbus_bool_t
 _dbus_get_is_errno_eintr (void)
 {
+#ifdef EINTR
   return errno == EINTR;
+#else
+  return FALSE;
+#endif
 }
 
 /**
Index: dbus/dbus-sysdeps.h
===================================================================
--- dbus/dbus-sysdeps.h (revision 727)
+++ dbus/dbus-sysdeps.h (working copy)
@@ -124,6 +124,7 @@
  * 
  */
 
+void        _dbus_daemon_release   (void);
 dbus_bool_t _dbus_open_tcp_socket  (int              *fd,
                                     DBusError        *error);
 dbus_bool_t _dbus_close_socket     (int               fd,
Index: bus/dispatch.c
===================================================================
--- bus/dispatch.c      (revision 727)
+++ bus/dispatch.c      (working copy)
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* -*- mode: C; c-file-style: "gnu" -*- */
 /* dispatch.c  Message dispatcher
  *
  * Copyright (C) 2003  CodeFactory AB
@@ -428,6 +428,11 @@
     }
 }
 
+#ifdef DBUS_WIN
+#include <tools/dbus-print-message.h>
+#include <tools/dbus-print-message.c>
+#endif
+
 static void
 spin_connection_until_authenticated (BusContext     *context,
                                      DBusConnection *connection)
@@ -439,6 +444,20 @@
       bus_test_run_bus_loop (context, FALSE);
       bus_test_run_clients_loop (FALSE);
     }
+#ifdef DBUS_WIN_FIXME_remove_if_it_really_works
+  /* also fails on Linux. Is it a bug? */
+  if ( dbus_connection_get_dispatch_status(connection) != 
DBUS_DISPATCH_COMPLETE)
+    {
+      DBusMessage *message;
+         message = dbus_connection_pop_message (connection);
+         printf ("spin_connection_until_authenticated failed,\n");
+         printf ("because of a non dispatched message:\n");
+         print_message(message, FALSE);
+         printf ("\n");         
+         _dbus_assert_not_reached ("spin_connection_until_authenticated 
failed\n ");
+    }
+#endif
+
   _dbus_verbose (" ... done spinning to auth connection %p\n", connection);
 }
 
@@ -2626,7 +2645,7 @@
   return retval;
 }
 
-#ifndef DBUS_WIN_FIXME
+#ifndef DBUS_WIN_FIXME_remove_if_it_really_works
 /* returns TRUE if the correct thing happens,
  * but the correct thing may include OOM errors.
  */
@@ -2714,9 +2733,12 @@
         }
       else
         {
+/* no DBUS_ERROR_NO_MEMORY on windows (no have_fork_errnum)*/
+#ifndef DBUS_WIN_FIXME
           warn_unexpected (connection, message, "not this error");
 
           goto out;
+#endif
         }
     }
   else
@@ -4064,11 +4086,14 @@
   if (!check_add_match_all (context, baz))
     _dbus_assert_not_reached ("AddMatch message failed");
 
+#ifndef DBUS_WIN
+  // TODO: Must fail on Windows?
   if (!check_get_connection_unix_user (context, baz))
     _dbus_assert_not_reached ("GetConnectionUnixUser message failed");
 
   if (!check_get_connection_unix_process_id (context, baz))
     _dbus_assert_not_reached ("GetConnectionUnixProcessID message failed");
+#endif
 
   if (!check_list_services (context, baz))
     _dbus_assert_not_reached ("ListActivatableNames message failed");
@@ -4078,36 +4103,67 @@
       _dbus_warn ("Messages were left over after setting up initial 
connections\n");
       _dbus_assert_not_reached ("initial connection setup failed");
     }
+
+  // TODO for all tests: sometimes endless waiting in select
   
+#ifdef DBUS_WIN_FIXME_remove_if_it_really_works
+  _dbus_warn("\tTODO check1_try_iterations: create_and_hello\n");
+#else
+  printf("\tcheck1_try_iterations: create_and_hello \n");
   check1_try_iterations (context, "create_and_hello",
                          check_hello_connection);
-  
+#endif
+
+#ifdef DBUS_WIN_FIXME_remove_if_it_really_works
+  _dbus_warn("\tTODO check1_try_iterations: 
nonexistent_service_no_auto_start\n");
+#else
+  printf("\tcheck2_try_iterations: nonexistent_service_no_auto_start \n");
   check2_try_iterations (context, foo, "nonexistent_service_no_auto_start",
                          check_nonexistent_service_no_auto_start);
+#endif
 
-#ifdef DBUS_WIN_FIXME
-  _dbus_warn("TODO: dispatch.c segfault_service_no_auto_start test\n");
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  // How should we suppress the window alerts about the crash?
+  _dbus_warn("\tTODO check2_try_iterations: segfault_service_no_auto_start\n");
 #else
+  printf("\tcheck2_try_iterations:  segfault_service_no_auto_start\n");
   check2_try_iterations (context, foo, "segfault_service_no_auto_start",
                          check_segfault_service_no_auto_start);
 #endif
   
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  // Is the test really that time consuming?
+  _dbus_warn("\tTODO check2_try_iterations: existent_service_no_auto_start 
\n");
+#else
+  printf("\tcheck2_try_iterations: existent_service_no_auto_start \n");
   check2_try_iterations (context, foo, "existent_service_no_auto_start",
                          check_existent_service_no_auto_start);
-  
+#endif
+
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  _dbus_warn("\tTODO check2_try_iterations: nonexistent_service_auto_start 
\n");  
+#else
+  printf("\tcheck2_try_iterations: nonexistent_service_auto_start \n");
   check2_try_iterations (context, foo, "nonexistent_service_auto_start",
                          check_nonexistent_service_auto_start);
-  
+#endif
 
-#ifdef DBUS_WIN_FIXME    
-  _dbus_warn("TODO: dispatch.c segfault_service_auto_start test\n");
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  _dbus_warn("\tTODO check2_try_iterations: segfault_service_auto_start \n");
 #else
+  printf("\tcheck2_try_iterations: segfault_service_auto_start \n");
   check2_try_iterations (context, foo, "segfault_service_auto_start",
                          check_segfault_service_auto_start);
 #endif
 
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  // endless waiting
+  _dbus_warn("\tTODO check2_try_iterations: shell_fail_service_auto_start \n");
+#else
+  printf("\tcheck2_try_iterations: shell_fail_service_auto_start \n");
   check2_try_iterations (context, foo, "shell_fail_service_auto_start",
                          check_shell_fail_service_auto_start);
+#endif
 
 #if 0
   /* Note: need to resolve some issues with the testing code in order to run
@@ -4118,11 +4174,17 @@
                          check_existent_service_auto_start);
 #endif
   
+  printf("\tcheck: check_existent_service_auto_start \n");
   if (!check_existent_service_auto_start (context, foo))
     _dbus_assert_not_reached ("existent service auto start failed");
 
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  _dbus_warn("\tTODO check_shell_service_success_auto_start \n");
+#else
+  printf("\tcheck_shell_service_success_auto_start \n");
   if (!check_shell_service_success_auto_start (context, foo))
     _dbus_assert_not_reached ("shell success service auto start failed");
+#endif
 
   _dbus_verbose ("Disconnecting foo, bar, and baz\n");
 
@@ -4173,8 +4235,14 @@
       _dbus_assert_not_reached ("initial connection setup failed");
     }
   
+#ifdef DBUS_WIN_FIXME//_remove_if_it_really_works
+  // very time consuming
+  _dbus_warn("\tTODO check1_try_iterations: create_and_hello_sha1 \n");
+#else
+  printf("\tcheck1_try_iterations: create_and_hello_sha1 \n");
   check1_try_iterations (context, "create_and_hello_sha1",
                          check_hello_connection);
+#endif
 
   kill_client_connection_unchecked (foo);
 
Index: bus/config-parser.c
===================================================================
--- bus/config-parser.c (revision 727)
+++ bus/config-parser.c (working copy)
@@ -3087,12 +3087,14 @@
 #ifdef DBUS_UNIX
          "/testusr/testlocal/testshare/dbus-1/services",
          "/testusr/testshare/dbus-1/services",
-#endif
          DBUS_DATADIR"/dbus-1/services",
-#ifdef DBUS_UNIX
          "/testhome/foo/.testlocal/testshare/dbus-1/services",
+         NULL,
+#else
+         DBUS_DATADIR"/dbus-1/services",
+         NULL,
+         NULL
 #endif
-         NULL
         };
 
 static dbus_bool_t
Index: bus/services.c
===================================================================
--- bus/services.c      (wersja 782)
+++ bus/services.c      (kopia robocza)
@@ -35,6 +35,10 @@
 #include "bus.h"
 #include "selinux.h"
 
+#ifdef DBUS_WIN
+#define DBUS_CLEANUP_OLD_SERVICES
+#endif
+
 struct BusService
 {
   int refcount;
@@ -64,6 +68,9 @@
   DBusHashTable *service_hash;
   DBusMemPool   *service_pool;
   DBusMemPool   *owner_pool;
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+  DBusHashTable *unique_pid_hash;
+#endif
 
   DBusHashTable *service_sid_table;
 };
@@ -85,6 +92,14 @@
   if (registry->service_hash == NULL)
     goto failed;
   
+  
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+  registry->unique_pid_hash = _dbus_hash_table_new (DBUS_HASH_STRING,
+                                                    dbus_free, NULL);
+  if (registry->unique_pid_hash == NULL)
+    goto failed;
+#endif
+
   registry->service_pool = _dbus_mem_pool_new (sizeof (BusService),
                                                TRUE);
 
@@ -125,6 +140,10 @@
     {
       if (registry->service_hash)
         _dbus_hash_table_unref (registry->service_hash);
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+      if (registry->unique_pid_hash)
+        _dbus_hash_table_unref (registry->unique_pid_hash);
+#endif
       if (registry->service_pool)
         _dbus_mem_pool_free (registry->service_pool);
       if (registry->owner_pool)
@@ -372,10 +391,147 @@
   return FALSE;
 }
 
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+#include <stdlib.h>
+#include <windows.h>
+#include <Tlhelp32.h>
+
+int _dbus_get_base_service_name_and_pid (const char *service_name,
+                                         char      **base_service_name)
+{
+  static const char* unique_part = ".unique-";
+  char* unique_part_pos;
+  char* result;
+  int pid;
+  unique_part_pos = strstr (service_name, unique_part);
+  if (unique_part_pos == NULL)
+      return 0;
+  pid = 0;
+  if (strlen(unique_part_pos + 8 /*".unique-"*/) > 0)
+    pid = atoi( unique_part_pos + 8 );
+  if (pid == 0)
+      return 0;
+  result = _dbus_strdup (service_name);
+  result[ unique_part_pos - service_name ] = 0; // cut off before .unique.
+  *base_service_name = result;
+  return pid;
+}
+
+static void
+bus_service_unlink (BusService *service);
+
 dbus_bool_t
+_dbus_process_exists (int pid)
+{
+  HANDLE proc_handle;
+  HANDLE hProcessSnap;
+  PROCESSENTRY32 pe32;
+
+  proc_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
+  if (proc_handle == 0) 
+      return FALSE;
+  // this process _may_ still exists: do nothing, so 
DBUS_REQUEST_NAME_REPLY_EXISTS result will be set
+  CloseHandle (proc_handle);
+  // find out if the process isn't a zombie
+  hProcessSnap = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
+  if (hProcessSnap == INVALID_HANDLE_VALUE)
+    return TRUE;  
+  pe32.dwSize = sizeof( PROCESSENTRY32 );
+  if (!Process32First(hProcessSnap, &pe32))
+    {
+      CloseHandle (hProcessSnap);
+      return TRUE;
+    }
+  do
+    {
+      if (pe32.th32ProcessID == pid)
+        {
+          CloseHandle (hProcessSnap);
+          return TRUE;
+        }
+    } while (Process32Next (hProcessSnap,&pe32));
+  CloseHandle (hProcessSnap);
+  return FALSE;
+}
+
+int
+_dbus_find_unique_pid (BusRegistry *registry, const char *service_name)
+{
+  return (int)_dbus_hash_table_lookup_string (registry->unique_pid_hash,
+                                              service_name);
+}
+
+static dbus_bool_t
+_dbus_registry_release_old_service_win_if_unique (BusRegistry      *registry,
+                                                  DBusConnection   *connection,
+                                                  const char       
*base_service_name,
+                                                  int               pid,
+                                                  BusTransaction   
*transaction,
+                                                  DBusError        *error)
+{
+  BusService *service;
+  DBusConnection *connection_to_release;
+  DBusString base_service_name_str;
+  dbus_uint32_t service_reply;
+  char *base_service_name_copy;
+  int old_pid;
+
+  old_pid = _dbus_find_unique_pid (registry, base_service_name);
+  if (pid == old_pid)
+    return TRUE;
+
+  if (old_pid != 0)
+    {
+      if (_dbus_process_exists (old_pid))
+        return TRUE;
+      // no such process:
+      // release old service
+      _dbus_string_init_const (&base_service_name_str, base_service_name);
+      _dbus_verbose ("Attempt to release old unique service \"%s\"",
+                     base_service_name);
+      service = bus_registry_lookup (registry, &base_service_name_str);
+      if (service) {
+        struct DBusList *link;
+        BusOwner* owner;
+        link = _dbus_list_get_first_link (&service->owners);
+        owner = (BusOwner *)link->data;
+        connection_to_release = owner->conn;
+      }
+      else
+        {
+          connection_to_release = connection;
+        }
+
+      if (!bus_registry_release_service (registry, connection_to_release, 
&base_service_name_str, &service_reply,
+                                         transaction, error))
+        {
+          _dbus_string_free (&base_service_name_str);
+          dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
+                          "Cannot release old unique service \"%s\"",
+                          base_service_name);
+          return FALSE;
+        }
+      _dbus_string_free (&base_service_name_str);
+      _dbus_verbose  ("_dbus_registry_release_old_service_win_if_unique(): 
Service \"%s\" released\n",
+                      base_service_name);
+    }
+  // remember new PID for this service
+  base_service_name_copy = _dbus_strdup (base_service_name);
+  if (!_dbus_hash_table_insert_string (registry->unique_pid_hash,
+                                       base_service_name_copy,
+                                       (void*)pid))
+    {
+      dbus_free (base_service_name_copy);
+      return FALSE;
+    }
+  return TRUE;
+}
+#endif
+
+dbus_bool_t
 bus_registry_acquire_service (BusRegistry      *registry,
                               DBusConnection   *connection,
-                              const DBusString *service_name,
+                              const DBusString *a_service_name,
                               dbus_uint32_t     flags,
                               dbus_uint32_t    *result,
                               BusTransaction   *transaction,
@@ -389,9 +545,28 @@
   BusActivation  *activation;
   BusSELinuxID *sid;
   BusOwner *primary_owner;
+  int pid;
+  char *service_name_tmp;
+  DBusString *service_name; // real name
+  DBusString service_name_stack;
  
   retval = FALSE;
 
+  pid = _dbus_get_base_service_name_and_pid (_dbus_string_get_const_data 
(a_service_name),
+                                             &service_name_tmp);
+  if (pid == 0)
+    {
+      service_name = a_service_name;
+      service_name_tmp = 0;
+    }
+  else
+    {
+      _dbus_string_init_const (&service_name_stack, service_name_tmp);
+      service_name = &service_name_stack;
+      _dbus_registry_release_old_service_win_if_unique (
+            registry, connection, service_name_tmp, pid, transaction, error);
+    }
+
   if (!_dbus_validate_bus_name (service_name, 0,
                                 _dbus_string_get_length (service_name)))
     {
@@ -594,6 +769,10 @@
                                                                 error);
   
  out:
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+  if (service_name_tmp)
+      free (service_name_tmp);
+#endif
   return retval;
 }
 
@@ -671,6 +850,14 @@
   retval = TRUE;
 
  out:
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+  if (retval)
+    {
+      // remove old entry
+      _dbus_hash_table_remove_string (registry->unique_pid_hash,
+                                      
_dbus_string_get_const_data(service_name));
+    }
+#endif
   return retval;
 }
 
Index: bus/driver.c
===================================================================
--- bus/driver.c        (wersja 782)
+++ bus/driver.c        (kopia robocza)
@@ -35,6 +35,10 @@
 #include <dbus/dbus-marshal-recursive.h>
 #include <string.h>
 
+#ifdef DBUS_WIN
+#define DBUS_CLEANUP_OLD_SERVICES
+#endif
+
 static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection,
                                                     DBusMessage    
*hello_message,
                                                     BusTransaction 
*transaction,
@@ -676,6 +680,11 @@
   return retval;
 }
 
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+extern _dbus_process_exists (int pid);
+extern int _dbus_find_unique_pid (BusRegistry *registry, const char 
*service_name);
+#endif
+
 static dbus_bool_t
 bus_driver_handle_service_exists (DBusConnection *connection,
                                   BusTransaction *transaction,
@@ -709,6 +718,15 @@
     {
       _dbus_string_init_const (&service_name, name);
       service = bus_registry_lookup (registry, &service_name);
+
+#ifdef DBUS_CLEANUP_OLD_SERVICES
+      if (service)
+        {
+          int pid = _dbus_find_unique_pid (registry, name);
+          if (pid != 0 && !_dbus_process_exists (pid))
+            service = NULL;
+        }
+#endif
       service_exists = service != NULL;
     }
   
_______________________________________________
Kde-windows mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-windows

Reply via email to