src: Handle exception in main
This commit is contained in:
parent
5d002ff6ca
commit
5594e3df25
|
@ -455,4 +455,15 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
||||||
int main(int argc, char **argv) { return nghttp2::main(argc, argv); }
|
int main(int argc, char **argv) {
|
||||||
|
try {
|
||||||
|
return nghttp2::main(argc, argv);
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
fputs("Out of memory\n", stderr);
|
||||||
|
} catch (std::exception &x) {
|
||||||
|
fputs("Exception caught: ", stderr);
|
||||||
|
fputs(x.what(), stderr);
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ extern "C" {
|
||||||
#include "comp_helper.h"
|
#include "comp_helper.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace nghttp2 {
|
||||||
|
|
||||||
typedef struct { int dump_header_table; } inflate_config;
|
typedef struct { int dump_header_table; } inflate_config;
|
||||||
|
|
||||||
static inflate_config config;
|
static inflate_config config;
|
||||||
|
@ -275,3 +277,18 @@ int main(int argc, char **argv) {
|
||||||
perform();
|
perform();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace nghttp2
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
try {
|
||||||
|
return nghttp2::main(argc, argv);
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
fputs("Out of memory\n", stderr);
|
||||||
|
} catch (std::exception &x) {
|
||||||
|
fputs("Exception caught: ", stderr);
|
||||||
|
fputs(x.what(), stderr);
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
|
@ -2713,4 +2713,15 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
||||||
int main(int argc, char **argv) { return nghttp2::main(argc, argv); }
|
int main(int argc, char **argv) {
|
||||||
|
try {
|
||||||
|
return nghttp2::main(argc, argv);
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
fputs("Out of memory\n", stderr);
|
||||||
|
} catch (std::exception &x) {
|
||||||
|
fputs("Exception caught: ", stderr);
|
||||||
|
fputs(x.what(), stderr);
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
|
@ -383,4 +383,15 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
||||||
int main(int argc, char **argv) { return nghttp2::main(argc, argv); }
|
int main(int argc, char **argv) {
|
||||||
|
try {
|
||||||
|
return nghttp2::main(argc, argv);
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
fputs("Out of memory\n", stderr);
|
||||||
|
} catch (std::exception &x) {
|
||||||
|
fputs("Exception caught: ", stderr);
|
||||||
|
fputs(x.what(), stderr);
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
13
src/shrpx.cc
13
src/shrpx.cc
|
@ -2551,4 +2551,15 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
||||||
int main(int argc, char **argv) { return shrpx::main(argc, argv); }
|
int main(int argc, char **argv) {
|
||||||
|
try {
|
||||||
|
return shrpx::main(argc, argv);
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
fputs("Out of memory\n", stderr);
|
||||||
|
} catch (std::exception &x) {
|
||||||
|
fputs("Exception caught: ", stderr);
|
||||||
|
fputs(x.what(), stderr);
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
|
@ -37,48 +37,51 @@
|
||||||
#include "shrpx_log_config.h"
|
#include "shrpx_log_config.h"
|
||||||
#include "ssl.h"
|
#include "ssl.h"
|
||||||
|
|
||||||
namespace shrpx {
|
|
||||||
|
|
||||||
class Downstream;
|
|
||||||
|
|
||||||
#define ENABLE_LOG 1
|
#define ENABLE_LOG 1
|
||||||
|
|
||||||
#define LOG_ENABLED(SEVERITY) (ENABLE_LOG && Log::log_enabled(SEVERITY))
|
#define LOG_ENABLED(SEVERITY) (ENABLE_LOG && shrpx::Log::log_enabled(SEVERITY))
|
||||||
|
|
||||||
#define LOG(SEVERITY) Log(SEVERITY, __FILE__, __LINE__)
|
#define LOG(SEVERITY) shrpx::Log(SEVERITY, __FILE__, __LINE__)
|
||||||
|
|
||||||
// Listener log
|
// Listener log
|
||||||
#define LLOG(SEVERITY, LISTEN) \
|
#define LLOG(SEVERITY, LISTEN) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[LISTEN:" << LISTEN << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[LISTEN:" << LISTEN << "] ")
|
||||||
|
|
||||||
// Worker log
|
// Worker log
|
||||||
#define WLOG(SEVERITY, WORKER) \
|
#define WLOG(SEVERITY, WORKER) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[WORKER:" << WORKER << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[WORKER:" << WORKER << "] ")
|
||||||
|
|
||||||
// ClientHandler log
|
// ClientHandler log
|
||||||
#define CLOG(SEVERITY, CLIENT_HANDLER) \
|
#define CLOG(SEVERITY, CLIENT_HANDLER) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[CLIENT_HANDLER:" << CLIENT_HANDLER \
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) \
|
||||||
<< "] ")
|
<< "[CLIENT_HANDLER:" << CLIENT_HANDLER << "] ")
|
||||||
|
|
||||||
// Upstream log
|
// Upstream log
|
||||||
#define ULOG(SEVERITY, UPSTREAM) \
|
#define ULOG(SEVERITY, UPSTREAM) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[UPSTREAM:" << UPSTREAM << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[UPSTREAM:" << UPSTREAM \
|
||||||
|
<< "]" \
|
||||||
|
" ")
|
||||||
|
|
||||||
// Downstream log
|
// Downstream log
|
||||||
#define DLOG(SEVERITY, DOWNSTREAM) \
|
#define DLOG(SEVERITY, DOWNSTREAM) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[DOWNSTREAM:" << DOWNSTREAM << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[DOWNSTREAM:" << DOWNSTREAM \
|
||||||
|
<< "] ")
|
||||||
|
|
||||||
// Downstream connection log
|
// Downstream connection log
|
||||||
#define DCLOG(SEVERITY, DCONN) \
|
#define DCLOG(SEVERITY, DCONN) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[DCONN:" << DCONN << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[DCONN:" << DCONN << "] ")
|
||||||
|
|
||||||
// Downstream HTTP2 session log
|
// Downstream HTTP2 session log
|
||||||
#define SSLOG(SEVERITY, HTTP2) \
|
#define SSLOG(SEVERITY, HTTP2) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[DHTTP2:" << HTTP2 << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[DHTTP2:" << HTTP2 << "] ")
|
||||||
|
|
||||||
// Memcached connection log
|
// Memcached connection log
|
||||||
#define MCLOG(SEVERITY, MCONN) \
|
#define MCLOG(SEVERITY, MCONN) \
|
||||||
(Log(SEVERITY, __FILE__, __LINE__) << "[MCONN:" << MCONN << "] ")
|
(shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[MCONN:" << MCONN << "] ")
|
||||||
|
|
||||||
|
namespace shrpx {
|
||||||
|
|
||||||
|
class Downstream;
|
||||||
|
|
||||||
enum SeverityLevel { INFO, NOTICE, WARN, ERROR, FATAL };
|
enum SeverityLevel { INFO, NOTICE, WARN, ERROR, FATAL };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue