e65e8bb968
With some inputs from steven@ and espie@ ok steven@
29 lines
776 B
Plaintext
29 lines
776 B
Plaintext
$OpenBSD: patch-libpisock_unixserial_c,v 1.2 2006/10/20 11:48:06 ajacoutot Exp $
|
|
--- libpisock/unixserial.c.orig Sun Aug 27 18:08:10 2006
|
|
+++ libpisock/unixserial.c Mon Sep 18 10:49:10 2006
|
|
@@ -159,13 +159,23 @@ s_open(pi_socket_t *ps, struct pi_sockad
|
|
|
|
struct pi_serial_data *data =
|
|
(struct pi_serial_data *)ps->device->data;
|
|
+#define maxretries 100
|
|
+ int retries;
|
|
|
|
#ifndef SGTTY
|
|
struct termios tcn;
|
|
#else
|
|
struct sgttyb tcn;
|
|
#endif
|
|
- if ((fd = open(tty, O_RDWR | O_NONBLOCK)) < 0) {
|
|
+
|
|
+ for (retries = 0 ; retries <= maxretries ; retries++ ) {
|
|
+ if ((fd = open(tty, O_RDWR | O_NONBLOCK)) != -1) {
|
|
+ break;
|
|
+ }
|
|
+ usleep(50000);
|
|
+ }
|
|
+
|
|
+ if (fd == -1) {
|
|
ps->last_error = PI_ERR_GENERIC_SYSTEM;
|
|
return PI_ERR_GENERIC_SYSTEM; /* errno already set */
|
|
}
|