bugfix: resend: fix serial_flush
Wolfgang Walter
wine at stwm.de
Sat Dec 20 09:53:26 CST 2008
serial_flush implements FlushFileBuffers for serial devices
FlushFileBuffers should write out any data not yet transmitted but
serial_flush instead discards any data not yet transmitted
This is because it uses tcflush() instead of tcdrain().
Regards,
--
Wolfgang Walter
Studentenwerk München
Anstalt des öffentlichen Rechts
Leiter EDV
Leopoldstraße 15
80802 München
-------------- next part --------------
From 85c73f458dfe8a9ae4c64a27264f9d8de54b00c6 Mon Sep 17 00:00:00 2001
From: Wolfgang Walter <wine at stwm.de>
Date: Fri, 12 Dec 2008 12:54:55 +0100
Subject: serial: fix serial_flush
serial_flush implements FlushFileBuffers for serial devices
FlushFileBuffers should write out any data not yet transmitted but
serial_flush instead discards any data not yet transmitted
This is because it uses tcflush() instead of tcdrain().
---
server/serial.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/server/serial.c b/server/serial.c
index d1b3822..04dc15e 100644
--- a/server/serial.c
+++ b/server/serial.c
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
+#include <errno.h>
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
@@ -201,7 +202,17 @@ static void 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.
*/
- if (tcflush( get_unix_fd(fd), TCOFLUSH ) == -1) file_set_error();
+ /* FlushFileBuffers does NOT have the semantics of tcflush.
+ * Whereas tcflush discards any data not yet transmitted
+ * FlushFileBuffers ensures they are written out.
+ * The POSIX equivalent is tcdrain
+ */
+ while (tcdrain( get_unix_fd(fd)) == -1) {
+ if (errno != EINTR) {
+ file_set_error();
+ return;
+ }
+ }
}
DECL_HANDLER(get_serial_info)
--
1.5.6.5
More information about the wine-patches
mailing list