struct sockaddr_un sa_unix;
+ struct timeval stv_timeout;
+ cdtime_t cdt_timeout;
+
sd = socket (PF_UNIX, item->socktype, 0);
if (sd < 0)
{
break;
}
- struct timeval timeout;
- timeout.tv_sec=2;
- if (timeout.tv_sec < interval_g * 3 / 4)
- timeout.tv_sec = interval_g * 3 / 4;
- timeout.tv_usec=0;
- status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout));
+ /* TODO: Remove the macro once interval_g is of type cdtime_t. */
+ cdt_timeout = TIME_T_TO_CDTIME_T (interval_g);
+ cdt_timeout = cdt_timeout * 3 / 4;
+ if (cdt_timeout < TIME_T_TO_CDTIME_T (2))
+ cdt_timeout = TIME_T_TO_CDTIME_T (2);
+
+ CDTIME_T_TO_TIMEVAL (cdt_timeout, &stv_timeout);
+
+ status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &stv_timeout, sizeof (stv_timeout));
if (status != 0)
{
FUNC_ERROR ("setsockopt");
#define CDTIME_T_TO_NS(t) ((long) (((double) (t)) / 1.073741824))
#define CDTIME_T_TO_TIMEVAL(cdt,tvp) do { \
- (tvp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
- (tvp)->tv_used = CDTIME_T_TO_US ((cdt) % 1073741824) \
+ (tvp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
+ (tvp)->tv_usec = CDTIME_T_TO_US ((cdt) % 1073741824); \
} while (0)
-#define TIMEVAL_TO_CDTIME_T(tv) (TIME_T_TO_CDTIME_T ((tv).tv_sec) \
- + US_TO_CDTIME_T ((tv).tv_usec))
+#define TIMEVAL_TO_CDTIME_T(tv) (TIME_T_TO_CDTIME_T ((tv).tv_sec) \
+ + US_TO_CDTIME_T ((tv).tv_usec))
#define CDTIME_T_TO_TIMESPEC(cdt,tsp) do { \
- (tsp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
- (tsp)->tv_nsec = CDTIME_T_TO_NS ((cdt) % 1073741824); \
+ (tsp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
+ (tsp)->tv_nsec = CDTIME_T_TO_NS ((cdt) % 1073741824); \
} while (0)
-#define TIMESPEC_TO_CDTIME_T(ts) (TIME_T_TO_CDTIME_T ((ts).tv_sec) \
- + NS_TO_CDTIME_T ((ts).tv_nsec))
+#define TIMESPEC_TO_CDTIME_T(ts) (TIME_T_TO_CDTIME_T ((ts).tv_sec) \
+ + NS_TO_CDTIME_T ((ts).tv_nsec))
cdtime_t cdtime (void);
#endif /* UTILS_TIME_H */
+/* vim: set sw=2 sts=2 et : */