File sendmail-8.13.5-select.dif of Package sendmail

--- libmilter/comm.c
+++ libmilter/comm.c	2006-03-20 14:05:17.000000000 +0100
@@ -80,8 +80,11 @@
 	i = 0;
 	for (;;)
 	{
+		struct timeval tv;
+		tv.tv_sec  = timeout->tv_sec;
+		tv.tv_usec = timeout->tv_usec;
 		FD_RD_INIT(sd, rds, excs);
-		ret = FD_RD_READY(sd, rds, excs, timeout);
+		ret = FD_RD_READY(sd, rds, excs, &tv);
 		if (ret == 0)
 			break;
 		else if (ret < 0)
@@ -153,8 +156,11 @@
 	i = 0;
 	for (;;)
 	{
+		struct timeval tv;
+		tv.tv_sec  = timeout->tv_sec;
+		tv.tv_usec = timeout->tv_usec;
 		FD_RD_INIT(sd, rds, excs);
-		ret = FD_RD_READY(sd, rds, excs, timeout);
+		ret = FD_RD_READY(sd, rds, excs, &tv);
 		if (ret == 0)
 			break;
 		else if (ret < 0)
@@ -253,6 +259,8 @@
 	written = 0;
 	for (;;)
 	{
+		struct timeval tv;
+
 		while (iovcnt > 0 && iov[0].iov_len == 0)
 		{
 			iov++;
@@ -269,8 +277,10 @@
 		**  FD_SETSIZE is checked when socket is created.
 		*/
 
+		tv.tv_sec  = timeout->tv_sec;
+		tv.tv_usec = timeout->tv_usec;
 		FD_WR_INIT(fd, wrs);
-		i = FD_WR_READY(fd, wrs, timeout);
+		i = FD_WR_READY(fd, wrs, &tv);
 		if (i == 0)
 			return MI_FAILURE;
 		if (i < 0)
--- libmilter/listener.c
+++ libmilter/listener.c	2006-03-20 14:02:03.000000000 +0100
@@ -670,12 +670,12 @@
 	int rs = 0;							\
 	struct timeval st;						\
 									\
-	st.tv_sec = (s);						\
-	st.tv_usec = 0;							\
-	if (st.tv_sec > 0)						\
+	if ((s) > 0)							\
 	{								\
 		for (;;)						\
 		{							\
+			st.tv_sec = (s);				\
+			st.tv_usec = 0;					\
 			rs = select(0, NULL, NULL, NULL, &st);		\
 			if (rs < 0 && errno == EINTR)			\
 				continue;				\
--- libsm/local.h
+++ libsm/local.h	2006-03-20 14:02:03.000000000 +0100
@@ -255,8 +255,11 @@
 		return SM_IO_EOF; \
 	do \
 	{	\
+		struct timeval tv;		\
+		tv.tv_sec  = sm_io_to.tv_sec;	\
+		tv.tv_usec = sm_io_to.tv_usec;	\
 		sm_io_to_sel = select((fd) + 1, NULL, &sm_io_to_mask, \
-					&sm_io_x_mask, &sm_io_to); \
+					&sm_io_x_mask, &tv); \
 	} while (sm_io_to_sel < 0 && errno == EINTR); \
 	if (sm_io_to_sel < 0) \
 	{ \
--- libsm/refill.c
+++ libsm/refill.c	2006-03-20 14:02:03.000000000 +0100
@@ -78,8 +78,11 @@
 		return SM_IO_EOF;					\
 	do								\
 	{								\
+		struct timeval tv;					\
+		tv.tv_sec  = (to)->tv_sec;				\
+		tv.tv_usec = (to)->tv_usec;				\
 		(sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL,	\
-			   	&sm_io_x_mask, (to));			\
+			   	&sm_io_x_mask, &tv);			\
 	} while ((sel_ret) < 0 && errno == EINTR);			\
 	if ((sel_ret) < 0)						\
 	{								\
--- sendmail/sfsasl.c
+++ sendmail/sfsasl.c	2006-03-20 14:02:03.000000000 +0100
@@ -601,8 +601,6 @@
 	left = timeout - (now - tlsstart);
 	if (left <= 0)
 		return 0;	/* timeout */
-	tv.tv_sec = left;
-	tv.tv_usec = 0;
 
 	if (LogLevel > 14)
 	{
@@ -635,6 +633,8 @@
 		FD_SET(rfd, &ssl_maskx);
 		do
 		{
+			tv.tv_sec = left;
+			tv.tv_usec = 0;
 			ret = select(rfd + 1, &ssl_maskr, NULL, &ssl_maskx,
 					&tv);
 		} while (ret < 0 && errno == EINTR);
@@ -651,6 +651,8 @@
 		FD_SET(rfd, &ssl_maskx);
 		do
 		{
+			tv.tv_sec = left;
+			tv.tv_usec = 0;
 			ret = select(wfd + 1, NULL, &ssl_maskw, &ssl_maskx,
 					&tv);
 		} while (ret < 0 && errno == EINTR);