summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/svc_unix.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
committerdeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
commit1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch)
treed7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/rpc/svc_unix.c
parent08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff)
downloadFreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip
FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
Diffstat (limited to 'lib/libc/rpc/svc_unix.c')
-rw-r--r--lib/libc/rpc/svc_unix.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libc/rpc/svc_unix.c b/lib/libc/rpc/svc_unix.c
index dc680d0..ac92bc5 100644
--- a/lib/libc/rpc/svc_unix.c
+++ b/lib/libc/rpc/svc_unix.c
@@ -43,6 +43,7 @@ static char *rcsid = "$FreeBSD$";
* and a record/unix stream.
*/
+#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -52,6 +53,7 @@ static char *rcsid = "$FreeBSD$";
#include <sys/un.h>
#include <sys/uio.h>
#include <errno.h>
+#include "un-namespace.h"
/*
* Ops vector for AF_UNIX based rpc service handle
@@ -130,7 +132,7 @@ static int __msgread(sock, buf, cnt)
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
- return(recvmsg(sock, &msg, 0));
+ return(_recvmsg(sock, &msg, 0));
}
static int __msgwrite(sock, buf, cnt)
@@ -157,7 +159,7 @@ static int __msgwrite(sock, buf, cnt)
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
- return(sendmsg(sock, &msg, 0));
+ return(_sendmsg(sock, &msg, 0));
}
/*
@@ -194,7 +196,7 @@ svcunix_create(sock, sendsize, recvsize, path)
int len = sizeof(struct sockaddr_un);
if (sock == RPC_ANYSOCK) {
- if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+ if ((sock = _socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror("svc_unix.c - AF_UNIX socket creation problem");
return ((SVCXPRT *)NULL);
}
@@ -207,10 +209,10 @@ svcunix_create(sock, sendsize, recvsize, path)
sizeof(addr.sun_len) + 1;
addr.sun_len = len;
- bind(sock, (struct sockaddr *)&addr, len);
+ _bind(sock, (struct sockaddr *)&addr, len);
- if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) ||
- (listen(sock, 2) != 0)) {
+ if ((_getsockname(sock, (struct sockaddr *)&addr, &len) != 0) ||
+ (_listen(sock, 2) != 0)) {
perror("svc_unix.c - cannot getsockname or listen");
if (madesock)
(void)_close(sock);
@@ -301,7 +303,7 @@ rendezvous_request(xprt)
r = (struct unix_rendezvous *)xprt->xp_p1;
again:
len = sizeof(struct sockaddr_in);
- if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr,
+ if ((sock = _accept(xprt->xp_sock, (struct sockaddr *)&addr,
&len)) < 0) {
if (errno == EINTR)
goto again;
@@ -359,7 +361,7 @@ static struct timeval wait_per_try = { 35, 0 };
* Note: we have to be careful here not to allow ourselves to become
* blocked too long in this routine. While we're waiting for data from one
* client, another client may be trying to connect. To avoid this situation,
- * some code from svc_run() is transplanted here: the select() loop checks
+ * some code from svc_run() is transplanted here: the _select() loop checks
* all RPC descriptors including the one we want and calls svc_getreqset2()
* to handle new requests if any are detected.
*/
@@ -391,8 +393,8 @@ readunix(xprt, buf, len)
/* XXX we know the other bits are still clear */
FD_SET(sock, fds);
- tv = delta; /* in case select() implements writeback */
- switch (select(svc_maxfd + 1, fds, NULL, NULL, &tv)) {
+ tv = delta; /* in case _select() implements writeback */
+ switch (_select(svc_maxfd + 1, fds, NULL, NULL, &tv)) {
case -1:
if (errno != EINTR)
goto fatal_err;
OpenPOWER on IntegriCloud