do not die on perl die() :P

This commit is contained in:
roberto@natty32
2011-05-01 16:42:01 +02:00
parent 694517bbe7
commit 7682eec52a
5 changed files with 23 additions and 14 deletions
+5 -3
View File
@@ -382,7 +382,7 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
SV *pi = SvREFCNT_inc(POPs);
if (!hv_store(env, "psgi.input", 10, pi, 0)) goto clear;
if (!hv_store(env, "psgix.io", 8, pi, 0)) goto clear;
if (!hv_store(env, "psgix.io", 8, SvREFCNT_inc(pi), 0)) goto clear;
if (!hv_store(env, "psgix.input.buffered", 20, &PL_sv_no, 0)) goto clear;
@@ -413,10 +413,11 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
PUTBACK;
perl_call_sv(psgi_func, G_SCALAR);
perl_call_sv(psgi_func, G_SCALAR | G_EVAL);
if(SvTRUE(ERRSV)) {
internal_server_error(wsgi_req, "exception raised");
uwsgi_log("%s\n", SvPV_nolen(ERRSV));
goto clear;
}
@@ -434,9 +435,10 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
XPUSHs( newRV((SV*) uperl.stream_responder));
PUTBACK;
perl_call_sv( (SV*)response, G_SCALAR);
perl_call_sv( (SV*)response, G_SCALAR | G_EVAL);
if(SvTRUE(ERRSV)) {
internal_server_error(wsgi_req, "exception raised");
uwsgi_log("%s\n", SvPV_nolen(ERRSV));
}
+9 -2
View File
@@ -132,16 +132,17 @@ int psgi_response(struct wsgi_request *wsgi_req, PerlInterpreter *my_perl, AV *r
return 1;
}
if (SvTYPE(SvRV(*hitem)) == SVt_PVGV || SvTYPE(SvRV(*hitem)) == SVt_PVHV) {
if (SvTYPE(SvRV(*hitem)) == SVt_PVGV || SvTYPE(SvRV(*hitem)) == SVt_PVHV || SvTYPE(SvRV(*hitem)) == SVt_PVMG) {
for(;;) {
PUSHMARK(SP);
XPUSHs(*hitem);
PUTBACK;
perl_call_method("getline", G_SCALAR);
perl_call_method("getline", G_SCALAR | G_EVAL);
SPAGAIN;
if(SvTRUE(ERRSV)) {
internal_server_error(wsgi_req, "exception raised");
uwsgi_log("%s\n", SvPV_nolen(ERRSV));
break;
}
@@ -154,6 +155,12 @@ int psgi_response(struct wsgi_request *wsgi_req, PerlInterpreter *my_perl, AV *r
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, chitem, hlen);
}
PUSHMARK(SP);
XPUSHs(*hitem);
PUTBACK;
perl_call_method("close", G_SCALAR | G_EVAL);
SPAGAIN;
}
else if (SvTYPE(SvRV(*hitem)) == SVt_PVAV) {
+3 -3
View File
@@ -339,7 +339,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
wsgi_req->app_id = uwsgi.default_app;
}
else {
internal_server_error(wsgi_req->poll.fd, "wsgi application not found");
internal_server_error(wsgi_req, "wsgi application not found");
goto clear2;
}
@@ -361,14 +361,14 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
if (wsgi_req->protocol_len < 5) {
uwsgi_log( "INVALID PROTOCOL: %.*s\n", wsgi_req->protocol_len, wsgi_req->protocol);
internal_server_error(wsgi_req->poll.fd, "invalid HTTP protocol !!!");
internal_server_error(wsgi_req, "invalid HTTP protocol !!!");
goto clear;
}
if (strncmp(wsgi_req->protocol, "HTTP/", 5)) {
uwsgi_log( "INVALID PROTOCOL: %.*s\n", wsgi_req->protocol_len, wsgi_req->protocol);
internal_server_error(wsgi_req->poll.fd, "invalid HTTP protocol !!!");
internal_server_error(wsgi_req, "invalid HTTP protocol !!!");
goto clear;
}
+5 -5
View File
@@ -281,17 +281,17 @@ char *uwsgi_get_cwd() {
}
void internal_server_error(int fd, char *message) {
void internal_server_error(struct wsgi_request *wsgi_req, char *message) {
if (uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] == 0) {
uwsgi.wsgi_req->headers_size = write(fd, "HTTP/1.1 500 Internal Server Error\r\nContent-type: text/html\r\n\r\n", 63);
uwsgi.wsgi_req->headers_size = wsgi_req->socket->proto_write_header(wsgi_req, "HTTP/1.1 500 Internal Server Error\r\nContent-type: text/html\r\n\r\n", 63);
}
else {
uwsgi.wsgi_req->headers_size = write(fd, "Status: 500 Internal Server Error\r\nContent-type: text/html\r\n\r\n", 62);
uwsgi.wsgi_req->headers_size = wsgi_req->socket->proto_write_header(wsgi_req, "Status: 500 Internal Server Error\r\nContent-type: text/html\r\n\r\n", 62);
}
uwsgi.wsgi_req->header_cnt = 2;
uwsgi.wsgi_req->response_size = write(fd, "<h1>uWSGI Error</h1>", 20);
uwsgi.wsgi_req->response_size += write(fd, message, strlen(message));
uwsgi.wsgi_req->response_size = wsgi_req->socket->proto_write(wsgi_req, "<h1>uWSGI Error</h1>", 20);
uwsgi.wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, message, strlen(message));
}
void uwsgi_as_root() {
+1 -1
View File
@@ -1405,7 +1405,7 @@ void stats(int);
void uwsgi_xml_config(char *, struct wsgi_request *, int, char *[]);
#endif
void internal_server_error(int, char *);
void internal_server_error(struct wsgi_request *, char *);
#ifdef UWSGI_SNMP
void manage_snmp(int, uint8_t *, int, struct sockaddr_in *);