This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin 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]

Re: sync(3)


On Wed, Oct 27, 2004 at 04:36:17AM +0200, Reini Urban wrote:
>Why is this a bad idea?

It's a very limited implementation of what sync is supposed to do but
maybe it's better than nothing.

A slightly more robust method would be to implement an internal cygwin
signal which could be sent to every cygwin process telling it to run
code like the below.

Of course, that isn't foolproof either since it doesn't affect
non-cygwin processes.

Do you have an assignment with Red Hat?  If so, I'll check this in.

cgf

>2004-10-27  Reini Urban  <rurban@x-ray.at>
>
>	* syscalls.cc (sync): Implement it via cygheap->fdtab and 
>	FlushFileBuffers. Better than a noop.
>
>Index: syscalls.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
>retrieving revision 1.345
>diff -u -b -r1.345 syscalls.cc
>--- syscalls.cc	3 Sep 2004 01:53:12 -0000	1.345
>+++ syscalls.cc	27 Oct 2004 02:30:01 -0000
>@@ -1082,6 +1082,24 @@
> extern "C" void
> sync ()
> {
>+  int err = 0;
>+  cygheap->fdtab.lock ();
>+
>+  fhandler_base *fh;
>+  for (int i = 0; i < (int) cygheap->fdtab.size; i++)
>+    if ((fh = cygheap->fdtab[i]) != NULL)
>+      {
>+#ifdef DEBUGGING
>+	debug_printf ("syncing fd %d", i);
>+#endif
>+	if (FlushFileBuffers (fh->get_handle ()) == 0)
>+	  {
>+	    __seterrno ();
>+	    err++;
>+	  }
>+      }
>+  cygheap->fdtab.unlock ();
>+  return err ? 1 : 0;
> }
> 
> /* Cygwin internal */


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