ext/common/Utils/ScopeGuard.h in passenger-5.0.4 vs ext/common/Utils/ScopeGuard.h in passenger-5.0.5
- old
+ new
@@ -1,8 +1,8 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
- * Copyright (c) 2010, 2011, 2012 Phusion
+ * Copyright (c) 2010-2015 Phusion
*
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,10 +28,11 @@
#include <boost/noncopyable.hpp>
#include <boost/function.hpp>
#include <boost/thread.hpp>
#include <oxt/system_calls.hpp>
#include <cstdio>
+#include <Logging.h>
namespace Passenger {
using namespace boost;
using namespace oxt;
@@ -97,16 +98,21 @@
public:
StdioGuard()
: f(0)
{ }
- StdioGuard(FILE *_f)
+ StdioGuard(FILE *_f, const char *file, unsigned int line)
: f(_f)
- { }
+ {
+ if (_f != NULL && file != NULL) {
+ P_LOG_FILE_DESCRIPTOR_OPEN3(fileno(_f), file, line);
+ }
+ }
~StdioGuard() {
if (f != NULL) {
+ P_LOG_FILE_DESCRIPTOR_CLOSE(fileno(f));
fclose(f);
}
}
};
@@ -114,17 +120,22 @@
private:
int fd;
bool ignoreErrors;
public:
- FdGuard(int _fd, bool _ignoreErrors = false)
+ FdGuard(int _fd, const char *file, unsigned int line, bool _ignoreErrors = false)
: fd(_fd),
ignoreErrors(_ignoreErrors)
- { }
+ {
+ if (_fd != -1 && file != NULL) {
+ P_LOG_FILE_DESCRIPTOR_OPEN3(_fd, file, line);
+ }
+ }
~FdGuard() {
if (fd != -1) {
safelyClose(fd, ignoreErrors);
+ P_LOG_FILE_DESCRIPTOR_CLOSE(fd);
}
}
void clear() {
fd = -1;