- diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
- index 36b6c4f..0694ed6 100644
- --- a/build.vc19/libtirpc/libtirpc.vcxproj
- +++ b/build.vc19/libtirpc/libtirpc.vcxproj
- @@ -87,7 +87,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>FD_SETSIZE=128;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- @@ -103,7 +103,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>FD_SETSIZE=128;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- @@ -121,7 +121,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>FD_SETSIZE=128;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- @@ -141,7 +141,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>FD_SETSIZE=128;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 1d1eac4..4297722 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -223,6 +223,18 @@ static int map_name_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_l
- name = "roland_mainz";
- dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
- }
- + else if (!strcmp(name, "swulsch")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap swulsch --> siegfried_wulsch\n");
- + }
- + else if (!strcmp(name, "197609")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap 197609 --> siegfried_wulsch\n");
- + }
- + else if (!strcmp(name, "1818")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap 1818 --> siegfried_wulsch\n");
- + }
- }
- #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index 7c5f241..ee9f5e1 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -80,6 +80,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- nfs41_open_state *state = upcall->state_ref;
- nfs41_file_info info = { 0 };
- +#if 1
- + if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
- + eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- + EASSERT(state->file.fh.superblock != NULL);
- + if (state->file.fh.superblock == NULL) {
- + /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +#endif
- +
- status = nfs41_cached_getattr(state->session, &state->file, &info);
- if (status) {
- eprintf("nfs41_cached_getattr() failed with %d\n", status);
- diff --git a/daemon/idmap.c b/daemon/idmap.c
- index 00af1fe..6947b6c 100644
- --- a/daemon/idmap.c
- +++ b/daemon/idmap.c
- @@ -133,7 +133,7 @@ static const struct config_option g_options[] = {
- OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID),
- /* caching configuration */
- - OPT_INT("cache_ttl", "60", cache_ttl),
- + OPT_INT("cache_ttl", "6000", cache_ttl),
- };
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 3f944fd..5bb6aee 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -351,12 +351,24 @@ static void copy_attrs(
- dst->type = src->type;
- dst->numlinks = src->numlinks;
- dst->mode = src->mode;
- - EASSERT(src->owner != NULL);
- + EASSERT(src->owner[0] != '\0');
- + if (src->owner[0] != '\0') {
- dst->owner = dst->owner_buf;
- (void)strcpy(dst->owner, src->owner);
- - EASSERT(src->owner_group != NULL);
- + }
- + else {
- + /* this should only happen for newly created files7dirs */
- + dst->owner = NULL;
- + }
- + EASSERT(src->owner_group[0] != '\0');
- + if (src->owner_group[0] != '\0') {
- dst->owner_group = dst->owner_group_buf;
- (void)strcpy(dst->owner_group, src->owner_group);
- + }
- + else {
- + /* this should only happen for newly created files7dirs */
- + dst->owner_group = NULL;
- + }
- dst->fileid = src->fileid;
- dst->hidden = src->hidden;
- dst->system = src->system;
- @@ -369,8 +381,11 @@ static void copy_attrs(
- dst->attrmask.arr[1] = FATTR4_WORD1_MODE
- | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
- | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
- - | FATTR4_WORD1_SYSTEM
- - | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- + | FATTR4_WORD1_SYSTEM;
- + if (dst->owner)
- + dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- + if (dst->owner_group)
- + dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- }
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 9bde0f0..6889a79 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -1815,6 +1815,7 @@ static bool_t decode_file_attrs(
- EASSERT(owner_len > 0);
- EASSERT(owner_len < sizeof(info->owner_group_buf));
- info->owner[owner_len] = '\0';
- + EASSERT(info->owner[0] != '\0');
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- if (info->owner_group == NULL)
- @@ -1830,6 +1831,7 @@ static bool_t decode_file_attrs(
- EASSERT(owner_group_len > 0);
- EASSERT(owner_group_len < sizeof(info->owner_group_buf));
- info->owner_group[owner_group_len] = '\0';
- + EASSERT(info->owner_group[0] != '\0');
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
- if (!xdr_u_hyper(xdr, &info->space_avail))
- diff --git a/daemon/open.c b/daemon/open.c
- index a9ffcb0..1f8bd54 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -99,6 +99,24 @@ static void open_state_free(
- void nfs41_open_state_ref(
- IN nfs41_open_state *state)
- {
- +#if 1
- + /*
- + * gisburn: fixme: sometimes this happens under high parallel
- + * usage with multiple mounts - but why ?
- + * 0:038> kp
- + * Child-SP RetAddr Call Site
- + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
- + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
- + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
- + * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
- + * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
- + * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
- + */
- + EASSERT(state != NULL);
- + if (state == NULL)
- + return;
- +#endif
- +
- const LONG count = InterlockedIncrement(&state->ref_count);
- dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
- @@ -669,12 +687,47 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- gid_t map_gid = -1;
- char *at_ch; /* pointer to '@' */
- +#if 1
- + /* this should only happen for newly created files/dirs */
- + if (((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) == 0) ||
- + ((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) == 0)) {
- + bitmap4 og_attr_request = { 0 };
- + nfs41_file_info og_info = { 0 };
- + nfsacl41 acl = { 0 };
- +
- + og_attr_request.count = 2;
- + og_attr_request.arr[1] =
- + FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- + og_info.owner = og_info.owner_buf;
- + og_info.owner_group = og_info.owner_group_buf;
- + status = nfs41_getattr(state->session, &state->file,
- + &og_attr_request, &og_info);
- + if (status) {
- + eprintf("get_stat_data: nfs41_getattr('%s') "
- + "failed with %d\n",
- + state->path.path,
- + status);
- + goto out_free_state;
- + }
- +
- + info.owner = info.owner_buf;
- + (void)strcpy(info.owner, og_info.owner);
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- + info.owner_group = info.owner_group_buf;
- + (void)strcpy(info.owner_group, og_info.owner_group);
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- + }
- +#endif
- +
- EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
- EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
- EASSERT(info.owner != NULL);
- EASSERT(info.owner_group != NULL);
- EASSERT(info.owner == info.owner_buf);
- EASSERT(info.owner_group == info.owner_group_buf);
- + EASSERT(strlen(info.owner) > 0);
- + EASSERT(strlen(info.owner_group) > 0);
- +
- /* Make copies as we will modify them */
- (void)strcpy(owner, info.owner);
- (void)strcpy(owner_group, info.owner_group);
- @@ -698,8 +751,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- }
- else {
- args->owner_local_uid = NFS_USER_NOBODY_UID;
- - eprintf("get_stat_data: "
- + eprintf("get_stat_data('%s'): "
- "no username mapping for '%s', fake uid=%d\n",
- + state->path.path,
- owner, args->owner_local_uid);
- }
- @@ -721,12 +775,14 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- }
- else {
- args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
- - eprintf("get_stat_data: "
- + eprintf("get_stat_data('%s'): "
- "no group mapping for '%s', fake gid=%d\n",
- + state->path.path,
- owner_group, args->owner_group_local_gid);
- }
- - dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
- + dprintf(1, "handle_open('%s'): stat: owner=%u/'%s', owner_group=%u/'%s'\n",
- + state->path.path,
- (unsigned int)args->owner_local_uid, owner,
- (unsigned int)args->owner_group_local_gid, owner_group);
- #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
- diff --git a/daemon/util.c b/daemon/util.c
- index 07aa2c6..c482624 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -207,7 +207,9 @@ void nfs41_file_info_cpy(
- IN const nfs41_file_info *src)
- {
- (void)memcpy(dest, src, sizeof(nfs41_file_info));
- + if (src->owner != NULL)
- dest->owner = dest->owner_buf;
- + if (src->owner_group != NULL)
- dest->owner_group = dest->owner_group_buf;
- }
- diff --git a/libtirpc/src/auth_time.c b/libtirpc/src/auth_time.c
- index ad8e521..596de50 100644
- --- a/libtirpc/src/auth_time.c
- +++ b/libtirpc/src/auth_time.c
- @@ -250,7 +250,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- nis_server tsrv;
- void (*oldsig)() = NULL; /* old alarm handler */
- struct sockaddr_in sin;
- - SOCKET s = RPC_ANYSOCK;
- + int s = RPC_ANYSOCK;
- socklen_t len;
- int type = 0;
- @@ -377,8 +377,8 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- goto error;
- }
- - s = socket(AF_INET, type, 0);
- - if (s == INVALID_SOCKET) {
- + s = wintirpc_socket(AF_INET, type, 0);
- + if (s == -1) {
- msg("unable to open fd to network.");
- goto error;
- }
- @@ -393,21 +393,21 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- fd_set readfds;
- int res;
- - if (sendto(s, (const char *)&thetime, sizeof(thetime), 0,
- + if (sendto(_get_osfhandle(s), (const char *)&thetime, sizeof(thetime), 0,
- (struct sockaddr *)&sin, sizeof(sin)) == -1) {
- msg("udp : sendto failed.");
- goto error;
- }
- do {
- FD_ZERO(&readfds);
- - FD_SET(s, &readfds);
- + FD_SET(_get_osfhandle(s), &readfds);
- res = select(_rpc_dtablesize(), &readfds,
- (fd_set *)NULL, (fd_set *)NULL, &timeout);
- } while (res == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
- if (res == SOCKET_ERROR)
- goto error;
- len = sizeof(from);
- - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0,
- + res = recvfrom(_get_osfhandle(s), (char *)&thetime, sizeof(thetime), 0,
- (struct sockaddr *)&from, &len);
- if (res == SOCKET_ERROR) {
- msg("recvfrom failed on udp transport.");
- @@ -424,7 +424,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- saw_alarm = 0;
- /* XXX Need Windows signal/alarm stuff here XXX */
- #endif
- - res = connect(s, (struct sockaddr *)&sin, sizeof(sin));
- + res = connect(_get_osfhandle(s), (struct sockaddr *)&sin, sizeof(sin));
- if (res == SOCKET_ERROR) {
- msg("failed to connect to tcp endpoint.");
- goto error;
- @@ -433,8 +433,8 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- msg("alarm caught it, must be unreachable.");
- goto error;
- }
- -// res = read(s, (char *)&thetime, sizeof(thetime));
- - res = recv(s, (char *)&thetime, sizeof(thetime), 0);
- +// res = read(_get_osfhandle(s), (char *)&thetime, sizeof(thetime));
- + res = recv(_get_osfhandle(s), (char *)&thetime, sizeof(thetime), 0);
- if (res != sizeof(thetime)) {
- if (saw_alarm)
- msg("timed out TCP call.");
- @@ -446,7 +446,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
- time_valid = 1;
- }
- save = WSAGetLastError();
- - (void)closesocket(s);
- + (void)wintirpc_closesocket(s);
- errno = save;
- s = RPC_ANYSOCK;
- @@ -465,7 +465,7 @@ error:
- */
- if (s != RPC_ANYSOCK)
- - (void)closesocket(s);
- + (void)wintirpc_closesocket(s);
- if (clnt != NULL)
- clnt_destroy(clnt);
- diff --git a/libtirpc/src/bindresvport.c b/libtirpc/src/bindresvport.c
- index c1f0d9b..f64ff58 100644
- --- a/libtirpc/src/bindresvport.c
- +++ b/libtirpc/src/bindresvport.c
- @@ -51,7 +51,7 @@
- */
- int
- bindresvport(sd, sin)
- - SOCKET sd;
- + int sd;
- struct sockaddr_in *sin;
- {
- return bindresvport_sa(sd, (struct sockaddr *)sin);
- @@ -87,7 +87,7 @@ bindresvport_sa(sd, sa)
- salen = sizeof(myaddr);
- sa = (struct sockaddr *)&myaddr;
- - if (getsockname(sd, (struct sockaddr *)&myaddr, &salen) == -1)
- + if (getsockname(_get_osfhandle(sd), (struct sockaddr *)&myaddr, &salen) == -1)
- return -1; /* errno is correctly set */
- af = myaddr.ss_family;
- @@ -125,7 +125,7 @@ bindresvport_sa(sd, sa)
- *portp = htons(port++);
- if (port > endport)
- port = startport;
- - res = bind(sd, sa, salen);
- + res = bind(_get_osfhandle(sd), sa, salen);
- if (res >= 0 || errno != EADDRINUSE)
- break;
- }
- @@ -144,7 +144,7 @@ bindresvport_sa(sd, sa)
- #if defined(_WIN32)
- int
- -bindresvport_sa(SOCKET sd, struct sockaddr *sa)
- +bindresvport_sa(int sd, struct sockaddr *sa)
- {
- fprintf(stderr, "Do-nothing bindresvport_sa!\n");
- return 0;
- @@ -159,7 +159,7 @@ bindresvport_sa(SOCKET sd, struct sockaddr *sa)
- */
- int
- bindresvport_sa(sd, sa)
- - SOCKET sd;
- + int sd;
- struct sockaddr *sa;
- {
- #ifdef IPV6_PORTRANGE
- @@ -185,13 +185,13 @@ bindresvport_sa(sd, sa)
- #ifdef _WIN32
- memset(sa, 0, salen);
- - if (error = getsockopt(sd, SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
- + if (error = getsockopt(_get_osfhandle(sd), SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
- int sockerr = WSAGetLastError();
- return -1;
- }
- af = proto_info.iAddressFamily;
- #else
- - if (getsockname(sd, sa, &salen) == -1)
- + if (getsockname(_get_osfhandle(sd), sa, &salen) == -1)
- return -1; /* errno is correctly set */
- af = sa->sa_family;
- @@ -231,18 +231,18 @@ bindresvport_sa(sd, sa)
- if (*portp == 0) {
- socklen_t oldlen = sizeof(old);
- - error = getsockopt(sd, proto, portrange, &old, &oldlen);
- + error = getsockopt(_get_osfhandle(sd), proto, portrange, &old, &oldlen);
- if (error < 0)
- return (error);
- - error = setsockopt(sd, proto, portrange, &portlow,
- + error = setsockopt(_get_osfhandle(sd), proto, portrange, &portlow,
- sizeof(portlow));
- if (error < 0)
- return (error);
- }
- #endif
- - error = bind(sd, sa, salen);
- + error = bind(_get_osfhandle(sd), sa, salen);
- if (error) {
- int err = WSAGetLastError();
- }
- @@ -252,7 +252,7 @@ bindresvport_sa(sd, sa)
- int saved_errno = errno;
- if (error < 0) {
- - if (setsockopt(sd, proto, portrange, &old,
- + if (setsockopt(_get_osfhandle(sd), proto, portrange, &old,
- sizeof(old)) < 0)
- errno = saved_errno;
- return (error);
- @@ -260,7 +260,7 @@ bindresvport_sa(sd, sa)
- if (sa != (struct sockaddr *)&myaddr) {
- /* Hmm, what did the kernel assign? */
- - if (getsockname(sd, sa, &salen) < 0)
- + if (getsockname(_get_osfhandle(sd), sa, &salen) < 0)
- errno = saved_errno;
- return (error);
- }
- diff --git a/libtirpc/src/clnt_bcast.c b/libtirpc/src/clnt_bcast.c
- index 8d32c5d..54ce1d2 100644
- --- a/libtirpc/src/clnt_bcast.c
- +++ b/libtirpc/src/clnt_bcast.c
- @@ -60,6 +60,7 @@
- #endif /* PORTMAP */
- #include <rpc/nettype.h>
- //#include <arpa/inet.h>
- +#define RPC_DEBUG 1
- #ifdef RPC_DEBUG
- #include <stdio.h>
- #endif
- @@ -248,12 +249,12 @@ __rpc_broadenable(int af, int s, struct broadif *bip)
- #if 0
- if (af == AF_INET6) {
- fprintf(stderr, "set v6 multicast if to %d\n", bip->index);
- - if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index,
- + if (setsockopt(_get_osfhandle(s), IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index,
- sizeof bip->index) < 0)
- return -1;
- } else
- #endif
- - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o, sizeof o) == SOCKET_ERROR)
- + if (setsockopt(_get_osfhandle(s), SOL_SOCKET, SO_BROADCAST, &o, sizeof o) == SOCKET_ERROR)
- return -1;
- return 0;
- @@ -292,7 +293,8 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- int pmap_reply_flag; /* reply recvd from PORTMAP */
- /* An array of all the suitable broadcast transports */
- struct {
- - int fd; /* File descriptor */
- + SOCK fd_sock; /* File descriptor */
- + int fd;
- int af;
- int proto;
- struct netconfig *nconf; /* Netconfig structure */
- @@ -352,19 +354,20 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- &fdlist[fdlistno].nal) == 0)
- continue;
- - fd = socket(si.si_af, si.si_socktype, si.si_proto);
- + fd = wintirpc_socket(si.si_af, si.si_socktype, si.si_proto);
- if (fd == INVALID_SOCKET) {
- stat = RPC_CANTSEND;
- continue;
- }
- fdlist[fdlistno].af = si.si_af;
- fdlist[fdlistno].proto = si.si_proto;
- + fdlist[fdlistno].fd_sock = _get_osfhandle(fd);
- fdlist[fdlistno].fd = fd;
- fdlist[fdlistno].nconf = nconf;
- fdlist[fdlistno].asize = __rpc_get_a_size(si.si_af);
- pfd[fdlistno].events = POLLIN | POLLPRI |
- POLLRDNORM | POLLRDBAND;
- - pfd[fdlistno].fd = fdlist[fdlistno].fd = fd;
- + pfd[fdlistno].fd = fdlist[fdlistno].fd_sock = _get_osfhandle(fd);
- fdlist[fdlistno].dsize = __rpc_get_t_size(si.si_af, si.si_proto,
- 0);
- @@ -375,7 +378,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) {
- udpbufsz = fdlist[fdlistno].dsize;
- if ((outbuf_pmap = malloc(udpbufsz)) == NULL) {
- - closesocket(fd);
- + wintirpc_closesocket(fd);
- stat = RPC_SYSTEMERROR;
- goto done_broad;
- }
- @@ -486,7 +489,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- */
- if (!__rpc_lowvers)
- - if (sendto(fdlist[i].fd, outbuf,
- + if (sendto(fdlist[i].fd_sock, outbuf,
- outlen, 0, (struct sockaddr*)addr,
- (size_t)fdlist[i].asize) !=
- outlen) {
- @@ -511,7 +514,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- */
- if (pmap_flag &&
- fdlist[i].proto == IPPROTO_UDP) {
- - if (sendto(fdlist[i].fd, outbuf_pmap,
- + if (sendto(fdlist[i].fd_sock, outbuf_pmap,
- outlen_pmap, 0, addr,
- (size_t)fdlist[i].asize) !=
- outlen_pmap) {
- @@ -573,7 +576,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- fdlist[i].nconf->nc_netid);
- #endif
- try_again:
- - inlen = recvfrom(fdlist[i].fd, inbuf, fdlist[i].dsize,
- + inlen = recvfrom(fdlist[i].fd_sock, inbuf, fdlist[i].dsize,
- 0, (struct sockaddr *)(void *)&fdlist[i].raddr,
- &fdlist[i].asize);
- if (inlen < 0) {
- @@ -673,7 +676,7 @@ done_broad:
- (void) free(outbuf_pmap);
- #endif /* PORTMAP */
- for (i = 0; i < fdlistno; i++) {
- - (void)closesocket(fdlist[i].fd);
- + (void)wintirpc_closesocket(fdlist[i].fd);
- __rpc_freebroadifs(&fdlist[i].nal);
- }
- AUTH_DESTROY(sys_auth);
- diff --git a/libtirpc/src/clnt_dg.c b/libtirpc/src/clnt_dg.c
- index 1ece8ad..0c2434f 100644
- --- a/libtirpc/src/clnt_dg.c
- +++ b/libtirpc/src/clnt_dg.c
- @@ -122,7 +122,7 @@ static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory";
- * Private data kept per client handle
- */
- struct cu_data {
- - SOCKET cu_fd; /* connections fd */
- + int cu_fd; /* connections fd */
- bool_t cu_closeit; /* opened by library */
- struct sockaddr_storage cu_raddr; /* remote address */
- int cu_rlen;
- @@ -156,7 +156,7 @@ struct cu_data {
- */
- CLIENT *
- clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
- - SOCKET fd; /* open file descriptor */
- + int fd; /* open file descriptor */
- const struct netbuf *svcaddr; /* servers address */
- rpcprog_t program; /* program number */
- rpcvers_t version; /* version number */
- @@ -281,10 +281,10 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
- #ifdef IP_RECVERR
- {
- int on = 1;
- - setsockopt(fd, SOL_IP, IP_RECVERR, &on, sizeof(on));
- + setsockopt(_get_osfhandle(fd), SOL_IP, IP_RECVERR, &on, sizeof(on));
- }
- #endif
- - ioctlsocket(fd, FIONBIO, &one);
- + ioctlsocket(_get_osfhandle(fd), FIONBIO, &one);
- /*
- * By default, closeit is always FALSE. It is users responsibility
- * to do a close on it, else the user may use clnt_control
- @@ -420,7 +420,7 @@ send_again:
- goto out;
- }
- nextsend_time = cu->cu_wait.tv_sec * 1000 + cu->cu_wait.tv_usec / 1000;
- - if (sendto(cu->cu_fd, cu->cu_outbuf, (int)outlen, 0, sa, salen) != outlen) {
- + if (sendto(_get_osfhandle(cu->cu_fd), cu->cu_outbuf, (int)outlen, 0, sa, salen) != outlen) {
- cu->cu_error.re_errno = errno;
- cu->cu_error.re_status = RPC_CANTSEND;
- goto out;
- @@ -437,7 +437,7 @@ get_reply:
- reply_msg.acpted_rply.ar_results.where = resultsp;
- reply_msg.acpted_rply.ar_results.proc = xresults;
- - fd.fd = cu->cu_fd;
- + fd.fd = _get_osfhandle(cu->cu_fd);
- fd.events = POLLIN;
- fd.revents = 0;
- while (total_time > 0) {
- @@ -477,7 +477,7 @@ get_reply:
- msg.msg_flags = 0;
- msg.msg_control = cbuf;
- msg.msg_controllen = 256;
- - ret = recvmsg (cu->cu_fd, &msg, MSG_ERRQUEUE);
- + ret = recvmsg (_get_osfhandle(cu->cu_fd), &msg, MSG_ERRQUEUE);
- if (ret >= 0
- && memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0
- && (msg.msg_flags & MSG_ERRQUEUE)
- @@ -502,7 +502,7 @@ get_reply:
- /* We have some data now */
- do {
- - recvlen = recvfrom(cu->cu_fd, cu->cu_inbuf,
- + recvlen = recvfrom(_get_osfhandle(cu->cu_fd), cu->cu_inbuf,
- cu->cu_recvsz, 0, NULL, NULL);
- errno = WSAGetLastError();
- } while (recvlen == SOCKET_ERROR && errno == WSAEINTR);
- @@ -693,7 +693,7 @@ clnt_dg_control(cl, request, info)
- *(struct timeval *)info = cu->cu_wait;
- break;
- case CLGET_FD:
- - *(SOCKET *)info = cu->cu_fd;
- + *(int *)info = cu->cu_fd;
- break;
- case CLGET_SVC_ADDR:
- addr = (struct netbuf *)info;
- @@ -779,7 +779,7 @@ clnt_dg_destroy(cl)
- CLIENT *cl;
- {
- struct cu_data *cu = (struct cu_data *)cl->cl_private;
- - SOCKET cu_fd = cu->cu_fd;
- + int cu_fd = cu->cu_fd;
- #ifndef _WIN32
- sigset_t mask;
- sigset_t newmask;
- @@ -793,7 +793,7 @@ clnt_dg_destroy(cl)
- while (dg_fd_locks[WINSOCK_HANDLE_HASH(cu_fd)])
- cond_wait(&dg_cv[WINSOCK_HANDLE_HASH(cu_fd)], &clnt_fd_lock);
- if (cu->cu_closeit)
- - (void)closesocket(cu_fd);
- + (void)wintirpc_closesocket(cu_fd);
- XDR_DESTROY(&(cu->cu_outxdrs));
- mem_free(cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
- if (cl->cl_netid && cl->cl_netid[0])
- diff --git a/libtirpc/src/clnt_generic.c b/libtirpc/src/clnt_generic.c
- index 58a6cc1..f90c4b8 100644
- --- a/libtirpc/src/clnt_generic.c
- +++ b/libtirpc/src/clnt_generic.c
- @@ -344,7 +344,7 @@ clnt_tp_create_timed(const char *hostname, const rpcprog_t prog, const rpcvers_t
- * If sizes are 0; appropriate defaults will be chosen.
- */
- CLIENT *
- -clnt_tli_create(const SOCKET fd_in, const struct netconfig *nconf,
- +clnt_tli_create(const int fd_in, const struct netconfig *nconf,
- struct netbuf *svcaddr, const rpcprog_t prog, const rpcvers_t vers,
- const uint sendsz, const uint recvsz,
- int (*callback_xdr)(void *, void *),
- @@ -357,7 +357,7 @@ clnt_tli_create(const SOCKET fd_in, const struct netconfig *nconf,
- BOOL one = TRUE;
- struct __rpc_sockinfo si;
- extern int __rpc_minfd;
- - SOCKET fd = fd_in;
- + int fd = fd_in;
- if (fd == RPC_ANYFD) {
- if (nconf == NULL) {
- @@ -402,7 +402,7 @@ clnt_tli_create(const SOCKET fd_in, const struct netconfig *nconf,
- if (nconf &&
- ((strcmp(nconf->nc_protofmly, "inet") == 0) ||
- (strcmp(nconf->nc_protofmly, "inet6") == 0))) {
- - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const char *)&one,
- + setsockopt(_get_osfhandle(fd), IPPROTO_TCP, TCP_NODELAY, (const char *)&one,
- sizeof (one));
- }
- cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz,
- @@ -435,7 +435,7 @@ err:
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = errno;
- err1: if (madefd)
- - (void)closesocket(fd);
- + (void)wintirpc_closesocket(fd);
- return (NULL);
- }
- @@ -460,11 +460,11 @@ __rpc_raise_fd(int fd)
- return (fd);
- if (fsync(nfd) == -1) {
- - closesocket(nfd);
- + wintirpc_closesocket(nfd);
- return (fd);
- }
- - if (closesocket(fd) == -1) {
- + if (wintirpc_closesocket(fd) == -1) {
- /* this is okay, we will syslog an error, then use the new fd */
- (void) syslog(LOG_ERR,
- "could not close() fd %d; mem & fd leak", fd);
- diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
- index ff67d5c..fa3e29f 100644
- --- a/libtirpc/src/clnt_vc.c
- +++ b/libtirpc/src/clnt_vc.c
- @@ -402,7 +402,7 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
- * XXX - fvdl connecting while holding a mutex?
- */
- slen = sizeof ss;
- - if (getpeername(fd, (struct sockaddr *)&ss, &slen) == SOCKET_ERROR) {
- + if (getpeername(_get_osfhandle(fd), (struct sockaddr *)&ss, &slen) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- if (errno != WSAENOTCONN) {
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- @@ -411,7 +411,7 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
- // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- goto err;
- }
- - if (connect(fd, (struct sockaddr *)raddr->buf, raddr->len) == SOCKET_ERROR){
- + if (connect(_get_osfhandle(fd), (struct sockaddr *)raddr->buf, raddr->len) == SOCKET_ERROR){
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = WSAGetLastError();
- mutex_unlock(&clnt_fd_lock);
- @@ -457,7 +457,7 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
- XDR_ENCODE);
- if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
- if (ct->ct_closeit) {
- - (void)closesocket(fd);
- + (void)wintirpc_closesocket(fd);
- }
- goto err;
- }
- @@ -934,7 +934,7 @@ clnt_vc_destroy(cl)
- }
- if (ct->ct_closeit && ct->ct_fd != -1) {
- - (void)closesocket(ct->ct_fd);
- + (void)wintirpc_closesocket(ct->ct_fd);
- }
- XDR_DESTROY(&(ct->ct_xdrs));
- if (ct->ct_addr.buf)
- @@ -971,7 +971,7 @@ read_vc(ctp, buf, len)
- if (len == 0)
- return (0);
- - fd.fd = ct->ct_fd;
- + fd.fd = _get_osfhandle(ct->ct_fd);
- fd.events = POLLIN;
- for (;;) {
- switch (poll(&fd, 1, milliseconds)) {
- @@ -990,7 +990,7 @@ read_vc(ctp, buf, len)
- break;
- }
- - len = recv(ct->ct_fd, buf, (size_t)len, 0);
- + len = recv(_get_osfhandle(ct->ct_fd), buf, (size_t)len, 0);
- errno = WSAGetLastError();
- switch (len) {
- @@ -1019,7 +1019,7 @@ write_vc(ctp, buf, len)
- int i = 0, cnt;
- for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- - if ((i = send(ct->ct_fd, buf, (size_t)cnt, 0)) == SOCKET_ERROR) {
- + if ((i = send(_get_osfhandle(ct->ct_fd), buf, (size_t)cnt, 0)) == SOCKET_ERROR) {
- ct->ct_error.re_errno = WSAGetLastError();
- ct->ct_error.re_status = RPC_CANTSEND;
- return (-1);
- diff --git a/libtirpc/src/getpeereid.c b/libtirpc/src/getpeereid.c
- index df8365f..17b1a5c 100644
- --- a/libtirpc/src/getpeereid.c
- +++ b/libtirpc/src/getpeereid.c
- @@ -36,7 +36,7 @@
- #ifdef _WIN32
- int
- -getpeereid(SOCKET s, uid_t *euid, gid_t *egid)
- +getpeereid(int s, uid_t *euid, gid_t *egid)
- {
- // XXX Need to figure out what to do here for Windows!
- return -1;
- @@ -50,7 +50,7 @@ getpeereid(int s, uid_t *euid, gid_t *egid)
- int error;
- uclen = sizeof(uc);
- - error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /* SCM_CREDENTIALS */
- + error = getsockopt(_get_osfhandle(s), SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /* SCM_CREDENTIALS */
- if (error != 0)
- return (error);
- // if (uc.cr_version != XUCRED_VERSION)
- diff --git a/libtirpc/src/pmap_getmaps.c b/libtirpc/src/pmap_getmaps.c
- index c6ad2bb..daf9e74 100644
- --- a/libtirpc/src/pmap_getmaps.c
- +++ b/libtirpc/src/pmap_getmaps.c
- @@ -66,7 +66,7 @@ pmap_getmaps(address)
- struct sockaddr_in *address;
- {
- struct pmaplist *head = NULL;
- - SOCKET sock = INVALID_SOCKET;
- + int sock = INVALID_SOCKET;
- struct timeval minutetimeout;
- CLIENT *client;
- diff --git a/libtirpc/src/rpc_com.h b/libtirpc/src/rpc_com.h
- index a69d7f0..ff9db44 100644
- --- a/libtirpc/src/rpc_com.h
- +++ b/libtirpc/src/rpc_com.h
- @@ -62,7 +62,7 @@
- __BEGIN_DECLS
- extern u_int __rpc_get_a_size(int);
- extern int __rpc_dtbsize(void);
- -extern struct netconfig * __rpcgettp(SOCKET);
- +extern struct netconfig * __rpcgettp(int);
- extern int __rpc_get_default_domain(char **);
- struct netbuf *__rpc_set_netbuf(struct netbuf *, const void *, size_t);
- @@ -73,7 +73,7 @@ int __rpc_sockinfo2netid(struct __rpc_sockinfo *, const char **);
- int __rpc_seman2socktype(int);
- int __rpc_socktype2seman(int);
- void *rpc_nullproc(CLIENT *);
- -int __rpc_sockisbound(SOCKET);
- +int __rpc_sockisbound(int);
- struct netbuf *__rpcb_findaddr(rpcprog_t, rpcvers_t, const struct netconfig *,
- const char *, CLIENT **);
- diff --git a/libtirpc/src/rpc_generic.c b/libtirpc/src/rpc_generic.c
- index 42dca45..442d309 100644
- --- a/libtirpc/src/rpc_generic.c
- +++ b/libtirpc/src/rpc_generic.c
- @@ -110,7 +110,8 @@ int
- __rpc_dtbsize()
- {
- #ifdef _WIN32
- - return (WINSOCK_HANDLE_HASH_SIZE);
- + /* gisburn: fixme: static value |1024| */
- + return (1024);
- #else
- static int tbsize;
- @@ -462,7 +463,7 @@ rpc_nullproc(clnt)
- */
- struct netconfig *
- __rpcgettp(fd)
- - SOCKET fd;
- + int fd;
- {
- const char *netid;
- struct __rpc_sockinfo si;
- @@ -478,7 +479,7 @@ __rpcgettp(fd)
- }
- int
- -__rpc_fd2sockinfo(SOCKET fd, struct __rpc_sockinfo *sip)
- +__rpc_fd2sockinfo(int fd, struct __rpc_sockinfo *sip)
- {
- socklen_t len;
- int type, proto;
- @@ -487,7 +488,7 @@ __rpc_fd2sockinfo(SOCKET fd, struct __rpc_sockinfo *sip)
- #ifdef _WIN32
- WSAPROTOCOL_INFO proto_info;
- int proto_info_size = sizeof(proto_info);
- - if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
- + if (getsockopt(_get_osfhandle(fd), SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
- int err = WSAGetLastError();
- return 0;
- }
- @@ -495,14 +496,14 @@ __rpc_fd2sockinfo(SOCKET fd, struct __rpc_sockinfo *sip)
- ss.ss_family = (ADDRESS_FAMILY)proto_info.iAddressFamily;
- #else
- len = sizeof ss;
- - if (getsockname(fd, (struct sockaddr *)&ss, &len) == SOCKET_ERROR) {
- + if (getsockname(_get_osfhandle(fd), (struct sockaddr *)&ss, &len) == SOCKET_ERROR) {
- return 0;
- }
- #endif
- sip->si_alen = len;
- len = sizeof type;
- - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&type, &len) == SOCKET_ERROR) {
- + if (getsockopt(_get_osfhandle(fd), SOL_SOCKET, SO_TYPE, (char *)&type, &len) == SOCKET_ERROR) {
- int err = WSAGetLastError();
- return 0;
- }
- @@ -554,20 +555,20 @@ __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
- return 0;
- }
- -SOCKET
- +int
- __rpc_nconf2fd(const struct netconfig *nconf)
- {
- struct __rpc_sockinfo si;
- - SOCKET fd;
- + int fd;
- if (!__rpc_nconf2sockinfo(nconf, &si))
- return 0;
- - if ((fd = socket(si.si_af, si.si_socktype, si.si_proto)) != INVALID_SOCKET &&
- + if ((fd = wintirpc_socket(si.si_af, si.si_socktype, si.si_proto)) != -1 &&
- si.si_af == AF_INET6) {
- int val = 1;
- - setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, (const char *)&val, sizeof(val));
- + setsockopt(_get_osfhandle(fd), SOL_IPV6, IPV6_V6ONLY, (const char *)&val, sizeof(val));
- }
- return fd;
- }
- @@ -876,7 +877,7 @@ __rpc_fixup_addr(struct netbuf *new, const struct netbuf *svc)
- }
- int
- -__rpc_sockisbound(SOCKET fd)
- +__rpc_sockisbound(int fd)
- {
- struct sockaddr_storage ss;
- union {
- @@ -889,7 +890,7 @@ __rpc_sockisbound(SOCKET fd)
- socklen_t slen;
- slen = sizeof (struct sockaddr_storage);
- - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR)
- + if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR)
- return 0;
- switch (ss.ss_family) {
- diff --git a/libtirpc/src/rpc_soc.c b/libtirpc/src/rpc_soc.c
- index 4b69810..9d0de3a 100644
- --- a/libtirpc/src/rpc_soc.c
- +++ b/libtirpc/src/rpc_soc.c
- @@ -68,7 +68,7 @@ extern mutex_t rpcsoc_lock;
- static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
- int *, u_int, u_int, char *);
- -static SVCXPRT *svc_com_create(SOCKET, u_int, u_int, char *);
- +static SVCXPRT *svc_com_create(int, u_int, u_int, char *);
- static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *);
- /* XXX */
- @@ -83,14 +83,14 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp)
- struct sockaddr_in *raddr;
- rpcprog_t prog;
- rpcvers_t vers;
- - SOCKET *sockp;
- + int *sockp;
- u_int sendsz;
- u_int recvsz;
- char *tp;
- {
- CLIENT *cl;
- int madefd = FALSE;
- - SOCKET fd = *sockp;
- + int fd = *sockp;
- struct netconfig *nconf;
- struct netbuf bindaddr;
- @@ -148,7 +148,7 @@ syserror:
- rpc_createerr.cf_error.re_errno = errno;
- err: if (madefd == TRUE)
- - (void)closesocket(fd);
- + (void)wintirpc_closesocket(fd);
- (void) freenetconfigent(nconf);
- mutex_unlock(&rpcsoc_lock);
- return (NULL);
- @@ -263,7 +263,7 @@ clntraw_create(prog, vers)
- */
- static SVCXPRT *
- svc_com_create(fd, sendsize, recvsize, netid)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- char *netid;
- @@ -292,12 +292,12 @@ svc_com_create(fd, sendsize, recvsize, netid)
- memset(&sin, 0, sizeof sin);
- sin.sin_family = AF_INET;
- bindresvport(fd, &sin);
- - listen(fd, SOMAXCONN);
- + listen(_get_osfhandle(fd), SOMAXCONN);
- svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
- (void) freenetconfigent(nconf);
- if (svc == NULL) {
- if (madefd)
- - (void)closesocket(fd);
- + (void)wintirpc_closesocket(fd);
- return (NULL);
- }
- port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
- @@ -307,7 +307,7 @@ svc_com_create(fd, sendsize, recvsize, netid)
- SVCXPRT *
- svctcp_create(fd, sendsize, recvsize)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- {
- @@ -319,7 +319,7 @@ svctcp_create(fd, sendsize, recvsize)
- SVCXPRT *
- svcudp_bufcreate(fd, sendsz, recvsz)
- - SOCKET fd;
- + int fd;
- u_int sendsz, recvsz;
- {
- @@ -330,7 +330,7 @@ svcudp_bufcreate(fd, sendsz, recvsz)
- SVCXPRT *
- svcfd_create(fd, sendsize, recvsize)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- {
- @@ -341,7 +341,7 @@ svcfd_create(fd, sendsize, recvsize)
- SVCXPRT *
- svcudp_create(fd)
- - SOCKET fd;
- + int fd;
- {
- return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp");
- @@ -522,7 +522,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
- struct sockaddr_un *raddr;
- u_long prog;
- u_long vers;
- - SOCKET *sockp;
- + int *sockp;
- u_int sendsz;
- u_int recvsz;
- {
- @@ -543,14 +543,14 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
- return(cl);
- }
- if (*sockp == SOCKET_ERROR) {
- - *sockp = socket(AF_UNIX, SOCK_STREAM, 0);
- + *sockp = wintirpc_socket(AF_UNIX, SOCK_STREAM, 0);
- len = SUN_LEN(raddr);
- - if ((*sockp == INVALID_SOCKET) || (connect(*sockp,
- + if ((*sockp == -1) || (connect(_get_osfhandle(*sockp),
- (struct sockaddr *)raddr, len) == SOCKET_ERROR)) {
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = errno;
- - if (*sockp != INVALID_SOCKET)
- - (void)closesocket(*sockp);
- + if (*sockp != -1)
- + (void)wintirpc_closesocket(*sockp);
- goto done;
- }
- }
- @@ -571,7 +571,7 @@ done:
- */
- SVCXPRT *
- svcunix_create(sock, sendsize, recvsize, path)
- - SOCKET sock;
- + int sock;
- u_int sendsize;
- u_int recvsize;
- char *path;
- @@ -603,7 +603,7 @@ svcunix_create(sock, sendsize, recvsize, path)
- addrlen = sizeof(struct sockaddr_un);
- sa = (struct sockaddr *)&sun;
- - if (bind(sock, sa, addrlen) == SOCKET_ERROR)
- + if (bind(_get_osfhandle(sock), sa, addrlen) == SOCKET_ERROR)
- goto done;
- taddr.addr.len = taddr.addr.maxlen = addrlen;
- @@ -613,7 +613,7 @@ svcunix_create(sock, sendsize, recvsize, path)
- memcpy(taddr.addr.buf, sa, addrlen);
- if (nconf->nc_semantics != NC_TPI_CLTS) {
- - if (listen(sock, SOMAXCONN) == SOCKET_ERROR) {
- + if (listen(_get_osfhandle(sock), SOMAXCONN) == SOCKET_ERROR) {
- free(taddr.addr.buf);
- goto done;
- }
- @@ -632,7 +632,7 @@ done:
- */
- SVCXPRT *
- svcunixfd_create(fd, sendsize, recvsize)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- {
- diff --git a/libtirpc/src/rpcb_clnt.c b/libtirpc/src/rpcb_clnt.c
- index b8c30c1..aafab64 100644
- --- a/libtirpc/src/rpcb_clnt.c
- +++ b/libtirpc/src/rpcb_clnt.c
- @@ -423,7 +423,7 @@ local_rpcb()
- static struct netconfig *loopnconf;
- static char *hostname;
- extern mutex_t loopnconf_lock;
- - SOCKET sock;
- + int sock;
- size_t tsize;
- struct netbuf nbuf;
- struct sockaddr_un sun;
- @@ -434,9 +434,10 @@ local_rpcb()
- * the netconfig file.
- */
- memset(&sun, 0, sizeof sun);
- - sock = socket(AF_UNIX, SOCK_STREAM, 0);
- - if (sock == INVALID_SOCKET)
- + sock = wintirpc_socket(AF_UNIX, SOCK_STREAM, 0);
- + if (sock == -1)
- goto try_nconf;
- +
- sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
- nbuf.len = SUN_LEN(&sun);
- @@ -455,7 +456,7 @@ local_rpcb()
- }
- /* Nobody needs this socket anymore; free the descriptor. */
- - closesocket(sock);
- + wintirpc_closesocket(sock);
- try_nconf:
- @@ -464,7 +465,7 @@ try_nconf:
- if (loopnconf == NULL) {
- struct netconfig *nconf, *tmpnconf = NULL;
- void *nc_handle;
- - SOCKET fd;
- + int fd;
- nc_handle = setnetconfig();
- if (nc_handle == NULL) {
- @@ -490,7 +491,7 @@ try_nconf:
- */
- if (fd == SOCKET_ERROR)
- continue;
- - closesocket(fd);
- + wintirpc_closesocket(fd);
- tmpnconf = nconf;
- if (!strcmp(nconf->nc_protofmly, NC_INET))
- hostname = IN4_LOCALHOST_STRING;
- @@ -657,7 +658,7 @@ __rpcbind_is_up()
- struct netconfig *nconf;
- struct sockaddr_un sun;
- void *localhandle;
- - SOCKET sock;
- + int sock;
- nconf = NULL;
- localhandle = setnetconfig();
- @@ -672,18 +673,19 @@ __rpcbind_is_up()
- endnetconfig(localhandle);
- memset(&sun, 0, sizeof sun);
- - sock = socket(AF_UNIX, SOCK_STREAM, 0);
- - if (sock == INVALID_SOCKET)
- + sock = wintirpc_socket(AF_UNIX, SOCK_STREAM, 0);
- + if (sock == -1)
- return (FALSE);
- +
- sun.sun_family = AF_UNIX;
- strncpy(sun.sun_path, _PATH_RPCBINDSOCK, sizeof(sun.sun_path));
- - if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) == SOCKET_ERROR) {
- - closesocket(sock);
- + if (connect(_get_osfhandle(sock), (struct sockaddr *)&sun, sizeof(sun)) == SOCKET_ERROR) {
- + wintirpc_closesocket(sock);
- return (FALSE);
- }
- - closesocket(sock);
- + wintirpc_closesocket(sock);
- return (TRUE);
- }
- diff --git a/libtirpc/src/rtime.c b/libtirpc/src/rtime.c
- index f933ff6..51a6c06 100644
- --- a/libtirpc/src/rtime.c
- +++ b/libtirpc/src/rtime.c
- @@ -59,7 +59,7 @@ extern int _rpc_dtablesize( void );
- #define NYEARS (unsigned long)(1970 - 1900)
- #define TOFFSET (unsigned long)(60*60*24*(365*NYEARS + (NYEARS/4)))
- -static void do_close( SOCKET );
- +static void do_close( int );
- int
- rtime(addrp, timep, timeout)
- @@ -67,7 +67,7 @@ rtime(addrp, timep, timeout)
- struct timeval *timep;
- struct timeval *timeout;
- {
- - SOCKET s;
- + int s;
- fd_set readfds;
- int res;
- unsigned long thetime;
- @@ -81,10 +81,11 @@ rtime(addrp, timep, timeout)
- } else {
- type = SOCK_DGRAM;
- }
- - s = socket(AF_INET, type, 0);
- - if (s == INVALID_SOCKET) {
- + s = wintirpc_socket(AF_INET, type, 0);
- + if (s == -1) {
- return(-1);
- }
- +
- addrp->sin_family = AF_INET;
- /* TCP and UDP port are the same in this case */
- @@ -95,7 +96,7 @@ rtime(addrp, timep, timeout)
- addrp->sin_port = serv->s_port;
- if (type == SOCK_DGRAM) {
- - res = sendto(s, (char *)&thetime, sizeof(thetime), 0,
- + res = sendto(_get_osfhandle(s), (char *)&thetime, sizeof(thetime), 0,
- (struct sockaddr *)addrp, sizeof(*addrp));
- if (res == SOCKET_ERROR) {
- do_close(s);
- @@ -103,7 +104,7 @@ rtime(addrp, timep, timeout)
- }
- do {
- FD_ZERO(&readfds);
- - FD_SET(s, &readfds);
- + FD_SET(_get_osfhandle(s), &readfds);
- res = select(_rpc_dtablesize(), &readfds,
- (fd_set *)NULL, (fd_set *)NULL, timeout);
- } while (res == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
- @@ -115,18 +116,18 @@ rtime(addrp, timep, timeout)
- return(-1);
- }
- fromlen = sizeof(from);
- - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0,
- + res = recvfrom(_get_osfhandle(s), (char *)&thetime, sizeof(thetime), 0,
- (struct sockaddr *)&from, &fromlen);
- do_close(s);
- if (res == SOCKET_ERROR) {
- return(-1);
- }
- } else {
- - if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) == SOCKET_ERROR) {
- + if (connect(_get_osfhandle(s), (struct sockaddr *)addrp, sizeof(*addrp)) == SOCKET_ERROR) {
- do_close(s);
- return(-1);
- }
- - res = recv(s, (char *)&thetime, sizeof(thetime), 0);
- + res = recv(_get_osfhandle(s), (char *)&thetime, sizeof(thetime), 0);
- do_close(s);
- if (res == SOCKET_ERROR) {
- return(-1);
- @@ -149,6 +150,6 @@ do_close(s)
- int save;
- save = errno;
- - (void)closesocket(s);
- + (void)wintirpc_closesocket(s);
- errno = save;
- }
- diff --git a/libtirpc/src/svc.c b/libtirpc/src/svc.c
- index 1666364..5b5d3de 100644
- --- a/libtirpc/src/svc.c
- +++ b/libtirpc/src/svc.c
- @@ -97,7 +97,7 @@ void
- xprt_register (xprt)
- SVCXPRT *xprt;
- {
- - SOCKET sock;
- + int sock;
- assert (xprt != NULL);
- @@ -115,7 +115,7 @@ xprt_register (xprt)
- #ifndef _WIN32
- if (sock < FD_SETSIZE) {
- __svc_xports[sock] = xprt;
- - FD_SET (sock, &svc_fdset);
- + FD_SET(_get_osfhandle(sock), &svc_fdset);
- svc_maxfd = max (svc_maxfd, sock);
- }
- #else
- @@ -144,7 +144,7 @@ __xprt_do_unregister (xprt, dolock)
- SVCXPRT *xprt;
- bool_t dolock;
- {
- - SOCKET sock;
- + int sock;
- assert (xprt != NULL);
- @@ -155,7 +155,7 @@ bool_t dolock;
- rwlock_wrlock (&svc_fd_lock);
- if ((sock < FD_SETSIZE) && (__svc_xports[sock] == xprt)) {
- __svc_xports[sock] = NULL;
- - FD_CLR (sock, &svc_fdset);
- + FD_CLR (_get_osfhandle(sock), &svc_fdset);
- if (sock >= svc_maxfd) {
- for (svc_maxfd--; svc_maxfd >= 0; svc_maxfd--)
- if (__svc_xports[svc_maxfd])
- @@ -638,7 +638,7 @@ svc_getreqset (readfds)
- }
- void
- -svc_getreq_common (SOCKET fd)
- +svc_getreq_common (int fd)
- {
- SVCXPRT *xprt;
- struct svc_req r;
- @@ -771,11 +771,11 @@ svc_getreq_poll (pfdp, pollretval)
- if (p->revents & POLLNVAL)
- {
- rwlock_wrlock (&svc_fd_lock);
- - FD_CLR (p->fd, &svc_fdset);
- + FD_CLR (_get_osfhandle(p->fd), &svc_fdset);
- rwlock_unlock (&svc_fd_lock);
- }
- else
- - svc_getreq_common (p->fd);
- + svc_getreq_common (wintirpc_osfhandle2fd(p->fd));
- }
- }
- }
- diff --git a/libtirpc/src/svc_dg.c b/libtirpc/src/svc_dg.c
- index d8dcada..ca21443 100644
- --- a/libtirpc/src/svc_dg.c
- +++ b/libtirpc/src/svc_dg.c
- @@ -138,7 +138,7 @@ svc_dg_create(fd, sendsize, recvsize)
- xprt->xp_rtaddr.maxlen = sizeof (struct sockaddr_storage);
- slen = sizeof ss;
- - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR)
- + if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR)
- goto freedata;
- __rpc_set_netbuf(&xprt->xp_ltaddr, &ss, slen);
- @@ -177,7 +177,7 @@ svc_dg_recv(xprt, msg)
- again:
- alen = sizeof (struct sockaddr_storage);
- - rlen = recvfrom(xprt->xp_fd, rpc_buffer(xprt), su->su_iosz, 0,
- + rlen = recvfrom(_get_osfhandle(xprt->xp_fd), rpc_buffer(xprt), su->su_iosz, 0,
- (struct sockaddr *)(void *)&ss, &alen);
- if (rlen == -1 && errno == EINTR)
- goto again;
- @@ -194,7 +194,7 @@ again:
- su->su_xid = msg->rm_xid;
- if (su->su_cache != NULL) {
- if (cache_get(xprt, msg, &reply, &replylen)) {
- - (void)sendto(xprt->xp_fd, reply, replylen, 0,
- + (void)sendto(_get_osfhandle(xprt->xp_fd), reply, replylen, 0,
- (struct sockaddr *)(void *)&ss, alen);
- return (FALSE);
- }
- @@ -217,7 +217,7 @@ svc_dg_reply(xprt, msg)
- msg->rm_xid = su->su_xid;
- if (xdr_replymsg(xdrs, msg)) {
- slen = XDR_GETPOS(xdrs);
- - if (sendto(xprt->xp_fd, rpc_buffer(xprt), slen, 0,
- + if (sendto(_get_osfhandle(xprt->xp_fd), rpc_buffer(xprt), slen, 0,
- (struct sockaddr *)xprt->xp_rtaddr.buf,
- (socklen_t)xprt->xp_rtaddr.len) == (ssize_t) slen) {
- stat = TRUE;
- @@ -257,7 +257,7 @@ svc_dg_destroy(xprt)
- xprt_unregister(xprt);
- if (xprt->xp_fd != -1)
- - (void)closesocket(xprt->xp_fd);
- + (void)wintirpc_closesocket(xprt->xp_fd);
- XDR_DESTROY(&(su->su_xdrs));
- (void) mem_free(rpc_buffer(xprt), su->su_iosz);
- (void) mem_free(su, sizeof (*su));
- diff --git a/libtirpc/src/svc_generic.c b/libtirpc/src/svc_generic.c
- index d84f237..168d516 100644
- --- a/libtirpc/src/svc_generic.c
- +++ b/libtirpc/src/svc_generic.c
- @@ -180,7 +180,7 @@ svc_tp_create(dispatch, prognum, versnum, nconf)
- */
- SVCXPRT *
- svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
- - SOCKET fd; /* Connection end point */
- + int fd; /* Connection end point */
- const struct netconfig *nconf; /* Netconfig struct for nettoken */
- const struct t_bind *bindaddr; /* Local bind address */
- u_int sendsz; /* Max sendsize */
- @@ -225,23 +225,23 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
- if (bindresvport(fd, NULL) < 0) {
- memset(&ss, 0, sizeof ss);
- ss.ss_family = si.si_af;
- - if (bind(fd, (struct sockaddr *)(void *)&ss,
- + if (bind(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss,
- (socklen_t)si.si_alen) == SOCKET_ERROR) {
- // XXX warnx(
- // "svc_tli_create: could not bind to anonymous port");
- goto freedata;
- }
- }
- - listen(fd, SOMAXCONN);
- + listen(_get_osfhandle(fd), SOMAXCONN);
- } else {
- - if (bind(fd,
- + if (bind(_get_osfhandle(fd),
- (struct sockaddr *)bindaddr->addr.buf,
- (socklen_t)si.si_alen) == SOCKET_ERROR) {
- // XXX warnx(
- // "svc_tli_create: could not bind to requested address");
- goto freedata;
- }
- - listen(fd, (int)bindaddr->qlen);
- + listen(_get_osfhandle(fd), (int)bindaddr->qlen);
- }
- }
- @@ -292,7 +292,7 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
- freedata:
- if (madefd)
- - (void)closesocket(fd);
- + (void)wintirpc_closesocket(fd);
- if (xprt) {
- if (!madefd) /* so that svc_destroy doesnt close fd */
- xprt->xp_fd = RPC_ANYFD;
- diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
- index 53f0df3..de90781 100644
- --- a/libtirpc/src/svc_vc.c
- +++ b/libtirpc/src/svc_vc.c
- @@ -67,7 +67,7 @@
- extern rwlock_t svc_fd_lock;
- -static SVCXPRT *makefd_xprt(SOCKET, u_int, u_int);
- +static SVCXPRT *makefd_xprt(int, u_int, u_int);
- static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *);
- static enum xprt_stat rendezvous_stat(SVCXPRT *);
- static void svc_vc_destroy(SVCXPRT *);
- @@ -179,7 +179,7 @@ svc_vc_create(fd, sendsize, recvsize)
- xprt->xp_fd = fd;
- slen = sizeof (struct sockaddr_storage);
- - if (getsockname(fd, (struct sockaddr *)(void *)&sslocal, &slen) == SOCKET_ERROR) {
- + if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&sslocal, &slen) == SOCKET_ERROR) {
- // XXX warnx("svc_vc_create: could not retrieve local addr");
- goto cleanup_svc_vc_create;
- }
- @@ -202,7 +202,7 @@ cleanup_svc_vc_create:
- */
- SVCXPRT *
- svc_fd_create(fd, sendsize, recvsize)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- {
- @@ -217,7 +217,7 @@ svc_fd_create(fd, sendsize, recvsize)
- return NULL;
- slen = sizeof (struct sockaddr_storage);
- - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
- + if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
- // XXX warnx("svc_fd_create: could not retrieve local addr");
- goto freedata;
- }
- @@ -250,7 +250,7 @@ freedata:
- static SVCXPRT *
- makefd_xprt(fd, sendsize, recvsize)
- - SOCKET fd;
- + int fd;
- u_int sendsize;
- u_int recvsize;
- {
- @@ -302,7 +302,7 @@ rendezvous_request(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
- {
- - SOCKET sock;
- + int sock;
- #ifndef _WIN32
- int flags;
- #endif
- @@ -320,7 +320,7 @@ rendezvous_request(xprt, msg)
- r = (struct cf_rendezvous *)xprt->xp_p1;
- again:
- len = sizeof addr;
- - if ((sock = accept(xprt->xp_fd, (struct sockaddr *)(void *)&addr,
- + if ((sock = wintirpc_accept(xprt->xp_fd, (struct sockaddr *)(void *)&addr,
- &len)) == SOCKET_ERROR) {
- if (errno == EINTR)
- goto again;
- @@ -355,7 +355,7 @@ again:
- if (__rpc_fd2sockinfo(sock, &si) && si.si_proto == IPPROTO_TCP) {
- len = 1;
- /* XXX fvdl - is this useful? */
- - setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&len, sizeof (len));
- + setsockopt(_get_osfhandle(sock), IPPROTO_TCP, TCP_NODELAY, (const char *)&len, sizeof (len));
- }
- cd = (struct cf_conn *)newxprt->xp_p1;
- @@ -413,7 +413,7 @@ __svc_vc_dodestroy(xprt)
- cd = (struct cf_conn *)xprt->xp_p1;
- if (xprt->xp_fd != RPC_ANYFD)
- - (void)closesocket(xprt->xp_fd);
- + (void)wintirpc_closesocket(xprt->xp_fd);
- if (xprt->xp_port != 0) {
- /* a rendezvouser socket */
- r = (struct cf_rendezvous *)xprt->xp_p1;
- @@ -483,7 +483,7 @@ read_vc(xprtp, buf, len)
- int len;
- {
- SVCXPRT *xprt;
- - SOCKET sock;
- + int sock;
- int milliseconds = 35 * 1000;
- struct pollfd pollfd;
- struct cf_conn *cfp;
- @@ -497,7 +497,7 @@ read_vc(xprtp, buf, len)
- if (cfp->nonblock) {
- #ifdef _WIN32
- - len = recv(sock, buf, (size_t)len, 0);
- + len = recv(_get_osfhandle(sock), buf, (size_t)len, 0);
- #else
- len = read(sock, buf, (size_t)len);
- #endif
- @@ -513,7 +513,7 @@ read_vc(xprtp, buf, len)
- }
- do {
- - pollfd.fd = sock;
- + pollfd.fd = _get_osfhandle(sock);
- pollfd.events = POLLIN;
- pollfd.revents = 0;
- switch (poll(&pollfd, 1, milliseconds)) {
- @@ -530,7 +530,7 @@ read_vc(xprtp, buf, len)
- } while ((pollfd.revents & POLLIN) == 0);
- #ifdef _WIN32
- - if ((len = recv(sock, buf, (size_t)len, 0)) > 0) {
- + if ((len = recv(_get_osfhandle(sock), buf, (size_t)len, 0)) > 0) {
- #else
- if ((len = read(sock, buf, (size_t)len)) > 0) {
- #endif
- @@ -568,7 +568,7 @@ write_vc(xprtp, buf, len)
- for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- #ifdef _WIN32
- - i = send(xprt->xp_fd, buf, (size_t)cnt, 0);
- + i = send(_get_osfhandle(xprt->xp_fd), buf, (size_t)cnt, 0);
- #else
- i = write(xprt->xp_fd, buf, (size_t)cnt);
- #endif
- @@ -752,7 +752,7 @@ svc_vc_rendezvous_ops(xprt)
- */
- int
- __rpc_get_local_uid(SVCXPRT *transp, uid_t *uid) {
- - SOCKET sock;
- + int sock;
- int ret;
- gid_t egid;
- uid_t euid;
- diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
- index eb98489..14fab0c 100644
- --- a/libtirpc/src/wintirpc.c
- +++ b/libtirpc/src/wintirpc.c
- @@ -23,6 +23,7 @@
- #include <rpc/rpc.h>
- #include <stdio.h>
- #include <winsock.h>
- +#include <assert.h>
- WSADATA WSAData;
- @@ -159,6 +160,126 @@ BOOL WINAPI DllMain/*tirpc_main*/(HINSTANCE hinstDLL, // DLL module handle
- return TRUE;
- }
- +struct map_osfhandle_fd
- +{
- + SOCKET m_s;
- + int m_fd;
- +};
- +
- +#define MAP_OSFHANDLE_SIZE (1024)
- +
- +static
- +struct map_osfhandle_fd handle_fd_map[MAP_OSFHANDLE_SIZE];
- +
- +void wintirpc_register_osfhandle_fd(SOCKET handle, int fd)
- +{
- + assert(handle != 0);
- + assert(handle != SOCKET_ERROR);
- + assert(fd < MAP_OSFHANDLE_SIZE);
- +
- + handle_fd_map[fd].m_fd = fd;
- + handle_fd_map[fd].m_s = handle;
- +}
- +
- +void wintirpc_unregister_osfhandle(SOCKET handle)
- +{
- + int i;
- +
- + assert(handle != 0);
- + assert(handle != SOCKET_ERROR);
- +
- + for (i=0 ; i < MAP_OSFHANDLE_SIZE ; i++) {
- + if (handle_fd_map[i].m_s == handle) {
- + handle_fd_map[i].m_s = SOCKET_ERROR;
- + handle_fd_map[i].m_fd = -1;
- + return;
- + }
- + }
- + (void)fprintf(stderr, "wintirpc_unregister_osfhandle: failed\n");
- +}
- +
- +int wintirpc_osfhandle2fd(SOCKET handle)
- +{
- + int i;
- +
- + assert(handle != 0);
- + assert(handle != SOCKET_ERROR);
- +
- + for (i=0 ; i < MAP_OSFHANDLE_SIZE ; i++) {
- + if ((handle_fd_map[i].m_s == handle) &&
- + (handle_fd_map[i].m_fd != -1)) {
- + return handle_fd_map[i].m_fd;
- + }
- + }
- + (void)fprintf(stderr, "wintirpc_osfhandle2fd: failed\n");
- + return -1;
- +}
- +
- +int wintirpc_socket(int af, int type, int protocol)
- +{
- + SOCKET s;
- +
- + s = socket(af, type, protocol);
- + if (s == INVALID_SOCKET) {
- + (void)fprintf(stderr, "wintirpc_socket: INVALID_SOCKET\n");
- + return -1;
- + }
- +
- + int fd = _open_osfhandle(s, _O_BINARY);
- + if (fd < 0) {
- + (void)closesocket(s);
- + /*
- + * |_open_osfhandle()| may not set |errno|, and
- + * |closesocket()| may override it
- + */
- + (void)fprintf(stderr, "wintirpc_socket: failed\n");
- + errno = ENOMEM;
- + return -1;
- + }
- +
- + wintirpc_register_osfhandle_fd(s, fd);
- +
- + (void)fprintf(stderr, "wintirpc_socket: %s/%d: sock fd=%d\n", __FILE__, (int)__LINE__, fd);
- +
- + return fd;
- +}
- +
- +int wintirpc_closesocket(int in_fd)
- +{
- + SOCKET s = _get_osfhandle(in_fd);
- +
- + wintirpc_unregister_osfhandle(s);
- +
- + return closesocket(s);
- +}
- +
- +int wintirpc_accept(int in_s_fd, struct sockaddr *addr, int *addrlen)
- +{
- + SOCKET in_s;
- + SOCKET out_s;
- + int out_s_fd;
- +
- + in_s = _get_osfhandle(in_s_fd);
- +
- + out_s = accept(in_s, addr, addrlen);
- +
- + out_s_fd = _open_osfhandle(out_s, _O_BINARY);
- + if (out_s_fd < 0) {
- + (void)closesocket(out_s);
- + /*
- + * |_open_osfhandle()| may not set |errno|, and
- + * |closesocket()| may override it
- + */
- + (void)fprintf(stderr, "wintirpc_accept: failed\n");
- + errno = ENOMEM;
- + return -1;
- + }
- +
- + wintirpc_register_osfhandle_fd(out_s, out_s_fd);
- +
- + return out_s_fd;
- +}
- +
- int tirpc_exit(void)
- {
- if (init == 0 || --init > 0)
- @@ -167,6 +288,14 @@ int tirpc_exit(void)
- return WSACleanup();
- }
- +void warnx(LPCSTR format, ...)
- +{
- + va_list args;
- + va_start(args, format);
- + fprintf(stderr, "tirpc: %04x: ", GetCurrentThreadId());
- + vfprintf(stderr, format, args);
- + va_end(args);
- +}
- void wintirpc_debug(char *fmt, ...)
- {
- diff --git a/libtirpc/tirpc/getpeereid.h b/libtirpc/tirpc/getpeereid.h
- index cdecd0e..025143f 100644
- --- a/libtirpc/tirpc/getpeereid.h
- +++ b/libtirpc/tirpc/getpeereid.h
- @@ -1,2 +1,2 @@
- -int getpeereid(SOCKET s, uid_t *euid, gid_t *egid);
- +int getpeereid(int s, uid_t *euid, gid_t *egid);
- diff --git a/libtirpc/tirpc/rpc/clnt.h b/libtirpc/tirpc/rpc/clnt.h
- index 0ee9724..3639f82 100644
- --- a/libtirpc/tirpc/rpc/clnt.h
- +++ b/libtirpc/tirpc/rpc/clnt.h
- @@ -393,7 +393,7 @@ extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t,
- * Generic TLI create routine. Only provided for compatibility.
- */
- -extern CLIENT *clnt_tli_create(const SOCKET, const struct netconfig *,
- +extern CLIENT *clnt_tli_create(const int, const struct netconfig *,
- struct netbuf *, const rpcprog_t,
- const rpcvers_t, const u_int, const u_int,
- int (*cb_xdr)(void *, void *),
- @@ -411,7 +411,7 @@ extern CLIENT *clnt_tli_create(const SOCKET, const struct netconfig *,
- /*
- * Low level clnt create routine for connectionful transports, e.g. tcp.
- */
- -extern CLIENT *clnt_vc_create(const SOCKET, const struct netbuf *,
- +extern CLIENT *clnt_vc_create(const int, const struct netbuf *,
- const rpcprog_t, const rpcvers_t,
- u_int, u_int, int (*cb_xdr)(void *, void *),
- int (*cb)(void *, void *, void **), void *args);
- @@ -432,7 +432,7 @@ extern CLIENT *clntunix_create(struct sockaddr_un *,
- /*
- * Low level clnt create routine for connectionless transports, e.g. udp.
- */
- -extern CLIENT *clnt_dg_create(const SOCKET, const struct netbuf *,
- +extern CLIENT *clnt_dg_create(const int, const struct netbuf *,
- const rpcprog_t, const rpcvers_t,
- const u_int, const u_int);
- /*
- diff --git a/libtirpc/tirpc/rpc/clnt_soc.h b/libtirpc/tirpc/rpc/clnt_soc.h
- index 582f555..4cf4d78 100644
- --- a/libtirpc/tirpc/rpc/clnt_soc.h
- +++ b/libtirpc/tirpc/rpc/clnt_soc.h
- @@ -62,7 +62,7 @@
- * u_int recvsz;
- */
- __BEGIN_DECLS
- -extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, SOCKET *,
- +extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, int *,
- u_int, u_int);
- __END_DECLS
- diff --git a/libtirpc/tirpc/rpc/rpc.h b/libtirpc/tirpc/rpc/rpc.h
- index 685fe42..e136149 100644
- --- a/libtirpc/tirpc/rpc/rpc.h
- +++ b/libtirpc/tirpc/rpc/rpc.h
- @@ -82,7 +82,7 @@
- __BEGIN_DECLS
- extern int get_myaddress(struct sockaddr_in *);
- -extern int bindresvport(SOCKET, struct sockaddr_in *) __THROW;
- +extern int bindresvport(int, struct sockaddr_in *) __THROW;
- extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]),
- xdrproc_t, xdrproc_t);
- extern int callrpc(const char *, int, int, int, xdrproc_t, void *,
- @@ -96,7 +96,7 @@ void freeuaddr(char *); /* free memory allocated by taddr2uaddr */
- void freenetbuf(struct netbuf *); /* free memory allocated by uaddr2taddr */
- struct sockaddr;
- -extern int bindresvport_sa(SOCKET, struct sockaddr *);
- +extern int bindresvport_sa(int, struct sockaddr *);
- __END_DECLS
- /*
- @@ -104,9 +104,9 @@ __END_DECLS
- * and rpcbind use only. Do not use, they may change without notice.
- */
- __BEGIN_DECLS
- -SOCKET __rpc_nconf2fd(const struct netconfig *);
- +int __rpc_nconf2fd(const struct netconfig *);
- int __rpc_nconf2sockinfo(const struct netconfig *, struct __rpc_sockinfo *);
- -int __rpc_fd2sockinfo(SOCKET, struct __rpc_sockinfo *);
- +int __rpc_fd2sockinfo(int, struct __rpc_sockinfo *);
- u_int __rpc_get_t_size(int, int, int);
- __END_DECLS
- diff --git a/libtirpc/tirpc/rpc/rpc_com.h b/libtirpc/tirpc/rpc/rpc_com.h
- index adde181..096cf23 100644
- --- a/libtirpc/tirpc/rpc/rpc_com.h
- +++ b/libtirpc/tirpc/rpc/rpc_com.h
- @@ -74,7 +74,7 @@ int __rpc_sockinfo2netid(struct __rpc_sockinfo *, const char **);
- int __rpc_seman2socktype(int);
- int __rpc_socktype2seman(int);
- void *rpc_nullproc(CLIENT *);
- -int __rpc_sockisbound(SOCKET);
- +int __rpc_sockisbound(int);
- struct netbuf *__rpcb_findaddr(rpcprog_t, rpcvers_t, const struct netconfig *,
- const char *, CLIENT **);
- diff --git a/libtirpc/tirpc/rpc/svc.h b/libtirpc/tirpc/rpc/svc.h
- index a919c50..c39c1dc 100644
- --- a/libtirpc/tirpc/rpc/svc.h
- +++ b/libtirpc/tirpc/rpc/svc.h
- @@ -88,7 +88,7 @@ enum xprt_stat {
- * Server side transport handle
- */
- typedef struct __rpc_svcxprt {
- - SOCKET xp_fd;
- + int xp_fd;
- u_short xp_port; /* associated port number */
- const struct xp_ops {
- /* receive incoming requests */
- @@ -313,7 +313,7 @@ __END_DECLS
- __BEGIN_DECLS
- extern void svc_getreq(int);
- extern void svc_getreqset(fd_set *);
- -extern void svc_getreq_common(SOCKET);
- +extern void svc_getreq_common(int);
- struct pollfd;
- extern void svc_getreq_poll(struct pollfd *, int);
- @@ -364,11 +364,11 @@ extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
- /*
- * Generic TLI create routine
- */
- -extern SVCXPRT *svc_tli_create(const SOCKET, const struct netconfig *,
- +extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
- const struct t_bind *, const u_int,
- const u_int);
- /*
- - * const SOCKET fd; -- connection end point
- + * const int fd; -- connection end point
- * const struct netconfig *nconf; -- netconfig structure for network
- * const struct t_bind *bindaddr; -- local bind address
- * const u_int sendsz; -- max sendsize
- @@ -379,9 +379,9 @@ extern SVCXPRT *svc_tli_create(const SOCKET, const struct netconfig *,
- * Connectionless and connectionful create routines
- */
- -extern SVCXPRT *svc_vc_create(const SOCKET, const u_int, const u_int);
- +extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
- /*
- - * const SOCKET fd; -- open connection end point
- + * const int fd; -- open connection end point
- * const u_int sendsize; -- max send size
- * const u_int recvsize; -- max recv size
- */
- @@ -391,9 +391,9 @@ extern SVCXPRT *svc_vc_create(const SOCKET, const u_int, const u_int);
- */
- extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
- -extern SVCXPRT *svc_dg_create(const SOCKET, const u_int, const u_int);
- +extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
- /*
- - * const SOCKET fd; -- open connection
- + * const int fd; -- open connection
- * const u_int sendsize; -- max send size
- * const u_int recvsize; -- max recv size
- */
- @@ -403,9 +403,9 @@ extern SVCXPRT *svc_dg_create(const SOCKET, const u_int, const u_int);
- * the routine takes any *open* connection
- * descriptor as its first input and is used for open connections.
- */
- -extern SVCXPRT *svc_fd_create(const SOCKET, const u_int, const u_int);
- +extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
- /*
- - * const SOCKET fd; -- open connection end point
- + * const int fd; -- open connection end point
- * const u_int sendsize; -- max send size
- * const u_int recvsize; -- max recv size
- */
- diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
- index a299835..4d4ae1f 100644
- --- a/libtirpc/tirpc/wintirpc.h
- +++ b/libtirpc/tirpc/wintirpc.h
- @@ -44,6 +44,13 @@
- #include <windows.h>
- #include <process.h>
- #include <basetsd.h>
- +#include <fcntl.h>
- +#include <io.h>
- +
- +/* warn about int to pointer */
- +#pragma warning (error : 4312)
- +/* conversion from 'int' to '_HFILE' of greater size */
- +#pragma warning (error : 4306)
- //#define snprintf _snprintf
- //#define vsnprintf _vsnprintf
- @@ -66,8 +73,7 @@
- /*
- * Hash of Windows Socket Handle values
- */
- -#define WINSOCK_HANDLE_HASH_SIZE 1024
- -#define WINSOCK_HANDLE_HASH(x) (((x) >> 2) % WINSOCK_HANDLE_HASH_SIZE)
- +#define WINSOCK_HANDLE_HASH(x) (x)
- /*
- * Functions imported from BSD
- @@ -95,6 +101,15 @@ struct sockaddr_un {
- /* XXX Should this return size_t or unsigned int ?? */
- #define SUN_LEN(ptr) ((unsigned int)(sizeof(int) + strlen ((ptr)->sun_path)))
- +/* Prototypes */
- +int wintirpc_socket(int af,int type, int protocol);
- +int wintirpc_closesocket(int in_fd);
- +int wintirpc_accept(int s_fd, struct sockaddr *addr, int *addrlen);
- +void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
- +void wintirpc_unregister_osfhandle(SOCKET handle);
- +int wintirpc_osfhandle2fd(SOCKET handle);
- +void warnx(LPCSTR format, ...);
- +
- /* Debugging function */
- void wintirpc_debug(char *fmt, ...);
- diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
- index 93ee7a9..d43334a 100644
- --- a/sys/nfs41_build_features.h
- +++ b/sys/nfs41_build_features.h
- @@ -32,19 +32,19 @@
- /*
- * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
- */
- -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
- +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
- /*
- * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
- * files which do not map to a local account a SID in the
- * Unix_User+x/Unix_Group+x range
- */
- -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
- +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
- /*
- * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
- * as "name service"
- */
- -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
- +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
- #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
msnfs41client: prototype fix for libtirpc hang
Posted by Anonymous on Thu 26th Oct 2023 18:06
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.