Rev 4921 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4921 | Rev 6099 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | interlocked locking with the sfp_lock. */ |
80 | interlocked locking with the sfp_lock. */ |
81 | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
81 | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
82 | int __oldcancel; |
82 | int __oldcancel; |
83 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); |
83 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); |
84 | #endif |
84 | #endif |
- | 85 | if (!(fp->_flags2 & __SNLK)) |
|
85 | _flockfile (fp); |
86 | _flockfile (fp); |
Line 86... | Line 87... | ||
86 | 87 | ||
87 | if (fp->_flags == 0) /* not open! */ |
88 | if (fp->_flags == 0) /* not open! */ |
- | 89 | { |
|
88 | { |
90 | if (!(fp->_flags2 & __SNLK)) |
89 | _funlockfile (fp); |
91 | _funlockfile (fp); |
90 | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
92 | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
91 | pthread_setcancelstate (__oldcancel, &__oldcancel); |
93 | pthread_setcancelstate (__oldcancel, &__oldcancel); |
92 | #endif |
94 | #endif |
93 | return (0); |
95 | return (0); |
- | 96 | } |
|
94 | } |
97 | #ifdef _STDIO_BSD_SEMANTICS |
- | 98 | /* BSD and Glibc systems only flush streams which have been written to. */ |
|
- | 99 | r = (fp->_flags & __SWR) ? __sflush_r (rptr, fp) : 0; |
|
- | 100 | #else |
|
95 | /* Unconditionally flush to allow special handling for seekable read |
101 | /* Follow POSIX semantics exactly. Unconditionally flush to allow |
96 | files to reposition file to last byte processed as opposed to |
102 | special handling for seekable read files to reposition file to last |
97 | last byte read ahead into the buffer. */ |
103 | byte processed as opposed to last byte read ahead into the buffer. */ |
- | 104 | r = __sflush_r (rptr, fp); |
|
98 | r = _fflush_r (rptr, fp); |
105 | #endif |
99 | if (fp->_close != NULL && fp->_close (rptr, fp->_cookie) < 0) |
106 | if (fp->_close != NULL && fp->_close (rptr, fp->_cookie) < 0) |
100 | r = EOF; |
107 | r = EOF; |
101 | if (fp->_flags & __SMBF) |
108 | if (fp->_flags & __SMBF) |
102 | _free_r (rptr, (char *) fp->_bf._base); |
109 | _free_r (rptr, (char *) fp->_bf._base); |
103 | if (HASUB (fp)) |
110 | if (HASUB (fp)) |
104 | FREEUB (rptr, fp); |
111 | FREEUB (rptr, fp); |
105 | if (HASLB (fp)) |
112 | if (HASLB (fp)) |
106 | FREELB (rptr, fp); |
113 | FREELB (rptr, fp); |
107 | __sfp_lock_acquire (); |
114 | __sfp_lock_acquire (); |
- | 115 | fp->_flags = 0; /* release this FILE for reuse */ |
|
108 | fp->_flags = 0; /* release this FILE for reuse */ |
116 | if (!(fp->_flags2 & __SNLK)) |
109 | _funlockfile (fp); |
117 | _funlockfile (fp); |
110 | #ifndef __SINGLE_THREAD__ |
118 | #ifndef __SINGLE_THREAD__ |
111 | __lock_close_recursive (fp->_lock); |
119 | __lock_close_recursive (fp->_lock); |