public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Deadlock when closing file
@ 2008-01-18 12:31 Øyvind Harboe
  0 siblings, 0 replies; only message in thread
From: Øyvind Harboe @ 2008-01-18 12:31 UTC (permalink / raw)
  To: eCos Disuss

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

I've made a tftp file system. Relatively straightforward w/eCos.

Mounting this device at /tftp, I can read/write files using the
following path syntax: /tftp/10.0.0.106/filename... This
adds tftp client get/set to my app without modifying the app.

However, tftp_client_put() needs to be done at close() time and
FILEIO_MUTEX_LOCK(fdlock) is held when co_close() is invoked.

fo_sync() is not invoked when the application (which I can't
really modify) calls close().

With the attached patch, I no longer get the deadlock, but I don't
quite understand this code or API contract well enough
to know how and why the FILEIO_MUTEX_LOCK(fdlock) should be
held.

Would it be possible to rewrite io/fileio/current/src/fd.cxx not to
hold FILEIO_MUTEX_LOCK() during fo_close() without
breaking something?


Should close() invoke fsync()?

-- 
Øyvind Harboe
http://www.zylin.com - eCos ARM & FPGA  developer kit

[-- Attachment #2: flushproblems.txt --]
[-- Type: text/plain, Size: 787 bytes --]

### Eclipse Workspace Patch 1.0
#P ecos
Index: io/fileio/current/src/fd.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/fd.cxx,v
retrieving revision 1.7
diff -u -r1.7 fd.cxx
--- io/fileio/current/src/fd.cxx	7 Apr 2004 11:18:54 -0000	1.7
+++ io/fileio/current/src/fd.cxx	18 Jan 2008 12:22:41 -0000
@@ -157,7 +157,11 @@
     {        
         cyg_file_lock( fp, fp->f_syncmode );
         
+        FILEIO_MUTEX_UNLOCK(fdlock);
+        // closing the file might involve other file operations, e.g. 
+        // tcp/ip communication on sockets.
         error = fp->f_ops->fo_close(fp);
+        FILEIO_MUTEX_LOCK(fdlock);
 
         cyg_file_unlock( fp, fp->f_syncmode );
             

[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-18 12:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-18 12:31 [ECOS] Deadlock when closing file Øyvind Harboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).