Commit 70afe70e authored by Deucе's avatar Deucе 👌🏾
Browse files

Add new definition for infinite timeout, and use that explicitly

The value of the macro is INT_MIN, not zero to protect agains weird
edge cases.

I considered INT_MAX, but figured you could get there in sane ways.
parent efa03b78
Pipeline #2621 passed with stage
in 9 minutes and 27 seconds
......@@ -30,7 +30,7 @@ size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, const char* termi
while(len < buflen) {
if(!comReadByte(handle, &ch)) {
if(timeout > 0 && msclock()-start >= timeout)
if(timeout != COM_INFINITE_TIMEOUT && msclock()-start >= timeout)
break;
YIELD();
continue;
......
......@@ -38,9 +38,11 @@
#ifndef _COMIO_H
#define _COMIO_H
#include <limits.h> /* INT_MAX */
#include <gen_defs.h> /* BOOL */
#define COM_ERROR -1
#define COM_INFINITE_TIMEOUT INT_MIN
#ifdef _WIN32
#if defined(COMIO_IMPORTS) || defined(COMIO_EXPORTS)
......
......@@ -1592,10 +1592,13 @@ service_loop(int argc, char** argv)
comWriteString(com_handle, banner);
comWriteString(com_handle, "\r\n");
if(prompt[0] != '\0') {
int ptimeout = prompt_timeout * 1000;
if (ptimeout == 0)
ptimeout = COM_INFINITE_TIMEOUT;
parse_tcp_section("TCP");
comWriteString(com_handle, prompt);
char ch;
if(comReadBuf(com_handle, &ch, sizeof(ch), NULL, prompt_timeout * 1000)) {
if(comReadBuf(com_handle, &ch, sizeof(ch), NULL, ptimeout)) {
if(IS_CONTROL(ch))
lprintf(LOG_WARNING, "Received a control character (%d) in response to prompt", ch);
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment