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_ENABLE_EMBEDDED_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,
182 _dbus_server_trace_ref (&debug_server->base, 0, 1,
"debug_pipe_new");
196 _DBUS_SET_OOM (error);
210 _dbus_transport_debug_pipe_new (
const char *server_name,
220 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
222 if (server_pipe_hash ==
NULL)
230 if (server ==
NULL ||
231 ((DBusServerDebugPipe*)server)->disconnected)
253 _dbus_verbose (
"failed to create full duplex pipe\n");
261 if (client_transport ==
NULL)
272 _dbus_socket_invalidate (&client_fd);
276 if (server_transport ==
NULL)
284 _dbus_socket_invalidate (&server_fd);
297 server_transport =
NULL;
299 if (connection ==
NULL)
323 return client_transport;
337 DBusServerListenResult
348 if (strcmp (method,
"debug-pipe") == 0)
356 return DBUS_SERVER_LISTEN_BAD_ADDRESS;
359 *server_p = _dbus_server_debug_pipe_new (name, error);
363 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
364 return DBUS_SERVER_LISTEN_OK;
368 _DBUS_ASSERT_ERROR_IS_SET(error);
369 return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
374 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
375 return DBUS_SERVER_LISTEN_NOT_HANDLED;
387 DBusTransportOpenResult
397 if (strcmp (method,
"debug-pipe") == 0)
405 return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
408 *transport_p = _dbus_transport_debug_pipe_new (name, error);
410 if (*transport_p ==
NULL)
412 _DBUS_ASSERT_ERROR_IS_SET (error);
413 return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
417 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
418 return DBUS_TRANSPORT_OPEN_OK;
423 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
424 return DBUS_TRANSPORT_OPEN_NOT_HANDLED;