* This file is part of the libserialport project.
*
* Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
- * Copyright (C) 2010-2012 Uwe Hermann <uwe@hermann-uwe.de>
- * Copyright (C) 2013 Martin Ling <martin-libserialport@earth.li>
+ * Copyright (C) 2010-2015 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2013-2015 Martin Ling <martin-libserialport@earth.li>
* Copyright (C) 2013 Matthias Heidbrink <m-sigrok@heidbrink.biz>
* Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include "libserialport.h"
#include "libserialport_internal.h"
* to avoid any issues if a short timeout is reached before
* poll() is even run.
*/
- if (timeout_ms && started) {
+ if (!timeout_ms) {
+ timeout_remaining_ms = -1;
+ } else if (!started) {
+ timeout_remaining_ms = timeout_ms;
+ } else {
gettimeofday(&now, NULL);
if (timercmp(&now, &end, >)) {
DEBUG("Wait timed out");
timeout_remaining_ms = delta.tv_sec * 1000 + delta.tv_usec / 1000;
}
- result = poll(pollfds, event_set->count, timeout_ms ? timeout_remaining_ms : -1);
+ result = poll(pollfds, event_set->count, timeout_remaining_ms);
started = 1;
if (result < 0) {