/*
- * $Id: comm.c,v 1.4 2009-10-13 22:55:37 didg Exp $
+ * $Id: comm.c,v 1.5 2009-10-18 17:50:13 didg Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
#include <sys/socket.h>
#endif
+#include <sys/select.h>
#include <assert.h>
#include <time.h>
* things and clean up fd_table. The same happens for any read/write errors.
*/
-static int check_fd(void)
+static int check_fd(time_t timeout, const sigset_t *sigmask)
{
int fd;
fd_set readfds;
- struct timeval tv;
+ struct timespec tv;
int ret;
int i;
int maxfd = control_fd;
maxfd = fd_table[i].fd;
}
- tv.tv_usec = 0;
- tv.tv_sec = 1;
- if ((ret = select(maxfd + 1, &readfds, NULL, NULL, &tv)) < 0) {
+ tv.tv_nsec = 0;
+ tv.tv_sec = timeout;
+ if ((ret = pselect(maxfd + 1, &readfds, NULL, NULL, &tv, sigmask)) < 0) {
if (errno == EINTR)
return 0;
LOG(log_error, logtype_cnid, "error in select: %s",strerror(errno));
}
/* ------------ */
-int comm_rcv(struct cnid_dbd_rqst *rqst)
+int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask)
{
char *nametmp;
int b;
- if ((cur_fd = check_fd()) < 0)
+ if ((cur_fd = check_fd(timeout, sigmask)) < 0)
return -1;
if (!cur_fd)