diff --git a/core/logging.c b/core/logging.c index 56ee5ff5..bb45aa37 100644 --- a/core/logging.c +++ b/core/logging.c @@ -458,13 +458,13 @@ void uwsgi_check_logrotate(void) { uwsgi_error_open(uwsgi.logfile); grace_them_all(0); } - if (dup2(fd, uwsgi.original_log_fd) < 0) { - uwsgi_error("dup2()"); - grace_them_all(0); + else { + if (dup2(fd, uwsgi.original_log_fd) < 0) { + uwsgi_error("dup2()"); + grace_them_all(0); + } + close(fd); } - - close(fd); - } else { uwsgi_error("unable to rotate log: rename()"); diff --git a/core/utils.c b/core/utils.c index b9c779b6..fa05eb17 100644 --- a/core/utils.c +++ b/core/utils.c @@ -460,18 +460,20 @@ void uwsgi_as_root() { } } int additional_groups = getgroups(0, NULL); - gid_t *gids = uwsgi_calloc(sizeof(gid_t) * additional_groups); - int i; - if (getgroups(additional_groups, gids) > 0) { - for (i = 0; i < additional_groups; i++) { - if (gids[i] == uwsgi.gid) - continue; - struct group *gr = getgrgid(gids[i]); - if (gr) { - uwsgi_log("set additional group %d (%s)\n", gids[i], gr->gr_name); - } - else { - uwsgi_log("set additional group %d\n", gids[i]); + if (additional_groups > 0) { + gid_t *gids = uwsgi_calloc(sizeof(gid_t) * additional_groups); + if (getgroups(additional_groups, gids) > 0) { + int i; + for (i = 0; i < additional_groups; i++) { + if (gids[i] == uwsgi.gid) + continue; + struct group *gr = getgrgid(gids[i]); + if (gr) { + uwsgi_log("set additional group %d (%s)\n", gids[i], gr->gr_name); + } + else { + uwsgi_log("set additional group %d\n", gids[i]); + } } } } diff --git a/core/uwsgi.c b/core/uwsgi.c index dee67112..e3aa00eb 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -4035,7 +4035,7 @@ void uwsgi_opt_connect_and_read(char *opt, char *address, void *foobar) { char buf[8192]; int fd = uwsgi_connect(address, -1, 0); - for (;;) { + while (fd >= 0) { int ret = uwsgi_waitfd(fd, -1); if (ret <= 0) { exit(0); @@ -4046,6 +4046,8 @@ void uwsgi_opt_connect_and_read(char *opt, char *address, void *foobar) { } uwsgi_log("%.*s", (int) len, buf); } + uwsgi_error("uwsgi_connect()"); + exit(1); } void uwsgi_opt_extract(char *opt, char *address, void *foobar) { diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 9ad87a28..b183bdef 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -1802,7 +1802,7 @@ void uwsgi_python_harakiri(int wid) { char *address = uwsgi_concat2(up.tracebacker, uwsgi_num2str(wid)); int fd = uwsgi_connect(address, -1, 0); - for (;;) { + while (fd >= 0) { int ret = uwsgi_waitfd(fd, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]); if (ret <= 0) { break;