@@ -64,6 +64,7 @@ int main(int argc, char** argv) {
6464 auto logcat_file =
6565 cuttlefish::SharedFD::Open (path.c_str (), O_CREAT | O_APPEND | O_WRONLY, 0666 );
6666
67+ bool first_iter = true ;
6768 // Server loop
6869 while (true ) {
6970 char buff[1024 ];
@@ -73,9 +74,35 @@ int main(int argc, char** argv) {
7374 break ;
7475 }
7576 auto written = cuttlefish::WriteAll (logcat_file, buff, read);
76- CHECK (written == read) << " Error writing to log file: "
77- << logcat_file->StrError ()
78- << " . This is unrecoverable." ;
77+ CHECK (written == read)
78+ << " Error writing to log file: " << logcat_file->StrError ()
79+ << " . This is unrecoverable." ;
80+ if (first_iter) {
81+ first_iter = false ;
82+ if ((!config->snapshot_path ().empty ())) {
83+ cuttlefish::SharedFD restore_pipe = cuttlefish::SharedFD::Open (
84+ instance.restore_pipe_name ().c_str (), O_WRONLY);
85+ if (!restore_pipe->IsOpen ()) {
86+ LOG (ERROR) << " Error opening restore pipe: "
87+ << restore_pipe->StrError ();
88+ return 2 ;
89+ }
90+ cuttlefish::SharedFD restore_adbd_pipe = cuttlefish::SharedFD::Open (
91+ instance.restore_adbd_pipe_name ().c_str (), O_WRONLY);
92+ if (!restore_adbd_pipe->IsOpen ()) {
93+ LOG (ERROR) << " Error opening restore pipe: "
94+ << restore_adbd_pipe->StrError ();
95+ return 2 ;
96+ }
97+
98+ CHECK (cuttlefish::WriteAll (restore_pipe, " 1" ) == 1 )
99+ << " Error writing to restore pipe: " << restore_pipe->StrError ()
100+ << " . This is unrecoverable." ;
101+ CHECK (cuttlefish::WriteAll (restore_adbd_pipe, " 2" ) == 1 )
102+ << " Error writing to adbd restore pipe: "
103+ << restore_adbd_pipe->StrError () << " . This is unrecoverable." ;
104+ }
105+ }
79106 }
80107
81108 logcat_file->Close ();
0 commit comments