2008-01-20 10:19:31 -05:00
|
|
|
$OpenBSD: patch-libpisock_unixserial_c,v 1.3 2008/01/20 15:19:31 ajacoutot Exp $
|
|
|
|
--- libpisock/unixserial.c.orig Thu Oct 12 16:21:23 2006
|
|
|
|
+++ libpisock/unixserial.c Thu Jan 17 09:00:40 2008
|
|
|
|
@@ -161,13 +161,23 @@ s_open(pi_socket_t *ps, struct pi_sockaddr *addr, size
|
2006-10-20 07:48:06 -04:00
|
|
|
|
|
|
|
struct pi_serial_data *data =
|
|
|
|
(struct pi_serial_data *)ps->device->data;
|
2004-12-10 23:59:46 -05:00
|
|
|
+#define maxretries 100
|
|
|
|
+ int retries;
|
|
|
|
|
|
|
|
#ifndef SGTTY
|
|
|
|
struct termios tcn;
|
|
|
|
#else
|
|
|
|
struct sgttyb tcn;
|
|
|
|
#endif
|
2006-10-20 07:48:06 -04:00
|
|
|
- if ((fd = open(tty, O_RDWR | O_NONBLOCK)) < 0) {
|
2004-12-10 23:59:46 -05:00
|
|
|
+
|
|
|
|
+ for (retries = 0 ; retries <= maxretries ; retries++ ) {
|
|
|
|
+ if ((fd = open(tty, O_RDWR | O_NONBLOCK)) != -1) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ usleep(50000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (fd == -1) {
|
2006-10-20 07:48:06 -04:00
|
|
|
ps->last_error = PI_ERR_GENERIC_SYSTEM;
|
|
|
|
return PI_ERR_GENERIC_SYSTEM; /* errno already set */
|
2004-12-10 23:59:46 -05:00
|
|
|
}
|