@@ -563,15 +563,15 @@ impl ServiceDaemon {
563
563
zc. status = DaemonStatus :: Shutdown ;
564
564
return Some ( command) ;
565
565
}
566
- Self :: exec_command ( & mut zc , command, false ) ;
566
+ zc . exec_command ( command, false ) ;
567
567
}
568
568
569
569
// check for repeated commands and run them if their time is up.
570
570
let mut i = 0 ;
571
571
while i < zc. retransmissions . len ( ) {
572
572
if now >= zc. retransmissions [ i] . next_time {
573
573
let rerun = zc. retransmissions . remove ( i) ;
574
- Self :: exec_command ( & mut zc , rerun. command , true ) ;
574
+ zc . exec_command ( rerun. command , true ) ;
575
575
} else {
576
576
i += 1 ;
577
577
}
@@ -624,76 +624,6 @@ impl ServiceDaemon {
624
624
}
625
625
}
626
626
}
627
-
628
- /// The entry point that executes all commands received by the daemon.
629
- ///
630
- /// `repeating`: whether this is a retransmission.
631
- fn exec_command ( zc : & mut Zeroconf , command : Command , repeating : bool ) {
632
- match command {
633
- Command :: Browse ( ty, next_delay, listener) => {
634
- zc. exec_command_browse ( repeating, ty, next_delay, listener) ;
635
- }
636
-
637
- Command :: ResolveHostname ( hostname, next_delay, listener, timeout) => {
638
- zc. exec_command_resolve_hostname (
639
- repeating, hostname, next_delay, listener, timeout,
640
- ) ;
641
- }
642
-
643
- Command :: Register ( service_info) => {
644
- zc. register_service ( service_info) ;
645
- zc. increase_counter ( Counter :: Register , 1 ) ;
646
- }
647
-
648
- Command :: RegisterResend ( fullname, intf) => {
649
- debug ! ( "register-resend service: {fullname} on {:?}" , & intf. addr) ;
650
- zc. exec_command_register_resend ( fullname, intf) ;
651
- }
652
-
653
- Command :: Unregister ( fullname, resp_s) => {
654
- debug ! ( "unregister service {} repeat {}" , & fullname, & repeating) ;
655
- zc. exec_command_unregister ( repeating, fullname, resp_s) ;
656
- }
657
-
658
- Command :: UnregisterResend ( packet, ip) => {
659
- zc. exec_command_unregister_resend ( packet, ip) ;
660
- }
661
-
662
- Command :: StopBrowse ( ty_domain) => zc. exec_command_stop_browse ( ty_domain) ,
663
-
664
- Command :: StopResolveHostname ( hostname) => {
665
- zc. exec_command_stop_resolve_hostname ( hostname)
666
- }
667
-
668
- Command :: Resolve ( instance, try_count) => zc. exec_command_resolve ( instance, try_count) ,
669
-
670
- Command :: GetMetrics ( resp_s) => match resp_s. send ( zc. counters . clone ( ) ) {
671
- Ok ( ( ) ) => debug ! ( "Sent metrics to the client" ) ,
672
- Err ( e) => error ! ( "Failed to send metrics: {}" , e) ,
673
- } ,
674
-
675
- Command :: GetStatus ( resp_s) => match resp_s. send ( zc. status . clone ( ) ) {
676
- Ok ( ( ) ) => debug ! ( "Sent status to the client" ) ,
677
- Err ( e) => error ! ( "Failed to send status: {}" , e) ,
678
- } ,
679
-
680
- Command :: Monitor ( resp_s) => {
681
- zc. monitors . push ( resp_s) ;
682
- }
683
-
684
- Command :: SetOption ( daemon_opt) => {
685
- zc. process_set_option ( daemon_opt) ;
686
- }
687
-
688
- Command :: Verify ( instance_fullname, timeout) => {
689
- zc. exec_command_verify ( instance_fullname, timeout, repeating) ;
690
- }
691
-
692
- _ => {
693
- error ! ( "unexpected command: {:?}" , & command) ;
694
- }
695
- }
696
- }
697
627
}
698
628
699
629
/// Creates a new UDP socket that uses `intf` to send and recv multicast.
@@ -2402,6 +2332,76 @@ impl Zeroconf {
2402
2332
}
2403
2333
}
2404
2334
2335
+ /// The entry point that executes all commands received by the daemon.
2336
+ ///
2337
+ /// `repeating`: whether this is a retransmission.
2338
+ fn exec_command ( & mut self , command : Command , repeating : bool ) {
2339
+ match command {
2340
+ Command :: Browse ( ty, next_delay, listener) => {
2341
+ self . exec_command_browse ( repeating, ty, next_delay, listener) ;
2342
+ }
2343
+
2344
+ Command :: ResolveHostname ( hostname, next_delay, listener, timeout) => {
2345
+ self . exec_command_resolve_hostname (
2346
+ repeating, hostname, next_delay, listener, timeout,
2347
+ ) ;
2348
+ }
2349
+
2350
+ Command :: Register ( service_info) => {
2351
+ self . register_service ( service_info) ;
2352
+ self . increase_counter ( Counter :: Register , 1 ) ;
2353
+ }
2354
+
2355
+ Command :: RegisterResend ( fullname, intf) => {
2356
+ debug ! ( "register-resend service: {fullname} on {:?}" , & intf. addr) ;
2357
+ self . exec_command_register_resend ( fullname, intf) ;
2358
+ }
2359
+
2360
+ Command :: Unregister ( fullname, resp_s) => {
2361
+ debug ! ( "unregister service {} repeat {}" , & fullname, & repeating) ;
2362
+ self . exec_command_unregister ( repeating, fullname, resp_s) ;
2363
+ }
2364
+
2365
+ Command :: UnregisterResend ( packet, ip) => {
2366
+ self . exec_command_unregister_resend ( packet, ip) ;
2367
+ }
2368
+
2369
+ Command :: StopBrowse ( ty_domain) => self . exec_command_stop_browse ( ty_domain) ,
2370
+
2371
+ Command :: StopResolveHostname ( hostname) => {
2372
+ self . exec_command_stop_resolve_hostname ( hostname)
2373
+ }
2374
+
2375
+ Command :: Resolve ( instance, try_count) => self . exec_command_resolve ( instance, try_count) ,
2376
+
2377
+ Command :: GetMetrics ( resp_s) => match resp_s. send ( self . counters . clone ( ) ) {
2378
+ Ok ( ( ) ) => debug ! ( "Sent metrics to the client" ) ,
2379
+ Err ( e) => error ! ( "Failed to send metrics: {}" , e) ,
2380
+ } ,
2381
+
2382
+ Command :: GetStatus ( resp_s) => match resp_s. send ( self . status . clone ( ) ) {
2383
+ Ok ( ( ) ) => debug ! ( "Sent status to the client" ) ,
2384
+ Err ( e) => error ! ( "Failed to send status: {}" , e) ,
2385
+ } ,
2386
+
2387
+ Command :: Monitor ( resp_s) => {
2388
+ self . monitors . push ( resp_s) ;
2389
+ }
2390
+
2391
+ Command :: SetOption ( daemon_opt) => {
2392
+ self . process_set_option ( daemon_opt) ;
2393
+ }
2394
+
2395
+ Command :: Verify ( instance_fullname, timeout) => {
2396
+ self . exec_command_verify ( instance_fullname, timeout, repeating) ;
2397
+ }
2398
+
2399
+ _ => {
2400
+ error ! ( "unexpected command: {:?}" , & command) ;
2401
+ }
2402
+ }
2403
+ }
2404
+
2405
2405
fn exec_command_browse (
2406
2406
& mut self ,
2407
2407
repeating : bool ,
0 commit comments