FreeBSD Bugzilla – Attachment 52756 Details for
Bug 79887
[patch] freopen() isn't thread-safe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.57 KB, created by
Dmitrij Tejblum
on 2005-04-14 00:20:26 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Dmitrij Tejblum
Created:
2005-04-14 00:20:26 UTC
Size:
1.57 KB
patch
obsolete
>Index: freopen.c >=================================================================== >RCS file: /home/ncvs/src/lib/libc/stdio/freopen.c,v >retrieving revision 1.13 >diff -u -r1.13 freopen.c >--- freopen.c 22 May 2004 15:19:41 -0000 1.13 >+++ freopen.c 13 Apr 2005 22:56:48 -0000 >@@ -155,14 +155,6 @@ > > /* Get a new descriptor to refer to the new file. */ > f = _open(file, oflags, DEFFILEMODE); >- if (f < 0 && isopen) { >- /* If out of fd's close the old one and try again. */ >- if (errno == ENFILE || errno == EMFILE) { >- (void) (*fp->_close)(fp->_cookie); >- isopen = 0; >- f = _open(file, oflags, DEFFILEMODE); >- } >- } > sverrno = errno; > > finish: >@@ -171,8 +163,6 @@ > * keep fp->_base: it may be the wrong size. This loses the effect > * of any setbuffer calls, but stdio has always done this before. > */ >- if (isopen) >- (void) (*fp->_close)(fp->_cookie); > if (fp->_flags & __SMBF) > free((char *)fp->_bf._base); > fp->_w = 0; >@@ -191,6 +181,8 @@ > memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t)); > > if (f < 0) { /* did not get it after all */ >+ if (isopen) >+ (void) (*fp->_close)(fp->_cookie); > fp->_flags = 0; /* set it free */ > errno = sverrno; /* restore in case _close clobbered */ > FUNLOCKFILE(fp); >@@ -202,10 +194,13 @@ > * to maintain the descriptor. Various C library routines (perror) > * assume stderr is always fd STDERR_FILENO, even if being freopen'd. > */ >- if (wantfd >= 0 && f != wantfd) { >+ if (wantfd >= 0) { > if (_dup2(f, wantfd) >= 0) { > (void)_close(f); > f = wantfd; >+ } else { >+ if (isopen) >+ (void) (*fp->_close)(fp->_cookie); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 79887
: 52756 |
52757
|
52758