diff --git a/event.c b/event.c index acad5bdc..414f8888 100644 --- a/event.c +++ b/event.c @@ -529,7 +529,7 @@ int event_queue_add_file_monitor(int eq, char *filename, int *id) { int fd = open(filename, O_RDONLY); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(filename); return -1; } diff --git a/lock.c b/lock.c index 070179d1..8a25cea7 100644 --- a/lock.c +++ b/lock.c @@ -146,7 +146,7 @@ void uwsgi_lock_init(void *lock) { int fd = open(filename, O_CREAT|O_RDWR|O_TRUNC); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(filename); exit(1); } diff --git a/plugins/psgi/psgi_plugin.c b/plugins/psgi/psgi_plugin.c index 661d83d3..95ea9e4b 100644 --- a/plugins/psgi/psgi_plugin.c +++ b/plugins/psgi/psgi_plugin.c @@ -102,7 +102,7 @@ void uwsgi_psgi_app() { if (uperl.psgi) { uperl.fd = open(uperl.psgi, O_RDONLY); if (uperl.fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(uperl.psgi); exit(1); } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 5ef1a070..9564281e 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -196,7 +196,7 @@ PyObject *uwsgi_pyimport_by_filename(char *name, char *filename) { real_filename = uwsgi_concat2(filename, "/__init__.py"); pyfile = fopen(real_filename, "r"); if (!pyfile) { - uwsgi_error("fopen()"); + uwsgi_error_open(real_filename); exit(1); } } diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index 8c9823fa..8b4aa75f 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -2087,7 +2087,7 @@ PyObject *py_uwsgi_parse_file(PyObject * self, PyObject * args) { fd = open(filename, O_RDONLY); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(filename); goto clear; } diff --git a/spooler.c b/spooler.c index 16d976ee..0a2b2b1d 100644 --- a/spooler.c +++ b/spooler.c @@ -53,7 +53,7 @@ int spool_request(char *filename, int rn, int core_id, char *buffer, int size) { fd = open(filename, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(filename); uwsgi_unlock(uwsgi.spooler_lock); return 0; } @@ -135,7 +135,7 @@ void spooler() { nullfd = open("/dev/null", O_RDONLY); if (nullfd < 0) { - uwsgi_error("open()"); + uwsgi_error_open("/dev/null"); exit(1); } @@ -164,7 +164,7 @@ void spooler() { spool_fd = open(dp->d_name, O_RDONLY); if (spool_fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(dp->d_name); continue; } diff --git a/utils.c b/utils.c index cbeaf325..09ee6ac0 100644 --- a/utils.c +++ b/utils.c @@ -104,7 +104,7 @@ void daemonize(char *logfile) { fdin = open("/dev/null", O_RDWR); if (fdin < 0) { - uwsgi_error("open()"); + uwsgi_error_open("/dev/null"); exit(1); } @@ -155,7 +155,7 @@ void logto(char *logfile) { #endif fd = open(logfile, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(logfile); exit(1); } #ifdef UWSGI_UDP @@ -269,7 +269,7 @@ void uwsgi_as_root() { cgroup_taskfile = uwsgi_concat2(uwsgi.cgroup, "/tasks"); cgroup = fopen(cgroup_taskfile, "w"); if (!cgroup) { - uwsgi_error("fopen"); + uwsgi_error_open(cgroup_taskfile); exit(1); } if (fprintf(cgroup, "%d\n", (int) getpid()) < 0) { @@ -295,7 +295,7 @@ void uwsgi_as_root() { cgroup_taskfile = uwsgi_concat3(uwsgi.cgroup, "/", uwsgi.cgroup_opt[i]); cgroup = fopen(cgroup_taskfile, "w"); if (!cgroup) { - uwsgi_error("fopen"); + uwsgi_error_open(cgroup_taskfile); exit(1); } if (fprintf(cgroup, "%s\n", cgroup_opt) < 0) { @@ -1077,7 +1077,7 @@ int uwsgi_read_whole_body(struct wsgi_request *wsgi_req, char *buf, size_t len) // here we use O_EXCL to avoid eventual application bug in uuid generation/using upload_progress_fd = open(upload_progress_filename, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP); if (upload_progress_fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(upload_progress_filename); free(upload_progress_filename); } } @@ -1372,7 +1372,7 @@ char *uwsgi_open_and_read(char *url, int *size, int add_zero, char *magic_table[ else { fd = open(url, O_RDONLY); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(url); exit(1); } diff --git a/uwsgi.c b/uwsgi.c index f997ef11..f1c4bd81 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -913,7 +913,7 @@ options_parsed: uwsgi_log("writing pidfile to %s\n", uwsgi.pidfile); pidfile = fopen(uwsgi.pidfile, "w"); if (!pidfile) { - uwsgi_error("fopen"); + uwsgi_error_open(uwsgi.pidfile); exit(1); } if (fprintf(pidfile, "%d\n", (int) getpid()) < 0) { @@ -1379,7 +1379,7 @@ int uwsgi_start(void *v_argv) { } if (cache_fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(uwsgi.cache_store); exit(1); } uwsgi.cache_items = (struct uwsgi_cache_item *) mmap(NULL, uwsgi.cache_filesize, PROT_READ | PROT_WRITE, MAP_SHARED, cache_fd, 0); @@ -1578,7 +1578,7 @@ int uwsgi_start(void *v_argv) { } else { int fd = open("/dev/null", O_RDONLY); if (fd < 0) { - uwsgi_error("open()"); + uwsgi_error_open("/dev/null"); exit(1); } if (fd != 0) { diff --git a/uwsgi.h b/uwsgi.h index 159e9f8a..b6070244 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -7,6 +7,7 @@ #define UMAX16 65536 #define uwsgi_error(x) uwsgi_log("%s: %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__); +#define uwsgi_error_open(x) uwsgi_log("open(\"%s\"): %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__); #define uwsgi_debug(x, ...) uwsgi_log("[uWSGI DEBUG] " x, __VA_ARGS__); #define uwsgi_rawlog(x) if (write(2, x, strlen(x)) != strlen(x)) uwsgi_error("write()") diff --git a/xmlconf.c b/xmlconf.c index ae4f747a..1a141892 100644 --- a/xmlconf.c +++ b/xmlconf.c @@ -358,7 +358,7 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options xmlfd = open(uwsgi.xml_config, O_RDONLY); if (xmlfd < 0) { - uwsgi_error("open()"); + uwsgi_error_open(uwsgi.xml_config); exit(1); }