diff --git a/core/protocol.c b/core/protocol.c index b94bc0da..d69cd7dc 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -886,44 +886,6 @@ nextsm2: return 0; } -ssize_t uwsgi_send_empty_pkt(int fd, char *socket_name, uint8_t modifier1, uint8_t modifier2) { - - struct uwsgi_header uh; - char *port; - uint16_t s_port; - struct sockaddr_in uaddr; - int ret; - - uh.modifier1 = modifier1; - uh.pktsize = 0; - uh.modifier2 = modifier2; - - if (socket_name) { - port = strchr(socket_name, ':'); - if (!port) - return -1; - s_port = atoi(port + 1); - port[0] = 0; - memset(&uaddr, 0, sizeof(struct sockaddr_in)); - uaddr.sin_family = AF_INET; - uaddr.sin_addr.s_addr = inet_addr(socket_name); - uaddr.sin_port = htons(s_port); - - port[0] = ':'; - - ret = sendto(fd, &uh, 4, 0, (struct sockaddr *) &uaddr, sizeof(struct sockaddr_in)); - } - else { - ret = send(fd, &uh, 4, 0); - } - - if (ret < 0) { - uwsgi_error("sendto()"); - } - - return ret; -} - int uwsgi_hooked_parse(char *buffer, size_t len, void (*hook) (char *, uint16_t, char *, uint16_t, void *), void *data) { char *ptrbuf, *bufferend; diff --git a/plugins/spooler/spooler_plugin.c b/plugins/spooler/spooler_plugin.c index 7d8e1fe8..04fc5e8c 100644 --- a/plugins/spooler/spooler_plugin.c +++ b/plugins/spooler/spooler_plugin.c @@ -20,16 +20,19 @@ int uwsgi_request_spooler(struct wsgi_request *wsgi_req) { if (uspool == NULL) { uwsgi_log("the spooler is inactive !!!...skip\n"); - uwsgi_send_empty_pkt(wsgi_req->poll.fd, NULL, 255, 0); + uh.modifier1 = 255; + uh.pktsize = 0; + uh.modifier2 = 0; + uwsgi_response_write_body_do(wsgi_req, (char *) &uh, 4); return -1; } - i = spool_request(uspool, spool_filename, uwsgi.workers[0].requests + 1, wsgi_req->async_id, wsgi_req->buffer, wsgi_req->uh.pktsize, NULL, 0, NULL, 0); + i = spool_request(uspool, spool_filename, uwsgi.workers[0].requests + 1, wsgi_req->async_id, wsgi_req->buffer, wsgi_req->uh->pktsize, NULL, 0, NULL, 0); uh.modifier1 = 255; uh.pktsize = 0; if (i > 0) { uh.modifier2 = 1; - if (write(wsgi_req->poll.fd, &uh, 4) != 4) { + if (uwsgi_response_write_body_do(wsgi_req, (char *) &uh, 4)) { uwsgi_log("disconnected client, remove spool file.\n"); /* client disconnect, remove spool file */ if (unlink(spool_filename)) { @@ -43,10 +46,7 @@ int uwsgi_request_spooler(struct wsgi_request *wsgi_req) { else { /* announce a failed spool request */ uh.modifier2 = 0; - i = write(wsgi_req->poll.fd, &uh, 4); - if (i != 4) { - uwsgi_error("write()"); - } + uwsgi_response_write_body_do(wsgi_req, (char *) &uh, 4); } return -1;