stephane/libmodbus — pull request #80 by pjkundert (2012-09-14 18:40:41+00:00)
Title: Fix timeout mutation

The modbus_set_response_timeout() API stores a timeout, that is subsequently used to limit TCP/IP connect() requests. Unfortunately, the C select() API on Linux is allowed to mutate the provided struct timeval. This results in permanent changes to the struct timeval representing the timeout, in the modbus_t structure! This is (at best) unexpected, because most users of the libmodbus API would expect that the timeout specified using a modbus_set_response_timeout() call should remain as they specified it, for all future libmodbus API calls, until it is changed using a subsequent modbus_set_response_timeout call.

The attached commits update the API to specify that the modbus_t's timeout is never passed by reference in a mutable way (use "const timeval *" instead of "timeval *"), and a copy of the provided timeval is used in calls to select(), to avoid corrupting the original.