[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] Connect to socket if SPEECHD_ADDRESS begins with /
From: |
Boris Dušek |
Subject: |
[PATCH 3/3] Connect to socket if SPEECHD_ADDRESS begins with / |
Date: |
Tue, 24 Jul 2012 22:13:05 +0200 |
From: Boris Dus?ek <address@hidden>
To: address@hidden
On OS X, launchd can pass the location of a socket with random name it
creates only in an environment variable, with its value being the
absolute path to the socket. This environment variable is then set in
the whole user session and any clients should check its value to know
how to connect to the relevant service.
To adapt Speech Dispatcher client libraries to this, either we would
invent a new environment variable only for this
purpose (e.g. SPEECHD_LAUNCHD_ADDRESS) and honor it on OS X before
trying the traditional means of specifying the communication socket,
or we can use SPEECHD_ADDRESS by adding a new rule - any value
beginning with "/" is treated as path. This does not collide with the
current use of SPEECHD_ADDRESS - it begins with specifier of the
communication method and no specifier begins with "/". Also no IP or
DNS address begins with "/".
I chose the second variant since it does not require adding a new
environment variable to the mix, and might simplify the syntax for
some current users setting the socket path. But I admit it might be a
bit non-systematic.
---
src/api/c/libspeechd.c | 3 +++
src/api/python/speechd/client.py | 2 ++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/api/c/libspeechd.c b/src/api/c/libspeechd.c
index 25e5250..3b7334a 100644
--- a/src/api/c/libspeechd.c
+++ b/src/api/c/libspeechd.c
@@ -176,6 +176,9 @@ SPDConnectionAddress *spd_get_default_address(char **error)
if (env_address == NULL) { // Default method = unix sockets
address->method = SPD_METHOD_UNIX_SOCKET;
address->unix_socket_name = _get_default_unix_socket_name();
+ } else if (env_address[0] == '/') {
+ address->method = SPD_METHOD_UNIX_SOCKET;
+ address->unix_socket_name = strdup(env_address);
} else {
pa = g_strsplit(env_address, ":", 0);
assert(pa);
diff --git a/src/api/python/speechd/client.py b/src/api/python/speechd/client.py
index 8d34363..4bcaf85 100644
--- a/src/api/python/speechd/client.py
+++ b/src/api/python/speechd/client.py
@@ -549,6 +549,8 @@ class SSIPClient(object):
_address = address or os.environ.get("SPEECHD_ADDRESS")
if _address:
+ if _address[0]='/':
+ _address = '%s:%s' % (CommunicationMethod.UNIX_SOCKET,
_address,)
connection_args.update(self._connection_arguments_from_address(_address))
# Respect the old (deprecated) key arguments and environment variables
# TODO: Remove this section in 0.8 release
--
1.7.7.5 (Apple Git-26)
- [PATCH 1/3] Do not exit on localization init fail, Boris Dušek, 2012/07/24
- [PATCH 2/3] Cleanup execution of commands in dummy, Boris Dušek, 2012/07/24
- [PATCH 2/3] Cleanup execution of commands in dummy, Trevor Saunders, 2012/07/24
- [PATCH 2/3] Cleanup execution of commands in dummy, Boris Dušek, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Trevor Saunders, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Boris Dušek, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Andrei Kholodnyi, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Boris Dušek, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Andrei Kholodnyi, 2012/07/25
- [PATCH 2/3] Cleanup execution of commands in dummy, Trevor Saunders, 2012/07/25
[PATCH 3/3] Connect to socket if SPEECHD_ADDRESS begins with /,
Boris Dušek <=
[PATCH v2 0/3] Small improvements, Boris Dušek, 2012/07/28