This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cyg_libc_stdio_files locking


Hello

I have found that fopen() and fclose() do not
unlock Cyg_libc_stdio_files on all execution paths.
file.patch is the patch to work around this.

In my diagnostic messages I use cyrillic,
and other people may use other encodings that are not
8-bit-clean too. So I think it may be worth to apply
the diag.patch.

Aleksey Makarov


Index: c/libc/stdio/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/ChangeLog,v
retrieving revision 1.17
diff -u -5 -p -r1.17 ChangeLog
--- c/libc/stdio/current/ChangeLog	2 Sep 2002 07:55:37 -0000	1.17
+++ c/libc/stdio/current/ChangeLog	22 Jan 2003 21:23:35 -0000
@@ -1,5 +1,11 @@
+2003-01-22  Aleksey Makarov  <amakarov@mail.ru>
+
+	* include/stdiofiles.hxx, include/stdiofiles.inl, 
+        src/common/fclose.cxx, src/common/fopen.cxx:
+        Cyg_libc_stdio_files locking fixed
+
 2002-09-02  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* include/stream.inl (set_position): Fixed typo in none buffered
 	case. Seek pos bytes, not whence bytes.
 
Index: c/libc/stdio/current/include/stdiofiles.hxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/stdiofiles.hxx,v
retrieving revision 1.3
diff -u -5 -p -r1.3 stdiofiles.hxx
--- c/libc/stdio/current/include/stdiofiles.hxx	23 May 2002 23:07:13 -0000	1.3
+++ c/libc/stdio/current/include/stdiofiles.hxx	22 Jan 2003 21:23:36 -0000
@@ -103,10 +103,16 @@ public:
     static cyg_bool
     trylock(void);
 
     static void
     unlock(void);
+
+    class Lock {
+    public:
+        Lock(); 
+        ~Lock();
+    };
     
 }; // class Cyg_libc_stdio_files
 
 
 // Inline functions for this class
Index: c/libc/stdio/current/include/stdiofiles.inl
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/stdiofiles.inl,v
retrieving revision 1.3
diff -u -5 -p -r1.3 stdiofiles.inl
--- c/libc/stdio/current/include/stdiofiles.inl	23 May 2002 23:07:13 -0000	1.3
+++ c/libc/stdio/current/include/stdiofiles.inl	22 Jan 2003 21:23:36 -0000
@@ -119,8 +119,17 @@ Cyg_libc_stdio_files::unlock(void)
     files_lock.unlock();
 # endif
 } // Cyg_libc_stdio_files::unlock()
 
 
+inline Cyg_libc_stdio_files::Lock::Lock() {
+    Cyg_libc_stdio_files::lock();
+}
+
+inline Cyg_libc_stdio_files::Lock::~Lock() {
+    Cyg_libc_stdio_files::unlock();
+}
+
+
 #endif // CYGONCE_LIBC_STDIO_STDIOFILES_INL multiple inclusion protection
 
 // EOF stdiofiles.inl
Index: c/libc/stdio/current/src/common/fclose.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/src/common/fclose.cxx,v
retrieving revision 1.3
diff -u -5 -p -r1.3 fclose.cxx
--- c/libc/stdio/current/src/common/fclose.cxx	23 May 2002 23:07:16 -0000	1.3
+++ c/libc/stdio/current/src/common/fclose.cxx	22 Jan 2003 21:23:37 -0000
@@ -79,11 +79,11 @@ fclose( FILE *stream )
 {
     Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
     int i;
     Cyg_ErrNo err;
     
-    Cyg_libc_stdio_files::lock();
+    Cyg_libc_stdio_files::Lock lock;
 
     // find the stream in the table
     for (i=0; i < FOPEN_MAX; i++)
     {
         if (real_stream == Cyg_libc_stdio_files::get_file_stream(i))
@@ -116,12 +116,10 @@ fclose( FILE *stream )
 #endif // CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS
 
     // and mark the stream available for use
     Cyg_libc_stdio_files::set_file_stream(i, NULL);
         
-    Cyg_libc_stdio_files::unlock();
-
     return 0;
 
 } // fclose()
         
 #endif // if defined(CYGPKG_LIBC_STDIO_OPEN)
Index: c/libc/stdio/current/src/common/fopen.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/src/common/fopen.cxx,v
retrieving revision 1.4
diff -u -5 -p -r1.4 fopen.cxx
--- c/libc/stdio/current/src/common/fopen.cxx	23 May 2002 23:07:17 -0000	1.4
+++ c/libc/stdio/current/src/common/fopen.cxx	22 Jan 2003 21:23:38 -0000
@@ -142,11 +142,11 @@ static FILE *fopen_inner( cyg_stdio_hand
     int i;
     Cyg_ErrNo err;
     int bufmode = _IOFBF;
     cyg_ucount32 bufsize = BUFSIZ;
     
-    Cyg_libc_stdio_files::lock();
+    Cyg_libc_stdio_files::Lock lock;
 
     // find an empty slot
     for (i=0; i < FOPEN_MAX; i++) {
         curr_stream = Cyg_libc_stdio_files::get_file_stream(i);
         if (curr_stream == NULL)
@@ -177,12 +177,10 @@ static FILE *fopen_inner( cyg_stdio_hand
                                                              append, binary,
                                                              bufmode, bufsize );
     // it puts any error in its own error flag
     if (( err=curr_stream->get_error() )) {
 
-        Cyg_libc_stdio_files::unlock();
-        
         free( curr_stream );
 
         cyg_stdio_close( dev );
         
         errno = err;
@@ -191,12 +189,10 @@ static FILE *fopen_inner( cyg_stdio_hand
 
     } // if
 
     Cyg_libc_stdio_files::set_file_stream(i, curr_stream);
         
-    Cyg_libc_stdio_files::unlock();
-
     return (FILE *)(curr_stream);
 
 } // fopen_inner()
 
 externC FILE *
Index: current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/ChangeLog,v
retrieving revision 1.31
diff -u -5 -p -r1.31 ChangeLog
--- current/ChangeLog	18 Jan 2003 04:18:26 -0000	1.31
+++ current/ChangeLog	22 Jan 2003 21:31:15 -0000
@@ -1,5 +1,9 @@
+2003-01-22  Aleksey Makarov  <amakarov@mail.ru>
+
+	* src/diag.cxx (diag_check_string): Allow non 8 bit clean encodings
+
 2003-01-18  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* include/cyg_ass.h (CYG_CHECK_FUNC_PTRC): Define with const pointer
 	arguments.
 	(CYG_CHECK_DATA_PTRC): Ditto. 
Index: current/src/diag.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/src/diag.cxx,v
retrieving revision 1.13
diff -u -5 -p -r1.13 diag.cxx
--- current/src/diag.cxx	18 Jul 2002 20:08:16 -0000	1.13
+++ current/src/diag.cxx	22 Jan 2003 21:31:17 -0000
@@ -246,11 +246,11 @@ static cyg_bool diag_check_string( const
         if( c == '\n' || c == '\r' || c == '\b' )
             continue;
 
         /* Check for printable chars. This assumes ASCII */
         
-        if( c < ' ' || c > '~' )
+        if( c < ' ' )
             result = false;
 
     }
 
     return result;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]