Repository navigation
Share the per-user socket path definition - #1139
Merged
Merged
Conversation
sthibaul
requested changes
Nov 15, 2026
| // Do not return glib string, but glibc string... | ||
| h = strdup(socket_filename->str); | ||
| g_string_free(socket_filename, 1); | ||
| h = strdup(socket_filename); |
Collaborator
There was a problem hiding this comment.
I don't think we need to strdup any more, and can just return socket_filename?
Contributor
Author
There was a problem hiding this comment.
Well spotted, thanks! Indeed, since GLib 2.46 g_malloc always uses the system malloc, so the string can be released with free(). Done in the first commit, which also drops the "Do not return glib string, but glibc string" comment. With your suggestion the function body comes down from nine lines in master to a single one, a clearer gain than the PR offered before.
The per-user socket, <runtime dir>/speech-dispatcher/speechd.sock, was spelled out in libspeechd (_get_default_unix_socket_name), in the server (runtime_speechd_dir and the "default" socket path) and in the run_test test program. configure.ac now builds the path relative to the runtime directory once, as SPD_SOCKET_PATH, and defines in config.h the macro SPD_BUILD_SOCKET_PATH(runtime_dir), which joins it to a runtime directory with g_build_filename. All three use SPD_BUILD_SOCKET_PATH(g_get_user_runtime_dir()). The server's own directory under the runtime directory, which also holds its pid file and logs, becomes SPD_RUNTIME_SUBDIR, from which SPD_SOCKET_PATH is built, and is also joined with g_build_filename. The resulting paths are unchanged. The server no longer checks that runtime_speechd_dir is non-NULL before building the default socket path, which no longer uses it. The check could not fail anyway, since earlier in main runtime_speechd_dir is always set from g_build_filename, which never returns NULL.
EXTRA_DIST in the top-level Makefile.am now lists one file per line, using line continuations, in the same order as before.
EXTRA_DIST in the top-level Makefile.am is now sorted in byte order, and a comment above it asks to keep it so.
The per-user socket path was still spelled out in the systemd user unit speech-dispatcher.socket and in the Python client (SSIPClient.DEFAULT_SOCKET_PATH). configure.ac now also substitutes spd_socket_path: configure generates speech-dispatcher.socket from the new speech-dispatcher.socket.in, and the Python client takes DEFAULT_SOCKET_PATH from paths.py. The resulting paths are unchanged.
shindere
force-pushed
the
share-socket-path
branch
from
November 16, 2026 00:09
36c9878 to
c9e02da
Compare
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default per-user socket,
<runtime dir>/speech-dispatcher/speechd.sock, is spelled out separately in several places: the server, libspeechd, a test program, the Python client and the systemd user socket unit. Nothing but convention keeps them in agreement, yet that agreement is what lets a client reach a server started with default settings.This PR defines the path relative to the runtime directory,
speech-dispatcher/speechd.sock, once inconfigure.ac, and every place joins it to the runtime directory in the same way. The resulting paths are unchanged.The first commit covers the C code. It defines
SPD_SOCKET_PATHand the macroSPD_BUILD_SOCKET_PATH(runtime_dir)inconfig.h. The macro joins the relative path to a runtime directory withg_build_filename, and the server, libspeechd andsrc/tests/run_test.call useSPD_BUILD_SOCKET_PATH(g_get_user_runtime_dir()). The server's own directory, which also holds its pid file and logs, becomesSPD_RUNTIME_SUBDIR, from whichSPD_SOCKET_PATHis built.The next three commits extend this to files that are not C:
EXTRA_DISTin the top-levelMakefile.am, which the fourth commit changes: one file per line, then sorted, with a comment that fixes the order. This keeps that change, and later ones, readable in a diff, and is of use on its own.configuregeneratesspeech-dispatcher.socketfrom the newspeech-dispatcher.socket.in, and the Python client takesSSIPClient.DEFAULT_SOCKET_PATHfrom the generatedpaths.py. Unlike the.serviceunits, whichmakegenerates because they hold an installation directory (@bindir@), the socket unit holds none, soconfigurecan generate it.Without the fourth commit, the unit and the Python client keep their own copy of the path.
The path remains written out in a comment of
config/speechd.confand in the documentation. Would you welcome generating them too, in this PR or a separate one?Tested with
make check,make installandmake dist: the generated unit andpaths.pyhold the same paths as before, and a server andspd-saybuilt from the first commit alone met at the expected socket.