cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-994165 ] fwrite() informs of a partial write for no good reason

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 05 Jun 2008 10:29:16 -0700

Bugs item #994165, was opened at 2004-07-20 01:15
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=994165&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: http
Group: bad behaviour
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: fwrite() informs of a partial write for no good reason

Initial Comment:
Working on libcurl for c++ version 7.11.1

Steps to reproduce:
1. Create a set of HTTP files, writing data to each one
of them as follows
for (int i=0 ;< 20; i++)
{
   1. Call Curl_Open() for file name http://<http-
server>/myfilename-i
   2. Call a Curl_Write operation with buffer size = 20000
bytes.
   3. Call a Write operation with buffer size = 40000
   4. Call a Curl-Close() operation
}
The problem occurs in sendf.c function: Curl_client_write
where fwrite returns wrote < len.
I checked GetLastError() which equal to 0 to indicate no
system error.

My name : Orna Haber
My email address orna.haber_at_ca.com

The attached zip file includes 2 source files that
illustrates the steps to reproduce and my proposed
soltion to the problem in sendf.c (sendf.c of version
7.11.1)

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2008-06-05 19:29

Message:
Logged In: YES
user_id=1110
Originator: NO

vecchioc, this is a very old and closed bug report. Adding info here is
pointless.

If you want to discuss something, take to the curl-library mailing list.

If you want to file a bug report, please submit a new one.

----------------------------------------------------------------------

Comment By: Giorgio Vecchiocattivi (vecchioc)
Date: 2008-06-05 18:54

Message:
Logged In: YES
user_id=731260
Originator: NO

We are having this error in our application. (with libcurl 7.15.5) on
windows 2003 server.
Some of our customers have an error "Failed writing body" every ~20 files
pushed to an FTP server.

The in any case the fwrite as I found in sendf.c:
399: wrote = data->set.fwrite(ptr, 1, len, data->set.out);
i.e. write "len" blocks of 1 byte.

is wrong, because the fwrite (in any platform) does not guarantee it will
write all "len" blocks.

The correct form is
399: wrote = len * data->set.fwrite(ptr, len, 1, data->set.out);
i.e. write 1 block of len bytes.

as work around I'm going to put a customized fwrite.

Giorgio V.

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2004-07-31 09:18

Message:
Logged In: YES
user_id=1110

Closed this until anything comes up that proves this worthy
of attention.

See also Dominick Meglio's informative reply:
http://curl.haxx.se/mail/lib-2004-07/0210.html

----------------------------------------------------------------------

Comment By: Gisle Vanem (giva)
Date: 2004-07-29 01:13

Message:
Logged In: YES
user_id=47168

Operation.cpp:

if (!m_pCurlFile->Open(m_strFileName,
   CFile::modeCreate/*0x02*/))

Shouldn't there be a typeBinary here to?
Ascii/binary matters for MFC too, no?

Hard to say what your problem is since the CURLFile
definition/implementation is missing from your .zip.

--gv

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2004-07-22 23:50

Message:
Logged In: YES
user_id=1110

1. GetLastError() is Windows, it doesn't exist on other
platforms.

2. fwrite() should never return anything by the same amount
as given to it, as everything else is a failure.

Can you explain why fwrite() fails for you in this case?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=994165&group_id=976
Received on 2008-06-05

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET