Permalink
Browse files

ported fastcgi and zeromq to the new api

  • Loading branch information...
1 parent c33ec8f commit 50fb43066a1fff7aca71dbaf8bce292e0696a4be roberto@sirius committed Apr 13, 2012
Showing with 36 additions and 12 deletions.
  1. +29 −9 proto/fastcgi.c
  2. +7 −3 proto/zeromq.c
View
@@ -193,22 +193,42 @@ ssize_t uwsgi_proto_fastcgi_write(struct wsgi_request * wsgi_req, char *buf, siz
if (len <= 65535) {
rlen = write(wsgi_req->poll.fd, &fr, 8);
if (rlen <= 0) {
- return rlen;
+ if (!uwsgi.ignore_write_errors) {
+ uwsgi_req_error("write()");
+ }
+ wsgi_req->write_errors++;
+ return 0;
}
- return write(wsgi_req->poll.fd, buf, len);
+ rlen = write(wsgi_req->poll.fd, buf, len);
+ if (rlen <= 0) {
+ if (!uwsgi.ignore_write_errors) {
+ uwsgi_req_error("write()");
+ }
+ wsgi_req->write_errors++;
+ return 0;
+ }
+ return rlen;
}
else {
while(len > 0) {
chunk_len = UMIN(65535, len);
fr.cl = htons(chunk_len);
rlen = write(wsgi_req->poll.fd, &fr, 8);
- if (rlen <= 0) {
- return rlen;
- }
+ if (rlen != 8) {
+ if (!uwsgi.ignore_write_errors) {
+ uwsgi_req_error("write()");
+ }
+ wsgi_req->write_errors++;
+ return 0;
+ }
rlen = write(wsgi_req->poll.fd, ptr, chunk_len);
- if (rlen <= 0) {
- return rlen;
- }
+ if (rlen != 8) {
+ if (!uwsgi.ignore_write_errors) {
+ uwsgi_req_error("write()");
+ }
+ wsgi_req->write_errors++;
+ return 0;
+ }
ptr += rlen;
len -= rlen;
}
@@ -224,7 +244,7 @@ ssize_t uwsgi_proto_fastcgi_write_header(struct wsgi_request * wsgi_req, char *b
void uwsgi_proto_fastcgi_close(struct wsgi_request *wsgi_req) {
if (write(wsgi_req->poll.fd, FCGI_END_REQUEST, 24) <= 0) {
- uwsgi_error("write()");
+ uwsgi_req_error("write()");
}
uwsgi_proto_base_close(wsgi_req);
View
@@ -415,7 +415,8 @@ ssize_t uwsgi_proto_zeromq_writev_header(struct wsgi_request *wsgi_req, struct i
for (i = 0; i < (int) iov_len; i++) {
len = uwsgi_proto_zeromq_write(wsgi_req, iovec[i].iov_base, iovec[i].iov_len);
if (len <= 0) {
- return len;
+ wsgi_req->write_errors++;
+ return 0;
}
ret += len;
}
@@ -441,10 +442,13 @@ ssize_t uwsgi_proto_zeromq_write(struct wsgi_request * wsgi_req, char *buf, size
zmq_msg_init_data(&reply, zmq_body, wsgi_req->proto_parser_pos + len, uwsgi_proto_zeromq_free, NULL);
if (uwsgi.threads > 1) pthread_mutex_lock(&uwsgi.zmq_lock);
if (zmq_send(uwsgi.zmq_pub, &reply, 0)) {
- uwsgi_error("zmq_send()");
+ if (!uwsgi.ignore_write_errors) {
+ uwsgi_error("zmq_send()");
+ }
+ wsgi_req->write_errors++;
if (uwsgi.threads > 1) pthread_mutex_unlock(&uwsgi.zmq_lock);
zmq_msg_close(&reply);
- return -1;
+ return 0;
}
if (uwsgi.threads > 1) pthread_mutex_unlock(&uwsgi.zmq_lock);
zmq_msg_close(&reply);

0 comments on commit 50fb430

Please sign in to comment.