Re: Allow NtFileFlushBuffers to block

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Eric,


Thanks for the comment. I've reworked the patch... is this more what you had in mind?

thanks,

Mike


Eric Pouech wrote:


what I don't like in your patch is that you create an event in all cases, where according to the doc, FlushFileBuffers should only block for named pipes.
maybe, it would be better to return the event handle from the flush server call and wait in kernel if this event is not NULL


A+


ChangeLog:
* allow NtFileFlushBuffers to block, as flushing a named pipe requires this
Index: server/fd.c
===================================================================
RCS file: /home/wine/wine/server/fd.c,v
retrieving revision 1.9
diff -u -r1.9 fd.c
--- server/fd.c	17 Apr 2003 02:14:04 -0000	1.9
+++ server/fd.c	8 May 2003 14:34:40 -0000
@@ -958,7 +958,7 @@
 }
 
 /* default flush() routine */
-int no_flush( struct fd *fd )
+int no_flush( struct fd *fd, struct event **event )
 {
     set_error( STATUS_OBJECT_TYPE_MISMATCH );
     return 0;
@@ -997,10 +997,15 @@
 DECL_HANDLER(flush_file)
 {
     struct fd *fd = get_handle_fd_obj( current->process, req->handle, 0 );
+    struct event * event = NULL;
 
     if (fd)
     {
-        fd->fd_ops->flush( fd );
+        fd->fd_ops->flush( fd, &event );
+        if( event )
+        {
+            reply->event = alloc_handle( current->process, event, SYNCHRONIZE, 0 );
+        }
         release_object( fd );
     }
 }
Index: server/file.c
===================================================================
RCS file: /home/wine/wine/server/file.c,v
retrieving revision 1.67
diff -u -r1.67 file.c
--- server/file.c	26 Mar 2003 23:41:43 -0000	1.67
+++ server/file.c	8 May 2003 14:34:40 -0000
@@ -72,7 +72,7 @@
 
 static int file_get_poll_events( struct fd *fd );
 static void file_poll_event( struct fd *fd, int event );
-static int file_flush( struct fd *fd );
+static int file_flush( struct fd *fd, struct event **event );
 static int file_get_info( struct fd *fd, struct get_file_info_reply *reply, int *flags );
 static void file_queue_async( struct fd *fd, void *ptr, unsigned int status, int type, int count );
 
@@ -301,7 +301,7 @@
 }
 
 
-static int file_flush( struct fd *fd )
+static int file_flush( struct fd *fd, struct event **event )
 {
     int ret = (fsync( get_unix_fd(fd) ) != -1);
     if (!ret) file_set_error();
Index: server/file.h
===================================================================
RCS file: /home/wine/wine/server/file.h,v
retrieving revision 1.7
diff -u -r1.7 file.h
--- server/file.h	26 Mar 2003 23:41:43 -0000	1.7
+++ server/file.h	8 May 2003 14:34:43 -0000
@@ -35,7 +35,7 @@
     /* a poll() event occured */
     void (*poll_event)(struct fd *,int event);
     /* flush the object buffers */
-    int  (*flush)(struct fd *);
+    int  (*flush)(struct fd *, struct event **);
     /* get file information */
     int  (*get_file_info)(struct fd *,struct get_file_info_reply *, int *flags);
     /* queue an async operation - see register_async handler in async.c*/
@@ -60,7 +60,7 @@
 extern void default_fd_remove_queue( struct object *obj, struct wait_queue_entry *entry );
 extern int default_fd_signaled( struct object *obj, struct thread *thread );
 extern void default_poll_event( struct fd *fd, int event );
-extern int no_flush( struct fd *fd );
+extern int no_flush( struct fd *fd, struct event **event );
 extern int no_get_file_info( struct fd *fd, struct get_file_info_reply *info, int *flags );
 extern void no_queue_async( struct fd *fd, void* ptr, unsigned int status, int type, int count );
 extern void main_loop(void);
Index: server/protocol.def
===================================================================
RCS file: /home/wine/wine/server/protocol.def,v
retrieving revision 1.65
diff -u -r1.65 protocol.def
--- server/protocol.def	4 Apr 2003 22:26:34 -0000	1.65
+++ server/protocol.def	8 May 2003 14:34:43 -0000
@@ -665,6 +665,8 @@
 /* Flush a file buffers */
 @REQ(flush_file)
     obj_handle_t handle;        /* handle to the file */
+@REPLY
+    obj_handle_t event;         /* event set when finished */
 @END
 
 
Index: server/serial.c
===================================================================
RCS file: /home/wine/wine/server/serial.c,v
retrieving revision 1.29
diff -u -r1.29 serial.c
--- server/serial.c	12 Mar 2003 22:38:14 -0000	1.29
+++ server/serial.c	8 May 2003 14:34:43 -0000
@@ -58,7 +58,7 @@
 static int serial_get_poll_events( struct fd *fd );
 static void serial_poll_event( struct fd *fd, int event );
 static int serial_get_info( struct fd *fd, struct get_file_info_reply *reply, int *flags );
-static int serial_flush( struct fd *fd );
+static int serial_flush( struct fd *fd, struct event **event );
 static void serial_queue_async(struct fd *fd, void *ptr, unsigned int status, int type, int count);
 
 struct serial
@@ -329,7 +329,7 @@
     set_fd_events ( fd, serial_get_poll_events( fd ));
 }
 
-static int serial_flush( struct fd *fd )
+static int serial_flush( struct fd *fd, struct event **event )
 {
     /* MSDN says: If hFile is a handle to a communications device,
      * the function only flushes the transmit buffer.
Index: dlls/ntdll/file.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/file.c,v
retrieving revision 1.21
diff -u -r1.21 file.c
--- dlls/ntdll/file.c	22 Apr 2003 04:04:17 -0000	1.21
+++ dlls/ntdll/file.c	8 May 2003 14:34:44 -0000
@@ -498,11 +498,19 @@
 NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK* IoStatusBlock )
 {
     NTSTATUS ret;
+    HANDLE hEvent = NULL;
+
     SERVER_START_REQ( flush_file )
     {
         req->handle = hFile;
         ret = wine_server_call( req );
+        hEvent = reply->event;
     }
     SERVER_END_REQ;
+    if( !ret && hEvent )
+    {
+        ret = NtWaitForSingleObject( hEvent, FALSE, NULL );
+        NtClose( hEvent );
+    }
     return ret;
 }

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux