@@ -135,25 +135,6 @@ fn deployment_populate_variant_origin(
135
135
Ok ( ( ) )
136
136
}
137
137
138
- /// Connect to the client socket and ensure the daemon is initialized;
139
- /// this avoids DBus and ensures that we get any early startup errors
140
- /// returned cleanly.
141
- pub ( crate ) fn start_daemon_via_socket ( ) -> CxxResult < ( ) > {
142
- let address = "/run/rpm-ostree/client.sock" ;
143
- tracing:: debug!( "Starting daemon via {address}" ) ;
144
- let s = std:: os:: unix:: net:: UnixStream :: connect ( address)
145
- . with_context ( || anyhow ! ( "Failed to connect to {}" , address) ) ?;
146
- let mut s = std:: io:: BufReader :: new ( s) ;
147
- let mut r = String :: new ( ) ;
148
- s. read_to_string ( & mut r)
149
- . context ( "Reading from client socket" ) ?;
150
- if r. is_empty ( ) {
151
- Ok ( ( ) )
152
- } else {
153
- Err ( anyhow ! ( "{r}" ) . into ( ) )
154
- }
155
- }
156
-
157
138
async fn send_ok_result_to_client ( _client : UnixStream ) {
158
139
// On success we close the stream without writing anything,
159
140
// which acknowledges successful startup to the client.
@@ -229,7 +210,10 @@ pub(crate) fn daemon_main(debug: bool) -> Result<()> {
229
210
// directly propagate the error back to our exit code.
230
211
init_res?;
231
212
tracing:: debug!( "Initializing directly (not socket activated)" ) ;
232
- StdUnixListener :: bind ( "/run/rpm-ostree/client.sock" ) ?
213
+ cfg ! ( feature = "client-socket" )
214
+ . then ( || StdUnixListener :: bind ( "/run/rpm-ostree/client.sock" ) )
215
+ . transpose ( )
216
+ . context ( "Binding to socket" ) ?
233
217
}
234
218
Some ( fd) => {
235
219
if fds. next ( ) . is_some ( ) {
@@ -239,7 +223,7 @@ pub(crate) fn daemon_main(debug: bool) -> Result<()> {
239
223
let listener = unsafe { StdUnixListener :: from_raw_fd ( fd) } ;
240
224
241
225
match init_res {
242
- Ok ( _) => listener,
226
+ Ok ( _) => Some ( listener) ,
243
227
Err ( e) => {
244
228
let err_copy = anyhow ! ( "{e}" ) ;
245
229
tracing:: debug!( "Reporting initialization error: {e}" ) ;
@@ -257,16 +241,18 @@ pub(crate) fn daemon_main(debug: bool) -> Result<()> {
257
241
}
258
242
} ;
259
243
260
- let ( shutdown_send, shutdown_recv) = tokio:: sync:: oneshot:: channel ( ) ;
261
- ( * SHUTDOWN_SIGNAL ) . lock ( ) . unwrap ( ) . replace ( shutdown_send) ;
244
+ if let Some ( listener) = listener {
245
+ let ( shutdown_send, shutdown_recv) = tokio:: sync:: oneshot:: channel ( ) ;
246
+ ( * SHUTDOWN_SIGNAL ) . lock ( ) . unwrap ( ) . replace ( shutdown_send) ;
262
247
263
- let listener = UnixListener :: from_std ( listener) ?;
248
+ let listener = UnixListener :: from_std ( listener) ?;
264
249
265
- // On success, we spawn a helper task that just responds with
266
- // sucess to clients that connect via the socket. In the future,
267
- // perhaps we'll expose an API here.
268
- tracing:: debug!( "Spawning acknowledgement task" ) ;
269
- tokio:: task:: spawn ( async { process_clients_with_ok ( listener, shutdown_recv) . await } ) ;
250
+ // On success, we spawn a helper task that just responds with
251
+ // sucess to clients that connect via the socket. In the future,
252
+ // perhaps we'll expose an API here.
253
+ tracing:: debug!( "Spawning acknowledgement task" ) ;
254
+ tokio:: task:: spawn ( async { process_clients_with_ok ( listener, shutdown_recv) . await } ) ;
255
+ }
270
256
271
257
tracing:: debug!( "Entering daemon mainloop" ) ;
272
258
// And now, enter the main loop.
0 commit comments