1234567891011121314151617181920212223242526272829 |
- $OpenBSD: patch-libpisock_unixserial_c,v 1.5 2015/09/21 08:46:50 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
-
- 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 */
- }
|