mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
1998-06-25 Andi Kleen <ak@muc.de> * inet/rcmd.c (rcmd): Change to use __poll instead of select. * resolv/res_send.c (res_send): Likewise.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
1998-06-25 Andi Kleen <ak@muc.de>
|
||||||
|
|
||||||
|
* inet/rcmd.c (rcmd): Change to use __poll instead of select.
|
||||||
|
* resolv/res_send.c (res_send): Likewise.
|
||||||
|
|
||||||
1998-06-27 12:58 Ulrich Drepper <drepper@cygnus.com>
|
1998-06-27 12:58 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
* sysdeps/unix/bsd/poll.c: Define __poll, make poll weak alias.
|
* sysdeps/unix/bsd/poll.c: Define __poll, make poll weak alias.
|
||||||
|
18
inet/rcmd.c
18
inet/rcmd.c
@ -36,6 +36,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
|||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
|
|||||||
size_t hstbuflen;
|
size_t hstbuflen;
|
||||||
char *tmphstbuf;
|
char *tmphstbuf;
|
||||||
struct sockaddr_in sin, from;
|
struct sockaddr_in sin, from;
|
||||||
fd_set reads;
|
struct pollfd pfd[2];
|
||||||
int32_t oldmask;
|
int32_t oldmask;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int s, lport, timo;
|
int s, lport, timo;
|
||||||
@ -94,6 +95,9 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
|
|||||||
tmphstbuf = __alloca (hstbuflen);
|
tmphstbuf = __alloca (hstbuflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pfd[0].events = POLLIN;
|
||||||
|
pfd[1].events = POLLIN;
|
||||||
|
|
||||||
*ahost = hp->h_name;
|
*ahost = hp->h_name;
|
||||||
oldmask = sigblock(sigmask(SIGURG));
|
oldmask = sigblock(sigmask(SIGURG));
|
||||||
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
|
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
|
||||||
@ -161,18 +165,16 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
|
|||||||
(void)close(s2);
|
(void)close(s2);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
FD_ZERO(&reads);
|
pfd[0].fd = s;
|
||||||
FD_SET(s, &reads);
|
pfd[1].fd = s2;
|
||||||
FD_SET(s2, &reads);
|
|
||||||
__set_errno (0);
|
__set_errno (0);
|
||||||
if (select(1 + (s > s2 ? s : s2), &reads, 0, 0, 0) < 1 ||
|
if (__poll (pfd, 2, -1) < 1 || (pfd[1].revents & POLLIN) == 0){
|
||||||
!FD_ISSET(s2, &reads)) {
|
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
_("rcmd: select (setting up stderr): %m\n"));
|
_("rcmd: poll (setting up stderr): %m\n"));
|
||||||
else
|
else
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
_("select: protocol failure in circuit setup\n"));
|
_("poll: protocol failure in circuit setup\n"));
|
||||||
(void)close(s2);
|
(void)close(s2);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ static char rcsid[] = "$Id$";
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@ -98,16 +99,6 @@ static int s = -1; /* socket used for communications */
|
|||||||
static int connected = 0; /* is the socket connected */
|
static int connected = 0; /* is the socket connected */
|
||||||
static int vc = 0; /* is the socket a virtual circuit? */
|
static int vc = 0; /* is the socket a virtual circuit? */
|
||||||
|
|
||||||
#ifndef FD_SET
|
|
||||||
/* XXX - should be in portability.h */
|
|
||||||
#define NFDBITS 32
|
|
||||||
#define FD_SETSIZE 32
|
|
||||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
|
||||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
|
||||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
|
||||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* XXX - this should be done in portability.h */
|
/* XXX - this should be done in portability.h */
|
||||||
#if (defined(BSD) && (BSD >= 199103)) || defined(linux)
|
#if (defined(BSD) && (BSD >= 199103)) || defined(linux)
|
||||||
# define CAN_RECONNECT 1
|
# define CAN_RECONNECT 1
|
||||||
@ -519,7 +510,7 @@ read_len:
|
|||||||
/*
|
/*
|
||||||
* Use datagrams.
|
* Use datagrams.
|
||||||
*/
|
*/
|
||||||
struct timeval timeout;
|
int timeout;
|
||||||
fd_set dsmask;
|
fd_set dsmask;
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
socklen_t fromlen;
|
socklen_t fromlen;
|
||||||
@ -619,26 +610,24 @@ read_len:
|
|||||||
/*
|
/*
|
||||||
* Wait for reply
|
* Wait for reply
|
||||||
*/
|
*/
|
||||||
timeout.tv_sec = (_res.retrans << try);
|
timeout = (_res.retrans << try) * 1000;
|
||||||
if (try > 0)
|
if (try > 0)
|
||||||
timeout.tv_sec /= _res.nscount;
|
timeout /= _res.nscount;
|
||||||
if ((long) timeout.tv_sec <= 0)
|
if (timeout <= 0)
|
||||||
timeout.tv_sec = 1;
|
timeout = 1000;
|
||||||
timeout.tv_usec = 0;
|
|
||||||
wait:
|
wait:
|
||||||
if (s < 0 || s >= FD_SETSIZE) {
|
if (s < 0 || s >= FD_SETSIZE) {
|
||||||
Perror(stderr, "s out-of-bounds", EMFILE);
|
Perror(stderr, "s out-of-bounds", EMFILE);
|
||||||
res_close();
|
res_close();
|
||||||
goto next_ns;
|
goto next_ns;
|
||||||
}
|
}
|
||||||
FD_ZERO(&dsmask);
|
pfd[0].fd = s;
|
||||||
FD_SET(s, &dsmask);
|
pfd[0].events = POLLIN;
|
||||||
n = select(s+1, &dsmask, (fd_set *)NULL,
|
n = __poll(pfd, 1, timeout);
|
||||||
(fd_set *)NULL, &timeout);
|
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
goto wait;
|
goto wait;
|
||||||
Perror(stderr, "select", errno);
|
Perror(stderr, "poll", errno);
|
||||||
res_close();
|
res_close();
|
||||||
goto next_ns;
|
goto next_ns;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user