Skip to content

Commit 20b9e7d

Browse files
committed
workshop/{Operator,Workplace} use SOCK_SEQPACKET for return_{pidfd,cgroup}
Closing the other side of a SOCK_DGRAM does not finish waiting recvmsg() calls.
1 parent 04ba15b commit 20b9e7d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

debian/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cm4all-workshop (6.9) unstable; urgency=low
22

33
* spawn: fix assertion failure with large payloads
4+
* spawn: fix hanging main process after spawner failure
45
* translation: add packet REAL_UID_GID
56
* switch to C++23
67
* require Meson 1.2

src/workshop/Operator.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ DoSpawn(SpawnService &service, AllocatorPtr alloc,
289289
p.stderr_fd = p.stdout_fd = stderr_w;
290290

291291
UniqueSocketDescriptor return_pidfd;
292-
std::tie(return_pidfd, p.return_pidfd) = CreateSocketPair(SOCK_DGRAM);
292+
std::tie(return_pidfd, p.return_pidfd) = CreateSocketPair(SOCK_SEQPACKET);
293293

294294
for (const char *arg : response.args) {
295295
if (p.args.size() >= 4096)

src/workshop/Workplace.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ WorkshopWorkplace::Start(EventLoop &event_loop, const WorkshopJob &job,
162162
if (client->SupportsCgroups()) {
163163
cgroup.name = job.plan_name.c_str();
164164

165-
std::tie(return_cgroup, p.return_cgroup) = CreateSocketPair(SOCK_DGRAM);
165+
std::tie(return_cgroup, p.return_cgroup) = CreateSocketPair(SOCK_SEQPACKET);
166166
}
167167
}
168168

@@ -218,6 +218,13 @@ WorkshopWorkplace::Start(EventLoop &event_loop, const WorkshopJob &job,
218218
"') started");
219219

220220
if (return_cgroup.IsDefined()) {
221+
/* close the other side of the socketpair if it's
222+
still open to avoid blocking the following receive
223+
call if the spawner has closed the socket without
224+
sending something */
225+
if (p.return_cgroup.IsDefined())
226+
p.return_cgroup.Close();
227+
221228
try {
222229
o->SetCgroup(EasyReceiveMessageWithOneFD(return_cgroup));
223230
} catch (...) {

0 commit comments

Comments
 (0)