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]

sync() revised


I revised my sync() patch, which compiles and works.
The assignment is on the way.

Still didn't find any package which actually uses that.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

2004-10-29  Reini Urban  <rurban@x-ray.at>

	* syscalls.cc (sync): Implement it via cygheap->fdtab and 
	FlushFileBuffers. Better than a noop.
	(sync_worker) Internalized, because dtable::lock is private.
	* dtable.h: (dtable::sync_worker) Added as friend for lock().

Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.349
diff -u -b -r1.349 syscalls.cc
--- syscalls.cc	28 Oct 2004 01:46:01 -0000	1.349
+++ syscalls.cc	29 Oct 2004 14:43:29 -0000
@@ -1087,10 +1087,33 @@
   return 0;
 }
 
+/* Cygwin internal */
+void __stdcall
+sync_worker ()
+{
+  cygheap->fdtab.lock ();
+
+  /* TODO: check if Admin and iterate over the local volumes instead */
+  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 ();
+	  }
+      }
+  cygheap->fdtab.unlock ();
+}
+
 /* sync: SUSv3 */
 extern "C" void
 sync ()
 {
+  sync_worker ();
 }
 
 /* Cygwin internal */
Index: dtable.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dtable.h,v
retrieving revision 1.30
diff -u -b -r1.30 dtable.h
--- dtable.h	21 Mar 2004 17:41:40 -0000	1.30
+++ dtable.h	29 Oct 2004 14:43:29 -0000
@@ -85,6 +85,7 @@
   void delete_archetype (fhandler_base *);
   friend void dtable_init ();
   friend void __stdcall close_all_files ();
+  friend void __stdcall sync_worker ();
   friend class cygheap_fdmanip;
   friend class cygheap_fdget;
   friend class cygheap_fdnew;

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