Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2008-04-18 03:49:58 +0400
committerMiguel de Icaza <miguel@gnome.org>2008-04-18 03:49:58 +0400
commitb3108791351ca358a54f95f6f9eaa37a10537455 (patch)
tree23ac31f5d505a24ceac0bd8e8f129712250ba738 /support
parentc1fed75b5a428df7c966b860d7b28fe6ab025147 (diff)
Remove redundant timeout check, de-select, use-poll instead
svn path=/trunk/mono/; revision=101085
Diffstat (limited to 'support')
-rw-r--r--support/serial.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/support/serial.c b/support/serial.c
index 4775805aaf5..abe409e05b6 100644
--- a/support/serial.c
+++ b/support/serial.c
@@ -91,6 +91,13 @@ read_serial (int fd, guchar *buffer, int offset, int count)
int
write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
{
+ struct pollfd pinfo;
+
+ pinfo.fd = fd;
+ pinfo.events = POLLOUT;
+ pinfo.revents = POLLOUT;
+
+
struct timeval tmval;
fd_set writefs;
guint32 n;
@@ -105,12 +112,13 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
{
size_t t;
- if (timeout > 0)
- {
- if (select(fd+1, NULL, &writefs, NULL, &tmval) <= 0 && errno != EINTR)
- {
+ if (timeout > 0) {
+ int c;
+
+ while ((c = poll (&pinfo, 1, timeout)) == -1 && errno == EINTR)
+ ;
+ if (c == -1)
return -1;
- }
}
do {
@@ -120,14 +128,6 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
if (t < 0)
return -1;
- if (timeout > 0)
- {
- if (select(fd+1, NULL, &writefs, NULL, &tmval) <= 0 && errno != EINTR)
- {
- return -1;
- }
- }
-
offset += t;
n -= t;
}