team-ljyzipelo

공개
761줄26 KB
1use crate::archive_ui as ui;
2use std::{
3 cell::RefCell,
4 io::{self, Read, Write},
5 path::PathBuf,
6 process::{Command, Stdio},
7 rc::Rc,
8 sync::{
9 Arc, Mutex,
10 atomic::{AtomicBool, Ordering},
11 mpsc::{self, Receiver, SyncSender},
12 },
13 thread::{self, JoinHandle},
14 time::{Duration, Instant},
15};
16use worker_protocol::{protocol as wire, wire as codec};
17
18macro_rules! convert_enum {
19 ($name:ident, $from:ty, $to:ty, $($variant:ident),+) => {
20 fn $name(value: $from) -> $to {
21 match value { $(<$from>::$variant => <$to>::$variant),+ }
22 }
23 };
24}
25convert_enum!(
26 format_to_wire,
27 ui::Format,
28 wire::Format,
29 Zip,
30 Tar,
31 Gzip,
32 TarGzip,
33 SevenZip
34);
35convert_enum!(
36 format_to_ui,
37 wire::Format,
38 ui::Format,
39 Zip,
40 Tar,
41 Gzip,
42 TarGzip,
43 SevenZip
44);
45convert_enum!(
46 kind_to_ui,
47 wire::EntryKind,
48 ui::Kind,
49 File,
50 Directory,
51 Link,
52 Other
53);
54convert_enum!(
55 stage_to_ui,
56 wire::Stage,
57 ui::Stage,
58 Scan,
59 Read,
60 Decode,
61 Write,
62 Verify,
63 Commit
64);
65convert_enum!(
66 disposition_to_ui,
67 wire::Disposition,
68 ui::Disposition,
69 Created,
70 PartialRetained,
71 Removed,
72 CommitUncertain
73);
74convert_enum!(
75 outcome_to_ui,
76 wire::Outcome,
77 ui::Outcome,
78 Completed,
79 Failed,
80 Cancelled
81);
82convert_enum!(
83 publication_to_ui,
84 wire::Publication,
85 ui::Publication,
86 None,
87 Partial,
88 Complete,
89 Uncertain
90);
91convert_enum!(
92 durability_to_ui,
93 wire::Durability,
94 ui::Durability,
95 NotApplicable,
96 Synced,
97 Unconfirmed,
98 Failed
99);
100convert_enum!(
101 cleanup_to_ui,
102 wire::Cleanup,
103 ui::Cleanup,
104 Complete,
105 Failed,
106 Unconfirmed
107);
108convert_enum!(
109 cancel_to_ui,
110 wire::CancelStatus,
111 ui::CancelStatus,
112 Requested,
113 AlreadyRequested,
114 TooLate,
115 Finished
116);
117fn list_to_wire(id: ui::ListId) -> wire::ListId {
118 wire::ListId {
119 catalog_version: id.catalog_version,
120 format: format_to_wire(id.format),
121 source_object: match id.source_object {
122 ui::SourceObject::Unix { device, inode } => wire::SourceObject::Unix { device, inode },
123 ui::SourceObject::Windows { volume, file_id } => wire::SourceObject::Windows {
124 volume_serial: volume,
125 file_id,
126 },
127 },
128 archive_bytes: id.archive_bytes,
129 archive_sha256: id.archive_sha256,
130 }
131}
132fn list_to_ui(id: wire::ListId) -> ui::ListId {
133 ui::ListId {
134 catalog_version: id.catalog_version,
135 format: format_to_ui(id.format),
136 source_object: match id.source_object {
137 wire::SourceObject::Unix { device, inode } => ui::SourceObject::Unix { device, inode },
138 wire::SourceObject::Windows {
139 volume_serial,
140 file_id,
141 } => ui::SourceObject::Windows {
142 volume: volume_serial,
143 file_id,
144 },
145 },
146 archive_bytes: id.archive_bytes,
147 archive_sha256: id.archive_sha256,
148 }
149}
150fn start_to_wire(start: ui::Start) -> wire::Start {
151 let action = match start {
152 ui::Start::List { archive } => wire::Action::List {
153 archive: wire::NativePath::from_path(&crate::archive_path::worker_path(&archive)),
154 },
155 ui::Start::Extract {
156 archive,
157 destination,
158 selection,
159 list_id,
160 gzip_output_name,
161 } => wire::Action::Extract {
162 archive: wire::NativePath::from_path(&crate::archive_path::worker_path(&archive)),
163 destination: wire::NativePath::from_path(&crate::archive_path::worker_path(
164 &destination,
165 )),
166 selection: match selection {
167 ui::Selection::All => wire::Selection::All,
168 ui::Selection::EntryIds(ids) => wire::Selection::EntryIds(ids),
169 },
170 list_id: Some(list_to_wire(list_id)),
171 gzip_output_name,
172 },
173 ui::Start::CreateZip {
174 sources,
175 output_file,
176 method,
177 aes256,
178 } => wire::Action::CreateZip {
179 sources: sources
180 .into_iter()
181 .map(|(path, archive_name)| wire::Source {
182 path: wire::NativePath::from_path(&crate::archive_path::worker_path(&path)),
183 archive_name,
184 })
185 .collect(),
186 output_file: wire::NativePath::from_path(&crate::archive_path::worker_path(
187 &output_file,
188 )),
189 method: match method {
190 ui::Method::Store => wire::Method::Store,
191 ui::Method::Deflate => wire::Method::Deflate,
192 },
193 encryption: if aes256 {
194 wire::Encryption::Aes256
195 } else {
196 wire::Encryption::None
197 },
198 },
199 };
200 wire::Start {
201 action,
202 limits: wire::Limits::default(),
203 }
204}
205fn error_to_ui(error: wire::ErrorCode) -> Option<ui::ErrorCode> {
206 Some(match error {
207 wire::ErrorCode::None => return None,
208 wire::ErrorCode::Integrity => ui::ErrorCode::Integrity,
209 wire::ErrorCode::UnsupportedFormat => ui::ErrorCode::UnsupportedFormat,
210 wire::ErrorCode::UnsupportedFeature => ui::ErrorCode::UnsupportedFeature,
211 wire::ErrorCode::WrongPassword => ui::ErrorCode::WrongPassword,
212 wire::ErrorCode::UnsafePath => ui::ErrorCode::UnsafePath,
213 wire::ErrorCode::Conflict => ui::ErrorCode::Conflict,
214 wire::ErrorCode::Limit => ui::ErrorCode::Limit,
215 wire::ErrorCode::Io => ui::ErrorCode::Io,
216 wire::ErrorCode::DiskFull => ui::ErrorCode::DiskFull,
217 wire::ErrorCode::Protocol => ui::ErrorCode::Protocol,
218 wire::ErrorCode::Internal => ui::ErrorCode::Internal,
219 wire::ErrorCode::SourceChanged => ui::ErrorCode::SourceChanged,
220 wire::ErrorCode::InvalidRequest => ui::ErrorCode::InvalidRequest,
221 })
222}
223fn event_to_ui(
224 message: wire::Message,
225 expected: Option<wire::ActionKind>,
226) -> Result<ui::Event, ()> {
227 Ok(match message {
228 wire::Message::Accepted { action, encryption } if expected == Some(action) => {
229 ui::Event::Accepted { encryption }
230 }
231 wire::Message::ResourceRequired {
232 challenge_id,
233 action,
234 scope,
235 usage,
236 soft_limits,
237 ceiling,
238 } if expected == Some(action) => ui::Event::ResourceRequired(ui::ResourceChallenge {
239 id: challenge_id,
240 action,
241 scope,
242 usage,
243 soft_limits,
244 ceiling,
245 }),
246 wire::Message::Entry(entry) => ui::Event::Entry(ui::Entry {
247 id: entry.entry_id,
248 name: entry.name,
249 kind: kind_to_ui(entry.kind),
250 bytes: Some(entry.size),
251 packed: Some(entry.compressed_size),
252 encrypted: entry.encrypted,
253 }),
254 wire::Message::ListEnd {
255 entry_count,
256 list_id,
257 } => ui::Event::ListEnd {
258 entry_count,
259 list_id: list_to_ui(list_id),
260 },
261 wire::Message::PasswordRequired {
262 challenge_id,
263 attempt,
264 purpose,
265 } => ui::Event::PasswordRequired {
266 challenge_id,
267 attempt,
268 encrypt: purpose == wire::PasswordPurpose::Encrypt,
269 },
270 wire::Message::Progress {
271 stage,
272 processed_bytes,
273 total_bytes,
274 completed_entries,
275 } => ui::Event::Progress {
276 stage: stage_to_ui(stage),
277 processed: processed_bytes,
278 total: total_bytes,
279 completed_entries: completed_entries.into(),
280 },
281 wire::Message::Output {
282 entry_id,
283 relative_name,
284 disposition,
285 } => ui::Event::Output {
286 entry_id,
287 relative_name,
288 disposition: disposition_to_ui(disposition),
289 },
290 wire::Message::CancelAck {
291 request_sequence,
292 status,
293 } => ui::Event::CancelAck {
294 request_sequence,
295 status: cancel_to_ui(status),
296 },
297 wire::Message::Terminal(terminal) => ui::Event::Terminal(ui::Terminal {
298 outcome: outcome_to_ui(terminal.outcome),
299 error: error_to_ui(terminal.error),
300 publication: publication_to_ui(terminal.publication),
301 created_count: terminal.created_count,
302 retained_partial_count: terminal.retained_partial_count,
303 durability: durability_to_ui(terminal.durability),
304 cleanup: cleanup_to_ui(terminal.cleanup),
305 }),
306 _ => return Err(()),
307 })
308}
309
310// 실제 파이프 쓰기는 백그라운드에서 수행하고 UI에서는 한 프레임만 직렬화함.
311#[derive(Clone, Default)]
312struct FrameBuffer(Rc<RefCell<Vec<u8>>>);
313impl Write for FrameBuffer {
314 fn write(&mut self, bytes: &[u8]) -> io::Result<usize> {
315 let mut buffer = self.0.borrow_mut();
316 if buffer.len().saturating_add(bytes.len()) > codec::MAX_BODY + 32 {
317 return Err(io::Error::other("요청 프레임 한도 초과"));
318 }
319 buffer.extend_from_slice(bytes);
320 Ok(bytes.len())
321 }
322 fn flush(&mut self) -> io::Result<()> {
323 Ok(())
324 }
325}
326struct Frame(Vec<u8>, bool);
327impl Drop for Frame {
328 fn drop(&mut self) {
329 self.0.fill(0);
330 }
331}
332fn notify(events: &SyncSender<ui::HostEvent>, event: ui::HostEvent) -> bool {
333 events.send(event).is_ok()
334}
335fn fault(events: &SyncSender<ui::HostEvent>, stop: &AtomicBool, message: &str) {
336 stop.store(true, Ordering::Release);
337 notify(events, ui::HostEvent::Fault(message.into()));
338}
339
340#[derive(Default)]
341struct ResourceDeadline {
342 pending: Option<(u64, wire::ResourceScope)>,
343 approved: bool,
344}
345
346pub struct ProcessFactory {
347 worker: PathBuf,
348}
349impl ProcessFactory {
350 pub fn new(worker: PathBuf) -> Self {
351 Self { worker }
352 }
353 pub fn sibling() -> Result<Self, String> {
354 let executable =
355 std::env::current_exe().map_err(|_| "앱 실행 위치를 확인하지 못했습니다")?;
356 let parent = executable.parent().ok_or("앱 실행 폴더가 없습니다")?;
357 Ok(Self::new(parent.join(if cfg!(windows) {
358 "zipelo-archive-worker.exe"
359 } else {
360 "zipelo-archive-worker"
361 })))
362 }
363}
364impl ui::Factory for ProcessFactory {
365 fn connect(&mut self, job_id: u64) -> Result<Box<dyn ui::Connection>, String> {
366 if !self.worker.is_absolute() || job_id == 0 {
367 return Err("작업자 경로 또는 작업 ID가 올바르지 않습니다".into());
368 }
369 let (send, requests) = mpsc::sync_channel::<Frame>(8);
370 let (events, receive) = mpsc::sync_channel(64);
371 let (ready, started) = mpsc::sync_channel(1);
372 let stop = Arc::new(AtomicBool::new(false));
373 let done = Arc::new(AtomicBool::new(false));
374 let expected = Arc::new(Mutex::new(None));
375 let resources = Arc::new(Mutex::new(ResourceDeadline::default()));
376 let worker = self.worker.clone();
377 let worker_stop = stop.clone();
378 let worker_done = done.clone();
379 let worker_expected = expected.clone();
380 let worker_resources = resources.clone();
381 let supervisor = thread::Builder::new()
382 .name("zipelo-worker-owner".into())
383 .spawn(move || {
384 let mut command = Command::new(worker);
385 command
386 .stdin(Stdio::piped())
387 .stdout(Stdio::piped())
388 .stderr(Stdio::piped());
389 #[cfg(windows)]
390 {
391 use std::os::windows::process::CommandExt;
392 command.creation_flags(0x08000000);
393 }
394 let child = match command.spawn() {
395 Ok(child) => child,
396 Err(_) => {
397 let _ = ready.send(Err(
398 "작업자를 실행하지 못했습니다. 앱과 작업자를 함께 설치하세요"
399 .to_string(),
400 ));
401 return;
402 }
403 };
404 if ready.send(Ok(())).is_err() {
405 let mut child = child;
406 let _ = child.kill();
407 let _ = child.wait();
408 return;
409 }
410 supervise(
411 child,
412 job_id,
413 requests,
414 events,
415 worker_stop,
416 worker_done,
417 worker_expected,
418 worker_resources,
419 );
420 })
421 .map_err(|_| "작업자 관리 스레드를 시작하지 못했습니다")?;
422 match started.recv() {
423 Ok(Ok(())) => {
424 let buffer = FrameBuffer::default();
425 Ok(Box::new(ProcessConnection {
426 job_id,
427 next: 0,
428 writer: codec::Writer::new(buffer.clone(), job_id),
429 buffer,
430 send: Some(send),
431 receive: Some(receive),
432 stop,
433 supervisor: Some(supervisor),
434 expected,
435 resources,
436 done,
437 disconnected: false,
438 reaped: false,
439 }))
440 }
441 result => {
442 stop.store(true, Ordering::Release);
443 drop(send);
444 drop(receive);
445 let _ = supervisor.join();
446 Err(result
447 .ok()
448 .and_then(Result::err)
449 .unwrap_or_else(|| "작업자 시작 결과가 없습니다".into()))
450 }
451 }
452 }
453}
454struct ProcessConnection {
455 job_id: u64,
456 next: u64,
457 writer: codec::Writer<FrameBuffer>,
458 buffer: FrameBuffer,
459 send: Option<SyncSender<Frame>>,
460 receive: Option<Receiver<ui::HostEvent>>,
461 stop: Arc<AtomicBool>,
462 supervisor: Option<JoinHandle<()>>,
463 expected: Arc<Mutex<Option<wire::ActionKind>>>,
464 resources: Arc<Mutex<ResourceDeadline>>,
465 done: Arc<AtomicBool>,
466 disconnected: bool,
467 reaped: bool,
468}
469impl ui::Connection for ProcessConnection {
470 fn send(&mut self, request: ui::Request) -> Result<(), String> {
471 if self.stop.load(Ordering::Acquire)
472 || request.job_id != self.job_id
473 || request.sequence != self.next
474 || self.next >= codec::MAX_FRAMES
475 {
476 self.stop.store(true, Ordering::Release);
477 return Err("작업자 요청 채널이 닫혔거나 순서가 올바르지 않습니다".into());
478 }
479 let is_cancel = matches!(request.command, ui::Command::Cancel);
480 let expanded = matches!(&request.command, ui::Command::StartExpanded(_));
481 let message = match request.command {
482 ui::Command::Start(start) | ui::Command::StartExpanded(start) => {
483 let start = start_to_wire(start);
484 *self.expected.lock().map_err(|_| {
485 self.stop.store(true, Ordering::Release);
486 "작업자 요청 상태 오류"
487 })? = Some(start.action.kind());
488 let ceiling = if expanded {
489 wire::Limits {
490 input: u64::MAX,
491 output: 64 * 1024 * 1024 * 1024,
492 entries: 200_000,
493 }
494 } else {
495 wire::Limits::default()
496 };
497 wire::Message::StartGuarded(wire::GuardedStart {
498 start,
499 ceiling,
500 interactive: false,
501 })
502 }
503 ui::Command::ResourceReply {
504 challenge_id,
505 scope,
506 allow,
507 } => wire::Message::ResourceReply {
508 challenge_id,
509 scope,
510 allow,
511 },
512 ui::Command::Cancel => wire::Message::Cancel,
513 ui::Command::Password {
514 challenge_id,
515 secret,
516 } => wire::Message::Password {
517 challenge_id,
518 secret: wire::Secret(secret.as_bytes().to_vec()),
519 },
520 };
521 if self.writer.send(&message).is_err() {
522 self.buffer.0.borrow_mut().fill(0);
523 self.buffer.0.borrow_mut().clear();
524 self.stop.store(true, Ordering::Release);
525 return Err("작업자 요청을 직렬화하지 못했습니다".into());
526 }
527 let mut resources = self.resources.lock().map_err(|_| {
528 self.stop.store(true, Ordering::Release);
529 "작업자 승인 상태 오류"
530 })?;
531 let bytes = Frame(std::mem::take(&mut *self.buffer.0.borrow_mut()), is_cancel);
532 if self.send.as_ref().unwrap().try_send(bytes).is_err() {
533 if is_cancel && self.done.load(Ordering::Acquire) {
534 self.next += 1;
535 return Ok(());
536 }
537 self.stop.store(true, Ordering::Release);
538 return Err("작업자 요청 대기열이 닫혔거나 가득 찼습니다".into());
539 }
540 if let wire::Message::ResourceReply {
541 challenge_id,
542 scope,
543 allow,
544 } = message
545 && resources.pending == Some((challenge_id, scope))
546 {
547 resources.approved |= allow;
548 resources.pending = None;
549 }
550 self.next += 1;
551 Ok(())
552 }
553 fn poll(&mut self) -> Option<ui::HostEvent> {
554 match self.receive.as_ref()?.try_recv() {
555 Ok(event) => {
556 if matches!(event, ui::HostEvent::Exited { .. }) {
557 self.reaped = true;
558 }
559 Some(event)
560 }
561 Err(mpsc::TryRecvError::Empty) => None,
562 Err(mpsc::TryRecvError::Disconnected) if !self.reaped && !self.disconnected => {
563 self.disconnected = true;
564 Some(ui::HostEvent::Fault(
565 "작업자 통신 스레드가 종료됐습니다".into(),
566 ))
567 }
568 Err(_) => None,
569 }
570 }
571}
572impl Drop for ProcessConnection {
573 fn drop(&mut self) {
574 self.stop.store(true, Ordering::Release);
575 self.send.take();
576 self.receive.take();
577 if let Some(supervisor) = self.supervisor.take() {
578 let _ = supervisor.join();
579 }
580 }
581}
582
583fn supervise(
584 mut child: std::process::Child,
585 job_id: u64,
586 requests: Receiver<Frame>,
587 events: SyncSender<ui::HostEvent>,
588 stop: Arc<AtomicBool>,
589 done: Arc<AtomicBool>,
590 expected: Arc<Mutex<Option<wire::ActionKind>>>,
591 resources: Arc<Mutex<ResourceDeadline>>,
592) {
593 let mut input = child.stdin.take().unwrap();
594 let mut output = child.stdout.take().unwrap();
595 let mut errors = child.stderr.take().unwrap();
596 let mut threads = Vec::new();
597 let cancel_write_failed = Arc::new(AtomicBool::new(false));
598 let terminal_received = Arc::new(AtomicBool::new(false));
599 let failed_cancel = cancel_write_failed.clone();
600 let tx = events.clone();
601 let abort = stop.clone();
602 let finished = done.clone();
603 threads.push(
604 thread::Builder::new()
605 .name("zipelo-worker-input".into())
606 .spawn(move || {
607 while !finished.load(Ordering::Acquire) && !abort.load(Ordering::Acquire) {
608 match requests.recv_timeout(Duration::from_millis(10)) {
609 Ok(frame) => {
610 if input
611 .write_all(&frame.0)
612 .and_then(|_| input.flush())
613 .is_err()
614 {
615 if frame.1 {
616 // 취소 쓰기 실패는 응답과 실제 종료 결과를 확인한 뒤 판단함.
617 failed_cancel.store(true, Ordering::Release);
618 } else {
619 fault(&tx, &abort, "작업자 요청 파이프 쓰기에 실패했습니다");
620 }
621 break;
622 }
623 }
624 Err(mpsc::RecvTimeoutError::Timeout) => {}
625 Err(_) => break,
626 }
627 }
628 }),
629 );
630 let tx = events.clone();
631 let abort = stop.clone();
632 let received_terminal = terminal_received.clone();
633 let pending_resource = resources.clone();
634 threads.push(
635 thread::Builder::new()
636 .name("zipelo-worker-output".into())
637 .spawn(move || {
638 let eof;
639 {
640 let mut reader = codec::Reader::new(&mut output);
641 eof = loop {
642 match reader.read() {
643 Ok(Some((job, sequence, message))) => {
644 let action = expected.lock().ok().and_then(|value| *value);
645 let event = event_to_ui(message, action);
646 if job != job_id || event.is_err() {
647 fault(&tx, &abort, "작업자 응답이 요청과 일치하지 않습니다");
648 break false;
649 }
650 if let Ok(ui::Event::ResourceRequired(question)) = &event {
651 if let Ok(mut state) = pending_resource.lock() {
652 state.pending = Some((question.id, question.scope));
653 } else {
654 fault(&tx, &abort, "작업자 승인 상태 오류");
655 break false;
656 }
657 }
658 if matches!(event, Ok(ui::Event::Terminal(_))) {
659 received_terminal.store(true, Ordering::Release);
660 }
661 if !notify(
662 &tx,
663 ui::HostEvent::Frame {
664 job_id: job,
665 sequence,
666 event: event.unwrap(),
667 },
668 ) {
669 return;
670 }
671 }
672 Ok(None) => break true,
673 Err(_) => {
674 fault(&tx, &abort, "작업자 응답 프레임을 읽지 못했습니다");
675 break false;
676 }
677 }
678 };
679 }
680 if eof || io::copy(&mut output, &mut io::sink()).is_ok() {
681 notify(&tx, ui::HostEvent::StdoutEof);
682 }
683 }),
684 );
685 let tx = events.clone();
686 let abort = stop.clone();
687 threads.push(
688 thread::Builder::new()
689 .name("zipelo-worker-errors".into())
690 .spawn(move || {
691 let mut bytes = [0u8; 4096];
692 loop {
693 match errors.read(&mut bytes) {
694 Ok(0) => {
695 notify(&tx, ui::HostEvent::StderrEof);
696 break;
697 }
698 Ok(_) => {}
699 Err(error) if error.kind() == io::ErrorKind::Interrupted => {}
700 Err(_) => {
701 fault(&tx, &abort, "작업자 오류 파이프를 읽지 못했습니다");
702 break;
703 }
704 }
705 }
706 }),
707 );
708 let mut handles = Vec::new();
709 for result in threads {
710 match result {
711 Ok(handle) => handles.push(handle),
712 Err(_) => fault(&events, &stop, "작업자 통신 스레드를 시작하지 못했습니다"),
713 }
714 }
715 let started = Instant::now();
716 let status = loop {
717 // 승인 뒤 실제 진행과 질문 대기 시간은 작업자의 60초 정체 감시로 판단함.
718 // 응답 프레임 간격을 실제 파일 처리 진행으로 간주하지 않음.
719 let approved = resources
720 .lock()
721 .map(|state| state.approved)
722 .unwrap_or(false);
723 if !approved && started.elapsed() >= Duration::from_secs(310) {
724 fault(&events, &stop, "작업자 처리 제한 시간을 초과했습니다");
725 }
726 if stop.load(Ordering::Acquire) {
727 let _ = child.kill();
728 }
729 match child.try_wait() {
730 Ok(Some(status)) => break Some(status),
731 Ok(None) => thread::sleep(Duration::from_millis(10)),
732 Err(_) => {
733 fault(&events, &stop, "작업자 종료 상태를 확인하지 못했습니다");
734 let _ = child.kill();
735 break child.wait().ok();
736 }
737 }
738 };
739 done.store(true, Ordering::Release);
740 for handle in handles {
741 if handle.join().is_err() {
742 fault(&events, &stop, "작업자 통신 스레드 회수에 실패했습니다");
743 }
744 }
745 if cancel_write_failed.load(Ordering::Acquire)
746 && !(terminal_received.load(Ordering::Acquire)
747 && status.as_ref().is_some_and(|status| status.success()))
748 {
749 fault(&events, &stop, "작업자 요청 파이프 쓰기에 실패했습니다");
750 }
751 if let Some(status) = status {
752 // 회수와 모든 파이프 핸들 정리가 끝난 뒤에만 닫기 허용 근거를 전달함.
753 notify(&events, ui::HostEvent::CleanupComplete);
754 notify(
755 &events,
756 ui::HostEvent::Exited {
757 success: status.success(),
758 },
759 );
760 }
761}