plugins/python: fix uwsgi_python_harakiri error handling

Fixes close with a negative fd.

Reported by Coverity as CID #970996.
This commit is contained in:
Riccardo Magliocchetti
2013-12-23 13:43:02 +01:00
parent 643fc3019b
commit e795cd8912
+14 -11
View File
@@ -1798,19 +1798,22 @@ static void uwsgi_python_harakiri(int wid) {
char *address = uwsgi_concat2(up.tracebacker, uwsgi_num2str(wid));
int fd = uwsgi_connect(address, -1, 0);
while (fd >= 0) {
int ret = uwsgi_waitfd(fd, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]);
if (ret <= 0) {
break;
}
ssize_t len = read(fd, buf, 8192);
if (len <= 0) {
break;
}
uwsgi_log("%.*s", (int) len, buf);
}
if (fd < 1)
goto exit;
int ret = uwsgi_waitfd(fd, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]);
if (ret <= 0) {
goto cleanup;
}
ssize_t len = read(fd, buf, 8192);
if (len <= 0) {
goto cleanup;
}
uwsgi_log("%.*s", (int) len, buf);
cleanup:
close(fd);
exit:
free(address);
}