remove the usage of setvbuf() and use fflush() instead if no buffering should

be done on the output
This commit is contained in:
Daniel Stenberg 2003-07-04 17:16:34 +00:00
parent 449e5bc2ad
commit 269d491b6a
1 changed files with 8 additions and 7 deletions

View File

@ -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 {