From: Manoj Kasichainula Date: Sat, 30 Oct 1999 05:25:32 +0000 (+0000) Subject: ap_bwrite now exports an errnoless interface. X-Git-Tag: 1.3.10~209 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b73b1bf345a54a91de82282f2ec541be327becef;p=apache ap_bwrite now exports an errnoless interface. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84074 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/echo/mod_echo.c b/modules/echo/mod_echo.c index e8327193e1..12a704d72b 100644 --- a/modules/echo/mod_echo.c +++ b/modules/echo/mod_echo.c @@ -43,7 +43,7 @@ static int process_echo_connection(conn_rec *c) (void) ap_bread(c->client,buf,sizeof buf,&r); if(r <= 0) break; - w=ap_bwrite(c->client,buf,r); + (void) ap_bwrite(c->client,buf,r, &w); if(w != r) break; ap_bflush(c->client); diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index ef549531ea..08e7b2fe3f 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -538,6 +538,7 @@ static int cgi_handler(request_rec *r) */ if (ap_should_client_block(r)) { int dbsize, len_read; + ap_ssize_t bytes_written; if (conf->logname) { dbuf = ap_pcalloc(r->pool, conf->bufbytes + 1); @@ -556,7 +557,8 @@ static int cgi_handler(request_rec *r) memcpy(dbuf + dbpos, argsbuffer, dbsize); dbpos += dbsize; } - if (ap_bwrite(script_out, argsbuffer, len_read) < len_read) { + (void) ap_bwrite(script_out, argsbuffer, len_read, &bytes_written); + if (bytes_written < len_read) { /* silly script stopped reading, soak up remaining message */ while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) { /* dump it */ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index cc08e49407..fd09d20936 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2015,9 +2015,10 @@ API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length) { char buf[IOBUFSIZE]; long total_bytes_sent = 0; - register int w, o; + register int o; + ap_ssize_t w; ap_ssize_t n; - ap_status_t status; + ap_status_t rv; if (length == 0) return 0; @@ -2030,8 +2031,8 @@ API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length) n = o; do { - status = ap_read(fd, buf, &n); - } while (status == APR_EINTR && !ap_is_aborted(r->connection) && + rv = ap_read(fd, buf, &n); + } while (rv == APR_EINTR && !ap_is_aborted(r->connection) && (n < 1)); if (n < 1) { @@ -2041,15 +2042,15 @@ API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length) o = 0; while (n && !ap_is_aborted(r->connection)) { - w = ap_bwrite(r->connection->client, &buf[o], n); + rv = ap_bwrite(r->connection->client, &buf[o], n, &w); if (w > 0) { total_bytes_sent += w; n -= w; o += w; } - else if (w < 0) { + else if (rv != APR_SUCCESS) { if (!ap_is_aborted(r->connection)) { - ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r, "client stopped connection before send body completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); r->connection->aborted = 1; @@ -2076,7 +2077,8 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) char buf[IOBUFSIZE]; long total_bytes_sent = 0; long zero_timeout = 0; - int w, o; + register int o; + ap_ssize_t w; ap_ssize_t n; ap_status_t rv; @@ -2120,15 +2122,15 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) o = 0; while (n && !ap_is_aborted(r->connection)) { - w = ap_bwrite(r->connection->client, &buf[o], n); + rv = ap_bwrite(r->connection->client, &buf[o], n, &w); if (w > 0) { total_bytes_sent += w; n -= w; o += w; } - else if (w < 0) { + else if (rv != APR_SUCCESS) { if (!ap_is_aborted(r->connection)) { - ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r, "client stopped connection before rflush completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); r->connection->aborted = 1; @@ -2159,7 +2161,9 @@ API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, size_t length) { size_t total_bytes_sent = 0; - int n, w; + int n; + ap_ssize_t w; + ap_status_t rv; if (length == 0) return 0; @@ -2175,19 +2179,19 @@ API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, } while (n && !r->connection->aborted) { - w = ap_bwrite(r->connection->client, (char *) mm + offset, n); + rv = ap_bwrite(r->connection->client, (char *) mm + offset, n, &w); if (w > 0) { total_bytes_sent += w; n -= w; offset += w; } - else if (w < 0) { + else if (rv != APR_SUCCESS) { if (r->connection->aborted) break; - else if (errno == EAGAIN) + else if (rv == EAGAIN) continue; else { - ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r, "client stopped connection before send mmap completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); r->connection->aborted = 1; @@ -2242,15 +2246,16 @@ API_EXPORT(int) ap_rputs(const char *str, request_rec *r) API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r) { - int n; + ap_ssize_t n; + ap_status_t rv; if (r->connection->aborted) return EOF; - n = ap_bwrite(r->connection->client, buf, nbyte); + rv = ap_bwrite(r->connection->client, buf, nbyte, &n); if (n < 0) { if (!r->connection->aborted) { - ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r, "client stopped connection before rwrite completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); r->connection->aborted = 1; @@ -2314,6 +2319,7 @@ API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...) int i, j, k; const char *x; BUFF *fb = r->connection->client; + ap_status_t rv; if (r->connection->aborted) return EOF; @@ -2324,11 +2330,11 @@ API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...) if (x == NULL) break; j = strlen(x); - i = ap_bwrite(fb, x, j); + rv = ap_bwrite(fb, x, j, &i); if (i != j) { va_end(args); if (!r->connection->aborted) { - ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r, "client stopped connection before rvputs completed"); ap_bsetflag(r->connection->client, B_EOUT, 1); r->connection->aborted = 1;