diff options
author | wtc%netscape.com <devnull@localhost> | 2002-03-20 19:35:56 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2002-03-20 19:35:56 +0000 |
commit | 0e5880437f54b6bff3b67d79ecd2b26755114ae7 (patch) | |
tree | a4213477707f16501cee171444d428a54086321d | |
parent | 2e56f8f81b18e7d82a487bcb93502e40683bca8b (diff) | |
download | nspr-hg-0e5880437f54b6bff3b67d79ecd2b26755114ae7.tar.gz |
Bugzilla bug 132208: call fstat() only when necessary in pt_HPUXSendFile.
-rw-r--r-- | pr/src/pthreads/ptio.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index 5bb7e321..697a9273 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -2146,14 +2146,16 @@ static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, PRInt32 count; int syserrno; - /* Get file size */ - if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) { - _PR_MD_MAP_FSTAT_ERROR(errno); - return -1; + if (sfd->file_nbytes == 0) { + /* Get file size */ + if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) { + _PR_MD_MAP_FSTAT_ERROR(errno); + return -1; + } + file_nbytes_to_send = statbuf.st_size - sfd->file_offset; + } else { + file_nbytes_to_send = sfd->file_nbytes; } - file_nbytes_to_send = (sfd->file_nbytes == 0) ? - statbuf.st_size - sfd->file_offset : - sfd->file_nbytes; nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send; hdtrl[0].iov_base = (void *) sfd->header; /* cast away the 'const' */ |