Commit 1d6ab32ea572054f8340b202ae511675cba64d8d

Authored by Stéphane Raimbault
1 parent e8dc8cb0

Fix #333455 - Workaround IPTOS_LOWDELAY not supported

- check IPTOS_LOWDELAY define in configure
- generate a config.h
- include the generated config.h in modbus.c
... ... @@ -7,6 +7,8 @@ libmodbus 2.2.0 (2009-05-01)
7 7 - modbus_param_t is smaller (2 int removed)
8 8 - Better error management
9 9 - Faster
  10 +- Fix #333455 reported by Jeff Laughlin
  11 + Cygwin IPTOS_LOWDELAY not supported on cygwin
10 12  
11 13 libmodbus 2.0.3 (2009-03-22)
12 14 ============================
... ...
configure.ac
... ... @@ -4,6 +4,7 @@
4 4 AC_PREREQ(2.59)
5 5 AC_INIT(libmodbus, 2.0.3, stephane.raimbault@gmail.com)
6 6 AC_CONFIG_SRCDIR([src/modbus.c])
  7 +AC_CONFIG_HEADERS([config.h])
7 8 AM_INIT_AUTOMAKE
8 9 AM_DISABLE_STATIC
9 10  
... ... @@ -25,6 +26,9 @@ AC_HEADER_TIME
25 26 AC_TYPE_UINT16_T
26 27 AC_TYPE_UINT32_T
27 28 AC_TYPE_UINT8_T
  29 +AC_CHECK_DECLS([IPTOS_LOWDELAY],
  30 + [have_iptos_lowdelay=yes], [have_iptos_lowdelay=no],
  31 + [#include <netinet/ip.h>])
28 32  
29 33 # Checks for library functions.
30 34 AC_FUNC_FORK
... ...
src/Makefile.am
1 1 lib_LTLIBRARIES = libmodbus.la
2 2 libmodbus_la_SOURCES = modbus.c modbus.h
3 3 libmodbus_la_LDFLAGS = -version-info 2:0:0
  4 +service_CFLAGS = -I$(top_srcdir)/
4 5  
5 6 # Include files to install
6 7 libmodbusincludedir = $(includedir)/modbus
... ...
src/modbus.c
... ... @@ -28,6 +28,7 @@
28 28 http://copyleft.free.fr/wordpress/index.php/libmodbus/
29 29 */
30 30  
  31 +#include <config.h>
31 32 #include <stdio.h>
32 33 #include <string.h>
33 34 #include <stdlib.h>
... ... @@ -1685,6 +1686,7 @@ static int modbus_connect_tcp(modbus_param_t *mb_param)
1685 1686 return ret;
1686 1687 }
1687 1688  
  1689 +#ifdef HAVE_DECL_IPTOS_LOWDELAY
1688 1690 /* Set the IP low delay option */
1689 1691 option = IPTOS_LOWDELAY;
1690 1692 ret = setsockopt(mb_param->fd, IPPROTO_TCP, IP_TOS,
... ... @@ -1694,6 +1696,7 @@ static int modbus_connect_tcp(modbus_param_t *mb_param)
1694 1696 close(mb_param->fd);
1695 1697 return ret;
1696 1698 }
  1699 +#endif
1697 1700  
1698 1701 if (mb_param->debug) {
1699 1702 printf("Connecting to %s\n", mb_param->ip);
... ...