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))
181 _dbus_server_trace_ref (&debug_server->base, 0, 1,
"debug_pipe_new");
208 _dbus_transport_debug_pipe_new (
const char *server_name,
214 int client_fd, server_fd;
218 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
220 if (server_pipe_hash ==
NULL)
228 if (server ==
NULL ||
229 ((DBusServerDebugPipe*)server)->disconnected)
252 _dbus_verbose (
"failed to create full duplex pipe\n");
260 if (client_transport ==
NULL)
275 if (server_transport ==
NULL)
296 server_transport =
NULL;
298 if (connection ==
NULL)
322 return client_transport;
336 DBusServerListenResult
347 if (strcmp (method,
"debug-pipe") == 0)
355 return DBUS_SERVER_LISTEN_BAD_ADDRESS;
358 *server_p = _dbus_server_debug_pipe_new (name, error);
362 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
363 return DBUS_SERVER_LISTEN_OK;
367 _DBUS_ASSERT_ERROR_IS_SET(error);
368 return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
373 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
374 return DBUS_SERVER_LISTEN_NOT_HANDLED;
386 DBusTransportOpenResult
396 if (strcmp (method,
"debug-pipe") == 0)
404 return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
407 *transport_p = _dbus_transport_debug_pipe_new (name, error);
409 if (*transport_p ==
NULL)
411 _DBUS_ASSERT_ERROR_IS_SET (error);
412 return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
416 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
417 return DBUS_TRANSPORT_OPEN_OK;
422 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
423 return DBUS_TRANSPORT_OPEN_NOT_HANDLED;