Issue with _dbus_write_socket on windows

Peter Kümmel syntheticpp at gmx.net
Fri Nov 17 08:16:40 PST 2006


Christian Ehrlicher wrote:
> Hi,
> 
> Yesterday we found a problem with _dbus_write_socket() on windows. The comment to this function is:
>  * Like _dbus_write(), but only supports sockets
>  * and is thus available on Windows.
> 
> But I found no function to write a fd. Only unix has a function _dbus_write(), but it's not internal public (only declared in dbus-sysdeps-unix.h).
> -> We need to move _dbus_write() to dbus-sysdeps.h/.c (no need for special win32 version afaics) and use this function in bus/bus.c:633 and other similar places to avoid crashes on windows.
> 
> Is my assumption correct or do I miss something here?
> 
> Christian
> 

After discussing this, we've currently solved the problem by introducing
a _dbus_write_stream function. But this is maybe not perfect.

Attached the patch with the global and unix specific changes.

Peter
-------------- next part --------------
Index: dbus/dbus-sysdeps-unix.c
===================================================================
--- dbus/dbus-sysdeps-unix.c	(revision 428)
+++ dbus/dbus-sysdeps-unix.c	(working copy)
@@ -169,6 +169,15 @@
   return _dbus_write (fd, buffer, start, len);
 }
 
+int
+_dbus_write_stream (DBusStream        stream,
+                    const DBusString *buffer,
+                    int               start,
+                    int               len)
+{
+	return _dbus_write (stream, buffer, start, len);
+}
+
 /**
  * Like _dbus_write_two() but only works on sockets and is thus
  * available on Windows.
Index: dbus/dbus-sysdeps.h
===================================================================
--- dbus/dbus-sysdeps.h	(revision 428)
+++ dbus/dbus-sysdeps.h	(working copy)
@@ -298,6 +298,12 @@
 
 dbus_bool_t _dbus_get_standard_session_servicedirs (DBusList **dirs);
 
+typedef int DBusStream;
+int _dbus_write_stream (DBusStream        stream,
+                        const DBusString *buffer,
+                        int               start,
+                        int               len);
+
 /** Opaque type for reading a directory listing */
 typedef struct DBusDirIter DBusDirIter;
 
 
 /**
Index: bus/bus.c
===================================================================
--- bus/bus.c	(revision 428)
+++ bus/bus.c	(working copy)
@@ -630,7 +630,7 @@
         }
 
       bytes = _dbus_string_get_length (&addr);
-      if (_dbus_write_socket (print_addr_fd, &addr, 0, bytes) != bytes)
+      if (_dbus_write_stream (print_addr_fd, &addr, 0, bytes) != bytes)
         {
           dbus_set_error (error, DBUS_ERROR_FAILED,
                           "Printing message bus address: %s\n",
@@ -731,7 +731,7 @@
         }
 
       bytes = _dbus_string_get_length (&pid);
-      if (_dbus_write_socket (print_pid_fd, &pid, 0, bytes) != bytes)
+      if (_dbus_write_stream (print_pid_fd, &pid, 0, bytes) != bytes)
         {
           dbus_set_error (error, DBUS_ERROR_FAILED,
                           "Printing message bus PID: %s\n",


More information about the dbus mailing list