summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c7fa720)
raw | patch | inline | side by side (parent: c7fa720)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 14:55:06 +0000 (15:55 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 14:55:06 +0000 (15:55 +0100) |
src/powerdns.c | patch | blob | history | |
src/utils_time.h | patch | blob | history |
diff --git a/src/powerdns.c b/src/powerdns.c
index 29f6bca502c7b48be0ecbadd2bc4befabf337885..508ea506f86cd08a1f2ff52ccae3333ad62ab8dd 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
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");
diff --git a/src/utils_time.h b/src/utils_time.h
index c3928d63466641d593ef2cc7fa10958a9c459125..33384cf11f17c9d175a1d96018ecda66d4a0dc55 100644 (file)
--- a/src/utils_time.h
+++ b/src/utils_time.h
#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 : */