summaryrefslogtreecommitdiffstats
path: root/usr.bin/talk/ctl_transact.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/talk/ctl_transact.c')
-rw-r--r--usr.bin/talk/ctl_transact.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/talk/ctl_transact.c b/usr.bin/talk/ctl_transact.c
index 81fead6..687de1e 100644
--- a/usr.bin/talk/ctl_transact.c
+++ b/usr.bin/talk/ctl_transact.c
@@ -38,6 +38,7 @@ static const char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93";
#include <arpa/inet.h>
#include <errno.h>
+#include <poll.h>
#include "talk.h"
#include "talk_ctl.h"
@@ -52,23 +53,20 @@ static const char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93";
void
ctl_transact(struct in_addr target, CTL_MSG lmsg, int type, CTL_RESPONSE *rp)
{
- fd_set read_mask, ctl_mask;
+ struct pollfd pfd[1];
int nready = 0, cc;
- struct timeval wait;
lmsg.type = type;
daemon_addr.sin_addr = target;
daemon_addr.sin_port = daemon_port;
- FD_ZERO(&ctl_mask);
- FD_SET(ctl_sockt, &ctl_mask);
+ pfd[0].fd = ctl_sockt;
+ pfd[0].events = POLLIN;
/*
* Keep sending the message until a response of
* the proper type is obtained.
*/
do {
- wait.tv_sec = CTL_WAIT;
- wait.tv_usec = 0;
/* resend message until a response is obtained */
do {
cc = sendto(ctl_sockt, (char *)&lmsg, sizeof (lmsg), 0,
@@ -79,8 +77,7 @@ ctl_transact(struct in_addr target, CTL_MSG lmsg, int type, CTL_RESPONSE *rp)
continue;
p_error("Error on write to talk daemon");
}
- read_mask = ctl_mask;
- nready = select(32, &read_mask, 0, 0, &wait);
+ nready = poll(pfd, 1, CTL_WAIT * 1000);
if (nready < 0) {
if (errno == EINTR)
continue;
@@ -99,10 +96,7 @@ ctl_transact(struct in_addr target, CTL_MSG lmsg, int type, CTL_RESPONSE *rp)
continue;
p_error("Error on read from talk daemon");
}
- read_mask = ctl_mask;
- /* an immediate poll */
- timerclear(&wait);
- nready = select(32, &read_mask, 0, 0, &wait);
+ nready = poll(pfd, 1, 0);
} while (nready > 0 && (rp->vers != TALK_VERSION ||
rp->type != type));
} while (rp->vers != TALK_VERSION || rp->type != type);
OpenPOWER on IntegriCloud