#include <sys/errno.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
+#include <pthread.h>
+
+pthread_mutex_t __thr_mutex = PTHREAD_MUTEX_INITIALIZER;
extern int errno;
#endif
SVCXPRT *xprt;
{
register int sock = xprt->xp_sock;
+#ifdef WIN32
+ EnterCriticalSection(&__thr_mutex);
+#else
+ pthread_mutex_lock(&__thr_mutex);
+#endif
#ifdef FD_SETSIZE
if (xports == NULL) {
nt_rpc_report(str);
}
#else
- if (sock < _rpc_dtablesize()) {
+ if (sock < FD_SETSIZE) {
xports[sock] = xprt;
FD_SET(sock, &svc_fdset);
}
}
#endif /* def FD_SETSIZE */
+#ifdef WIN32
+ LeaveCriticalSection(&__thr_mutex);
+#else
+ pthread_mutex_unlock(&__thr_mutex);
+#endif
}
/*
SVCXPRT *xprt;
{
register int sock = xprt->xp_sock;
+#ifdef WIN32
+ EnterCriticalSection(&__thr_mutex);
+#else
+ pthread_mutex_lock(&__thr_mutex);
+#endif
#ifdef FD_SETSIZE
#ifdef WIN32
xports[sock] = (SVCXPRT *)0;
FD_CLR((unsigned)sock, &svc_fdset);
#else
- if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) {
+ if ((sock < FD_SETSIZE) && (xports[sock] == xprt)) {
xports[sock] = (SVCXPRT *)0;
FD_CLR(sock, &svc_fdset);
#endif
svc_fds &= ~(1 << sock);
}
#endif /* def FD_SETSIZE */
+
+#ifdef WIN32
+ LeaveCriticalSection(&__thr_mutex);
+#else
+ pthread_mutex_unlock(&__thr_mutex);
+#endif
}
for ( i=0; i<readfds->fd_count; i++ ) {
sock = readfds->fd_array[i];
/* sock has input waiting */
- xprt = xports[sock];
+ EnterCriticalSection(&__thr_mutex);
+ xprt = xports[sock];
+ LeaveCriticalSection(&__thr_mutex);
#else
- setsize = _rpc_dtablesize();
+ setsize = FD_SETSIZE;
maskp = (u_long *)readfds->fds_bits;
for (sock = 0; sock < setsize; sock += NFDBITS) {
for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) {
/* sock has input waiting */
- xprt = xports[sock + bit - 1];
+ pthread_mutex_lock(&__thr_mutex);
+ xprt = xports[sock + bit - 1];
+ pthread_mutex_unlock(&__thr_mutex);
#endif
#else
for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) {
if ((readfds_local & 1) != 0) {
/* sock has input waiting */
- xprt = xports[sock];
+ pthread_mutex_lock(&__thr_mutex);
+ xprt = xports[sock];
+ pthread_mutex_unlock(&__thr_mutex);
#endif /* def FD_SETSIZE */
/* now receive msgs from xprtprt (support batch calls) */
do {
} while (stat == XPRT_MOREREQS);
}
}
+#if !defined(FD_SETSIZE) || !defined(WIN32)
}
+#endif