mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
remove the usage of setvbuf() and use fflush() instead if no buffering should
be done on the output
This commit is contained in:
parent
449e5bc2ad
commit
269d491b6a
15
src/main.c
15
src/main.c
@ -2063,6 +2063,7 @@ struct OutStruct {
|
||||
|
||||
int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
int rc;
|
||||
struct OutStruct *out=(struct OutStruct *)stream;
|
||||
struct Configurable *config = out->config;
|
||||
if(out && !out->stream) {
|
||||
@ -2070,12 +2071,6 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
out->stream=fopen(out->filename, "wb");
|
||||
if(!out->stream)
|
||||
return -1; /* failure */
|
||||
if(config->nobuffer) {
|
||||
/* disable output buffering */
|
||||
#ifdef HAVE_SETVBUF
|
||||
setvbuf(out->stream, NULL, _IONBF, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(config->recvpersecond) {
|
||||
@ -2098,7 +2093,13 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
config->lastrecvtime = now;
|
||||
}
|
||||
|
||||
return fwrite(buffer, size, nmemb, out->stream);
|
||||
rc = fwrite(buffer, size, nmemb, out->stream);
|
||||
|
||||
if(config->nobuffer)
|
||||
/* disable output buffering */
|
||||
fflush(out->stream);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct InStruct {
|
||||
|
Loading…
Reference in New Issue
Block a user