Commit ce894603 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/17215 ([3.4 only] __basic_file<char>::close ignores errors)

2004-08-30  Paolo Carlini  <pcarlini@suse.de>
	    Kenneth C. Schalk  <ken@xorian.net>

	PR libstdc++/17215
	* config/io/basic_file_stdio.cc (__basic_file<char>::close()):
	Check the return value of fclose/sync, loop on EINTR.
	(__basic_file<char>::sys_open): Likewise, for sync.

Co-Authored-By: Kenneth C. Schalk <ken@xorian.net>

From-SVN: r86756
parent 28839b70
2004-08-30 Paolo Carlini <pcarlini@suse.de>
Kenneth C. Schalk <ken@xorian.net>
PR libstdc++/17215
* config/io/basic_file_stdio.cc (__basic_file<char>::close()):
Check the return value of fclose/sync, loop on EINTR.
(__basic_file<char>::sys_open): Likewise, for sync.
2004-08-29 Paolo Carlini <pcarlini@suse.de> 2004-08-29 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (time_get<>::_M_extract_via_format, * include/bits/locale_facets.tcc (time_get<>::_M_extract_via_format,
......
...@@ -189,11 +189,18 @@ namespace std ...@@ -189,11 +189,18 @@ namespace std
__basic_file* __ret = NULL; __basic_file* __ret = NULL;
if (!this->is_open() && __file) if (!this->is_open() && __file)
{ {
int __err;
errno = 0;
do
__err = this->sync();
while (__err && errno == EINTR);
if (!__err)
{
_M_cfile = __file; _M_cfile = __file;
_M_cfile_created = false; _M_cfile_created = false;
this->sync();
__ret = this; __ret = this;
} }
}
return __ret; return __ret;
} }
...@@ -252,12 +259,23 @@ namespace std ...@@ -252,12 +259,23 @@ namespace std
__basic_file* __ret = static_cast<__basic_file*>(NULL); __basic_file* __ret = static_cast<__basic_file*>(NULL);
if (this->is_open()) if (this->is_open())
{ {
// In general, no need to zero errno in advance if checking
// for error first. However, C89/C99 (at variance with IEEE
// 1003.1, f.i.) do not mandate that fclose/fflush must set
// errno upon error.
int __err;
errno = 0;
if (_M_cfile_created) if (_M_cfile_created)
fclose(_M_cfile); do
__err = fclose(_M_cfile);
while (__err && errno == EINTR);
else else
this->sync(); do
_M_cfile = 0; __err = this->sync();
while (__err && errno == EINTR);
if (!__err)
__ret = this; __ret = this;
_M_cfile = 0;
} }
return __ret; return __ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment