Skip to content

Commit f0fbf13

Browse files
committed
rename ExecCommand to Edge
1 parent 90fcc59 commit f0fbf13

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/exec/use_pty/backchannel.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -199,31 +199,31 @@ impl AsFd for ParentBackchannel {
199199
/// Different messages exchanged between the monitor and the parent process using a [`ParentBackchannel`].
200200
#[derive(PartialEq, Eq)]
201201
pub(super) enum MonitorMessage {
202-
ExecCommand,
202+
Edge,
203203
Signal(c_int),
204204
}
205205

206206
impl MonitorMessage {
207207
const LEN: usize = PREFIX_LEN + MONITOR_DATA_LEN;
208-
const EXEC_CMD: Prefix = 0;
208+
const EDGE_CMD: Prefix = 0;
209209
const SIGNAL: Prefix = 1;
210210

211211
fn from_parts(prefix: Prefix, data: MonitorData) -> Self {
212212
match prefix {
213-
Self::EXEC_CMD => Self::ExecCommand,
213+
Self::EDGE_CMD => Self::Edge,
214214
Self::SIGNAL => Self::Signal(data),
215215
_ => unreachable!(),
216216
}
217217
}
218218

219219
fn to_parts(&self) -> (Prefix, MonitorData) {
220220
let prefix = match self {
221-
MonitorMessage::ExecCommand => Self::EXEC_CMD,
221+
MonitorMessage::Edge => Self::EDGE_CMD,
222222
MonitorMessage::Signal(_) => Self::SIGNAL,
223223
};
224224

225225
let data = match self {
226-
MonitorMessage::ExecCommand => 0,
226+
MonitorMessage::Edge => 0,
227227
MonitorMessage::Signal(data) => *data,
228228
};
229229

@@ -234,7 +234,7 @@ impl MonitorMessage {
234234
impl std::fmt::Debug for MonitorMessage {
235235
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
236236
match self {
237-
Self::ExecCommand => "ExecCommand".fmt(f),
237+
Self::Edge => "Edge".fmt(f),
238238
&Self::Signal(signal) => write!(f, "Signal({})", signal_fmt(signal)),
239239
}
240240
}

src/exec/use_pty/monitor.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub(super) fn exec_monitor(
8080
err
8181
})?;
8282
// Given that `UnixStream` delivers messages in order it shouldn't be possible to
83-
// receive an event different to `ExecCommand` at the beginning.
84-
debug_assert_eq!(event, MonitorMessage::ExecCommand);
83+
// receive an event different to `Edge` at the beginning.
84+
debug_assert_eq!(event, MonitorMessage::Edge);
8585

8686
// FIXME (ogsudo): Some extra config happens here if selinux is available.
8787

@@ -188,7 +188,7 @@ pub(super) fn exec_monitor(
188188
dev_warn!("cannot receive red light from parent: {err}");
189189
err
190190
})?;
191-
debug_assert_eq!(event, MonitorMessage::ExecCommand);
191+
debug_assert_eq!(event, MonitorMessage::Edge);
192192

193193
// FIXME (ogsudo): The tty is restored here if selinux is available.
194194

@@ -332,8 +332,8 @@ impl<'a> MonitorClosure<'a> {
332332
}
333333
Ok(event) => {
334334
match event {
335-
// We shouldn't receive this event more than once.
336-
MonitorMessage::ExecCommand => unreachable!(),
335+
// We shouldn't receive this event at this point in the protocol
336+
MonitorMessage::Edge => unreachable!(),
337337
// Forward signal to the command.
338338
MonitorMessage::Signal(signal) => {
339339
if let Some(command_pid) = self.command_pid {

src/exec/use_pty/parent.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,10 @@ pub(in crate::exec) fn exec_pty(
211211
drop(backchannels.monitor);
212212

213213
// Send green light to the monitor after closing the follower.
214-
retry_while_interrupted(|| backchannels.parent.send(&MonitorMessage::ExecCommand)).map_err(
215-
|err| {
216-
dev_error!("cannot send green light to monitor: {err}");
217-
err
218-
},
219-
)?;
214+
retry_while_interrupted(|| backchannels.parent.send(&MonitorMessage::Edge)).map_err(|err| {
215+
dev_error!("cannot send green light to monitor: {err}");
216+
err
217+
})?;
220218

221219
let mut closure = ParentClosure::new(
222220
monitor_pid,
@@ -358,7 +356,7 @@ impl ParentClosure {
358356
StopReason::Exit(ParentExit::Command(exit_reason)) => Ok(exit_reason),
359357
};
360358
// Send red light to the monitor after processing all events
361-
retry_while_interrupted(|| self.backchannel.send(&MonitorMessage::ExecCommand)).map_err(
359+
retry_while_interrupted(|| self.backchannel.send(&MonitorMessage::Edge)).map_err(
362360
|err| {
363361
dev_error!("cannot send red light to monitor: {err}");
364362
err

0 commit comments

Comments
 (0)