26 #include "dbus-internals.h"
27 #include "dbus-server-debug-pipe.h"
28 #include "dbus-transport-socket.h"
29 #include "dbus-connection-internal.h"
30 #include "dbus-hash.h"
31 #include "dbus-string.h"
32 #include "dbus-protocol.h"
34 #ifdef DBUS_BUILD_TESTS
50 typedef struct DBusServerDebugPipe DBusServerDebugPipe;
56 struct DBusServerDebugPipe
67 static int server_pipe_hash_refcount = 0;
72 if (!server_pipe_hash)
78 if (!server_pipe_hash)
82 server_pipe_hash_refcount = 1;
88 pipe_hash_unref (
void)
93 server_pipe_hash_refcount -= 1;
94 if (server_pipe_hash_refcount == 0)
97 server_pipe_hash =
NULL;
104 DBusServerDebugPipe *debug_server = (DBusServerDebugPipe*) server;
117 ((DBusServerDebugPipe*)server)->disconnected =
TRUE;
133 _dbus_server_debug_pipe_new (
const char *server_name,
136 DBusServerDebugPipe *debug_server;
140 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
142 if (!pipe_hash_ref ())
152 debug_server =
dbus_new0 (DBusServerDebugPipe, 1);
153 if (debug_server ==
NULL)
165 if (debug_server->name ==
NULL)
169 &debug_vtable, &address))
207 _dbus_transport_debug_pipe_new (
const char *server_name,
213 int client_fd, server_fd;
217 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
219 if (server_pipe_hash ==
NULL)
227 if (server ==
NULL ||
228 ((DBusServerDebugPipe*)server)->disconnected)
251 _dbus_verbose (
"failed to create full duplex pipe\n");
259 if (client_transport ==
NULL)
274 if (server_transport ==
NULL)
295 server_transport =
NULL;
297 if (connection ==
NULL)
321 return client_transport;
335 DBusServerListenResult
346 if (strcmp (method,
"debug-pipe") == 0)
354 return DBUS_SERVER_LISTEN_BAD_ADDRESS;
357 *server_p = _dbus_server_debug_pipe_new (name, error);
361 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
362 return DBUS_SERVER_LISTEN_OK;
366 _DBUS_ASSERT_ERROR_IS_SET(error);
367 return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
372 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
373 return DBUS_SERVER_LISTEN_NOT_HANDLED;
385 DBusTransportOpenResult
395 if (strcmp (method,
"debug-pipe") == 0)
403 return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
406 *transport_p = _dbus_transport_debug_pipe_new (name, error);
408 if (*transport_p ==
NULL)
410 _DBUS_ASSERT_ERROR_IS_SET (error);
411 return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
415 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
416 return DBUS_TRANSPORT_OPEN_OK;
421 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
422 return DBUS_TRANSPORT_OPEN_NOT_HANDLED;