diff options
author | jasone <jasone@FreeBSD.org> | 2000-01-27 23:07:25 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-01-27 23:07:25 +0000 |
commit | 8abe2a2d86ee5f72093b3feeabf05c9f6f963576 (patch) | |
tree | 2ebe01199c17764ebcd26435b5ce1c06ebb67ad5 /lib/libc/net | |
parent | 1731b249ccd9d7586d511eda8756f5c6b57b871c (diff) | |
download | FreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.zip FreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.tar.gz |
Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
just use _foo() <-- foo(). In the case of a libpthread that doesn't do
call conversion (such as linuxthreads and our upcoming libpthread), this
is adequate. In the case of libc_r, we still need three names, which are
now _thread_sys_foo() <-- _foo() <-- foo().
Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(),
nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo().
Remove all internal libc usage of: creat(), pause(), sleep(), system(),
tcdrain(), wait(), and waitpid().
Make thread cancellation fully POSIX-compliant.
Suggested by: deischen
Diffstat (limited to 'lib/libc/net')
-rw-r--r-- | lib/libc/net/getaddrinfo.c | 2 | ||||
-rw-r--r-- | lib/libc/net/name6.c | 10 | ||||
-rw-r--r-- | lib/libc/net/rcmd.c | 45 | ||||
-rw-r--r-- | lib/libc/net/res_send.c | 10 |
4 files changed, 36 insertions, 31 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 414898e..9f0a47a 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -578,7 +578,7 @@ explore_null(pai, hostname, servname, res) s = socket(pai->ai_family, SOCK_DGRAM, 0); if (s < 0) return 0; - _libc_close(s); + _close(s); afd = find_afd(pai->ai_family); if (afd == NULL) return 0; diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index e3ddf3e..3f39d03 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -257,7 +257,7 @@ _ghbyname(const char *name, int af, int flags, int *errp) * (or apropriate interval), * because addresses will be dynamically assigned or deleted. */ - _libc_close(s); + _close(s); } for (i = 0; i < MAXHOSTCONF; i++) { @@ -1184,21 +1184,21 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) (char *)&filter, sizeof(filter)); cc = sendmsg(s, &msg, 0); if (cc < 0) { - _libc_close(s); + _close(s); return NULL; } FD_SET(s, &s_fds); for (;;) { fds = s_fds; if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) { - _libc_close(s); + _close(s); return NULL; } len = sizeof(sin6); cc = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin6, &len); if (cc <= 0) { - _libc_close(s); + _close(s); return NULL; } if (cc < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) @@ -1209,7 +1209,7 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) if (fr->icmp6_fqdn_type == ICMP6_FQDN_REPLY) break; } - _libc_close(s); + _close(s); if (fr->icmp6_fqdn_cookie[1] != 0) { /* rfc1788 type */ name = buf + sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) + 4; diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 96d5bab..1448f14 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -136,10 +136,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) freeaddrinfo(res); return (-1); } - _libc_fcntl(s, F_SETOWN, pid); + _fcntl(s, F_SETOWN, pid); if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) break; - (void)_libc_close(s); + (void)_close(s); if (errno == EADDRINUSE) { lport--; continue; @@ -166,7 +166,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) continue; } if (refused && timo <= 16) { - (void)_libc_sleep(timo); + struct timespec time_to_sleep, time_remaining; + + time_to_sleep.tv_sec = timo; + time_to_sleep.tv_nsec = 0; + (void)_nanosleep(&time_to_sleep, &time_remaining); + timo *= 2; ai = res; refused = 0; @@ -179,7 +184,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) } lport--; if (fd2p == 0) { - _libc_write(s, "", 1); + _write(s, "", 1); lport = 0; } else { char num[8]; @@ -191,17 +196,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) goto bad; listen(s2, 1); (void)snprintf(num, sizeof(num), "%d", lport); - if (_libc_write(s, num, strlen(num)+1) != strlen(num)+1) { + if (_write(s, num, strlen(num)+1) != strlen(num)+1) { (void)fprintf(stderr, "rcmd: write (setting up stderr): %s\n", strerror(errno)); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } nfds = max(s, s2)+1; if(nfds > FD_SETSIZE) { fprintf(stderr, "rcmd: too many files\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } again: @@ -217,7 +222,7 @@ again: else (void)fprintf(stderr, "select: protocol failure in circuit setup\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); @@ -239,10 +244,10 @@ again: * down and check for the real auxiliary channel to connect. */ if (aport == 20) { - _libc_close(s3); + _close(s3); goto again; } - (void)_libc_close(s2); + (void)_close(s2); if (s3 < 0) { (void)fprintf(stderr, "rcmd: accept: %s\n", strerror(errno)); @@ -256,17 +261,17 @@ again: goto bad2; } } - (void)_libc_write(s, locuser, strlen(locuser)+1); - (void)_libc_write(s, remuser, strlen(remuser)+1); - (void)_libc_write(s, cmd, strlen(cmd)+1); - if (_libc_read(s, &c, 1) != 1) { + (void)_write(s, locuser, strlen(locuser)+1); + (void)_write(s, remuser, strlen(remuser)+1); + (void)_write(s, cmd, strlen(cmd)+1); + if (_read(s, &c, 1) != 1) { (void)fprintf(stderr, "rcmd: %s: %s\n", *ahost, strerror(errno)); goto bad2; } if (c != 0) { - while (_libc_read(s, &c, 1) == 1) { - (void)_libc_write(STDERR_FILENO, &c, 1); + while (_read(s, &c, 1) == 1) { + (void)_write(STDERR_FILENO, &c, 1); if (c == '\n') break; } @@ -277,9 +282,9 @@ again: return (s); bad2: if (lport) - (void)_libc_close(*fd2p); + (void)_close(*fd2p); bad: - (void)_libc_close(s); + (void)_close(s); sigsetmask(oldmask); freeaddrinfo(res); return (-1); @@ -328,13 +333,13 @@ rresvport_af(alport, family) if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return (s); if (errno != EADDRINUSE) { - (void)_libc_close(s); + (void)_close(s); return (-1); } #endif *sport = 0; if (bindresvport_sa(s, (struct sockaddr *)&ss) == -1) { - (void)_libc_close(s); + (void)_close(s); return (-1); } *alport = (int)ntohs(*sport); diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index b57b8db..68a7c60 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -428,7 +428,7 @@ res_send(buf, buflen, ans, anssiz) read_len: cp = ans; len = INT16SZ; - while ((n = _libc_read(s, (char *)cp, (int)len)) > 0) { + while ((n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) <= 0) break; @@ -476,7 +476,7 @@ read_len: } cp = ans; while (len != 0 && - (n = _libc_read(s, (char *)cp, (int)len)) > 0) { + (n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } @@ -499,7 +499,7 @@ read_len: n = (len > sizeof(junk) ? sizeof(junk) : len); - if ((n = _libc_read(s, junk, n)) > 0) + if ((n = _read(s, junk, n)) > 0) len -= n; else break; @@ -608,7 +608,7 @@ read_len: if (s1 < 0) goto bad_dg_sock; (void)dup2(s1, s); - (void)_libc_close(s1); + (void)_close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n")) #endif /* CAN_RECONNECT */ @@ -893,7 +893,7 @@ void res_close() { if (s >= 0) { - (void)_libc_close(s); + (void)_close(s); s = -1; connected = 0; vc = 0; |