Skip to content

Commit 9f1f01d

Browse files
committed
Don't require a FIFO to be identifiable as such
The jobserver specification [0] currently suggests that the FIFO must be a genuine FIFO. For some work we're doing [1][2], we're emulating a FIFO using CUSE/FUSE to allow tracking when consumers disappear to avoid lost tokens. nixos had a similar idea in the past too [3]. There doesn't seem to be a good reason to check that any FIFO passed by the user is actually identifiable as such by `stat()`, so drop the check. make already does not perform such a check, just the specification isn't clear about it, so we've asked them to clarify it [4]. [0] https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html [1] https://codeberg.org/amonakov/guildmaster [2] https://gitweb.gentoo.org/proj/steve.git/ [3] NixOS/nixpkgs#314888 [4] https://savannah.gnu.org/bugs/index.php?67726
1 parent 231db65 commit 9f1f01d

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

src/jobserver-posix.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626

2727
namespace {
2828

29-
// Return true if |fd| is a fifo or pipe descriptor.
30-
bool IsFifoDescriptor(int fd) {
31-
struct stat info;
32-
int ret = ::fstat(fd, &info);
33-
return (ret == 0) && ((info.st_mode & S_IFMT) == S_IFIFO);
34-
}
35-
3629
// Implementation of Jobserver::Client for Posix systems
3730
class PosixJobserverClient : public Jobserver::Client {
3831
public:
@@ -89,11 +82,6 @@ class PosixJobserverClient : public Jobserver::Client {
8982
std::string("Error opening fifo for reading: ") + strerror(errno);
9083
return false;
9184
}
92-
if (!IsFifoDescriptor(read_fd_)) {
93-
*error = "Not a fifo path: " + fifo_path;
94-
// Let destructor close read_fd_.
95-
return false;
96-
}
9785
write_fd_ = ::open(fifo_path.c_str(), O_WRONLY | O_NONBLOCK | O_CLOEXEC);
9886
if (write_fd_ < 0) {
9987
*error =

src/jobserver_test.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,13 @@ TEST(Jobserver, PosixFifoClientWithWrongPath) {
379379
ASSERT_GE(fd, 0) << "Could not create file: " << strerror(errno);
380380
::close(fd);
381381

382-
// Create new client instance, passing the file path for the fifo.
382+
// Create new client instance, with an empty file path.
383383
Jobserver::Config config;
384384
config.mode = Jobserver::Config::kModePosixFifo;
385-
config.path = file_path;
386-
387385
std::string error;
388386
std::unique_ptr<Jobserver::Client> client =
389387
Jobserver::Client::Create(config, &error);
390-
EXPECT_FALSE(client.get());
391-
EXPECT_FALSE(error.empty());
392-
EXPECT_EQ("Not a fifo path: " + file_path, error);
393388

394-
// Do the same with an empty file path.
395-
error.clear();
396-
config.path.clear();
397389
client = Jobserver::Client::Create(config, &error);
398390
EXPECT_FALSE(client.get());
399391
EXPECT_FALSE(error.empty());

0 commit comments

Comments
 (0)