From affe1ac821b17813188bd91045ced32fe4fcfe56 Mon Sep 17 00:00:00 2001 From: Louis Lagendijk Date: Wed, 20 Apr 2016 10:58:54 +0200 Subject: [PATCH] pixma_bjnp.c pixma_bjnp_private.h: make bjnp protocol follow timeouts set by backend --- backend/pixma_bjnp.c | 16 ++++++++-------- backend/pixma_bjnp_private.h | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/pixma_bjnp.c b/backend/pixma_bjnp.c index 19bb5827f..7e09666a0 100644 --- a/backend/pixma_bjnp.c +++ b/backend/pixma_bjnp.c @@ -706,8 +706,8 @@ udp_command (const int dev_no, char *command, int cmd_len, char *response, FD_ZERO (&fdset); FD_SET (sockfd, &fdset); - timeout.tv_sec = BJNP_TIMEOUT_UDP; - timeout.tv_usec = 0; + timeout.tv_sec = device[dev_no].bjnp_timeout /1000; + timeout.tv_usec = device[dev_no].bjnp_timeout %1000; } while (((result = select (sockfd + 1, &fdset, NULL, NULL, &timeout)) <= 0) @@ -737,7 +737,7 @@ udp_command (const int dev_no, char *command, int cmd_len, char *response, close(sockfd); PDBG (bjnp_dbg - (LOG_CRIT, "udp_command: ERROR - no data received\n" ) ); + (LOG_CRIT, "udp_command: ERROR - no data received (timeout = %d)\n", device[dev_no].bjnp_timeout ) ); return -1; } @@ -1423,8 +1423,8 @@ bjnp_recv_header (int devno, size_t *payload_size ) FD_ZERO (&input); FD_SET (fd, &input); - timeout.tv_sec = BJNP_TIMEOUT_TCP; - timeout.tv_usec = 0; + timeout.tv_sec = device[devno].bjnp_timeout /1000; + timeout.tv_usec = device[devno].bjnp_timeout %1000; } while ( ( (result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); @@ -1524,7 +1524,7 @@ bjnp_init_device_structure(int dn, bjnp_sockaddr_t *sa, bjnp_protocol_defs_t *pr device[dn].address_level = get_scanner_name(sa, name); device[dn].session_id = 0; device[dn].serial = -1; - device[dn].bjnp_timeout = 0; + device[dn].bjnp_timeout = 1000; device[dn].scanner_data_left = 0; device[dn].last_cmd = 0; device[dn].blocksize = BJNP_BLOCKSIZE_START; @@ -1597,8 +1597,8 @@ bjnp_recv_data (int devno, SANE_Byte * buffer, size_t start_pos, size_t * len) /* wait for data to be received, retry on a signal being received */ FD_ZERO (&input); FD_SET (fd, &input); - timeout.tv_sec = BJNP_TIMEOUT_TCP; - timeout.tv_usec = 0; + timeout.tv_sec = device[devno].bjnp_timeout /1000; + timeout.tv_usec = device[devno].bjnp_timeout %1000; } while (((result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); diff --git a/backend/pixma_bjnp_private.h b/backend/pixma_bjnp_private.h index 1902c7acf..a8b4a2f94 100644 --- a/backend/pixma_bjnp_private.h +++ b/backend/pixma_bjnp_private.h @@ -80,8 +80,6 @@ /* timers */ #define BJNP_BROADCAST_INTERVAL 10 /* ms between broadcasts */ #define BJNP_BC_RESPONSE_TIMEOUT 500 /* waiting time for broadc. responses */ -#define BJNP_TIMEOUT_UDP 4 /* standard UDP timeout in seconds */ -#define BJNP_TIMEOUT_TCP 4 /* standard TCP timeout in seconds */ #define BJNP_USLEEP_MS 1000 /* sleep for 1 msec */ /* retries */