afs_int64 _##buf##_l[SYNC_PROTO_MAX_LEN/sizeof(afs_int64)]; \
char * buf = (char *)(_##buf##_l)
+#ifdef AFS_LINUX26_ENV
+/* Some Linux kernels have a bug where we are not woken up immediately from a
+ * select() when data is available. Work around this by having a low select()
+ * timeout, so we don't hang in those situations. */
+# define SYNC_SELECT_TIMEOUT 10
+#else
+# define SYNC_SELECT_TIMEOUT 86400
+#endif
+
#ifdef USE_UNIX_SOCKETS
#include <afs/afsutil.h>
#include <sys/un.h>
CallHandler(FSYNC_readfds, nfds, POLLIN|POLLPRI);
#else
int maxfd;
+ struct timeval s_timeout;
GetHandler(&FSYNC_readfds, &maxfd);
+ s_timeout.tv_sec = SYNC_SELECT_TIMEOUT;
+ s_timeout.tv_usec = 0;
/* Note: check for >= 1 below is essential since IOMGR_select
* doesn't have exactly same semantics as select.
*/
#ifdef AFS_PTHREAD_ENV
- if (select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
+ if (select(maxfd + 1, &FSYNC_readfds, NULL, NULL, &s_timeout) >= 1)
#else /* AFS_PTHREAD_ENV */
if (IOMGR_Select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
#endif /* AFS_PTHREAD_ENV */
for (;;) {
int maxfd;
+ struct timeval s_timeout;
GetHandler(&SALVSYNC_readfds, &maxfd);
+ s_timeout.tv_sec = SYNC_SELECT_TIMEOUT;
+ s_timeout.tv_usec = 0;
/* Note: check for >= 1 below is essential since IOMGR_select
* doesn't have exactly same semantics as select.
*/
- if (select(maxfd + 1, &SALVSYNC_readfds, NULL, NULL, NULL) >= 1)
+ if (select(maxfd + 1, &SALVSYNC_readfds, NULL, NULL, &s_timeout) >= 1)
CallHandler(&SALVSYNC_readfds);
}