Skip to content

Commit

Permalink
Rename: kj::AutoCloseFd -> kj::OwnFd
Browse files Browse the repository at this point in the history
  • Loading branch information
kentonv committed Dec 24, 2024
1 parent baa362d commit b3454c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/workerd/server/workerd.c++
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ class FileWatcher {
}

private:
kj::AutoCloseFd inotifyFd;
kj::OwnFd inotifyFd;
kj::UnixEventPort::FdObserver observer;

kj::HashMap<kj::String, int> watches;
kj::HashMap<int, kj::HashSet<kj::String>> filesWatched;

static kj::AutoCloseFd makeInotify() {
static kj::OwnFd makeInotify() {
return KJ_SYSCALL_FD(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
}
};
Expand Down Expand Up @@ -264,17 +264,17 @@ class FileWatcher {
}

private:
kj::AutoCloseFd kqueueFd;
kj::OwnFd kqueueFd;
kj::UnixEventPort::FdObserver observer;
kj::Vector<kj::AutoCloseFd> filesWatched;
kj::Vector<kj::OwnFd> filesWatched;

static kj::AutoCloseFd makeKqueue() {
static kj::OwnFd makeKqueue() {
auto fd = KJ_SYSCALL_FD(kqueue());
KJ_SYSCALL(fcntl(fd, F_SETFD, FD_CLOEXEC));
return kj::mv(fd);
}

void watchFd(kj::AutoCloseFd fd) {
void watchFd(kj::OwnFd fd) {
KJ_SYSCALL(fcntl(fd, F_SETFD, FD_CLOEXEC));

struct kevent change;
Expand Down Expand Up @@ -1439,7 +1439,7 @@ class CliMain final: public SchemaFileImpl::ErrorReporter {
if (fd < 0) {
return kj::none;
}
return ExeInfo{kj::str(path), kj::newDiskFile(kj::AutoCloseFd(fd))};
return ExeInfo{kj::str(path), kj::newDiskFile(kj::OwnFd(fd))};
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/workerd/util/perfetto-tracing.c++
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ PERFETTO_TRACK_EVENT_STATIC_STORAGE_IN_NAMESPACE(workerd::traces);

namespace workerd {
namespace {
kj::AutoCloseFd openTraceFile(kj::StringPtr path) {
kj::OwnFd openTraceFile(kj::StringPtr path) {
int fd = open(path.cStr(), O_RDWR | O_CREAT | O_TRUNC, 0600);
KJ_REQUIRE(fd >= 0, "Unable to open tracing file");
return kj::AutoCloseFd(fd);
return kj::OwnFd(fd);
}

void initializePerfettoOnce() {
Expand Down Expand Up @@ -79,10 +79,10 @@ kj::Array<kj::ArrayPtr<const char>> PerfettoSession::parseCategories(kj::StringP
}

struct PerfettoSession::Impl {
kj::AutoCloseFd fd;
kj::OwnFd fd;
std::unique_ptr<perfetto::TracingSession> session;

Impl(kj::AutoCloseFd dest, kj::StringPtr categories)
Impl(kj::OwnFd dest, kj::StringPtr categories)
: fd(kj::mv(dest)),
session(createTracingSession(fd.get(), categories)) {
session->StartBlocking();
Expand All @@ -93,7 +93,7 @@ PerfettoSession::PerfettoSession(kj::StringPtr path, kj::StringPtr categories)
: impl(kj::heap<Impl>(openTraceFile(path), categories)) {}

PerfettoSession::PerfettoSession(int fd, kj::StringPtr categories)
: impl(kj::heap<Impl>(kj::AutoCloseFd(fd), categories)) {}
: impl(kj::heap<Impl>(kj::OwnFd(fd), categories)) {}

PerfettoSession::~PerfettoSession() noexcept(false) {
if (impl) {
Expand Down

0 comments on commit b3454c2

Please sign in to comment.