X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Frx%2FFBSD%2Frx_knet.c;h=5aa504e582945d851c9659c56fc33968ae56b0d9;hp=d4883d7d4abf08a9fbebb41d1ebb9513d0988aa4;hb=530c491c673154c5c935bd339c6d00850d454190;hpb=0ee73ecbff418d253076923681174560030ef753 diff --git a/src/rx/FBSD/rx_knet.c b/src/rx/FBSD/rx_knet.c index d4883d7..5aa504e 100644 --- a/src/rx/FBSD/rx_knet.c +++ b/src/rx/FBSD/rx_knet.c @@ -26,62 +26,61 @@ RCSID("$Header$"); #ifdef AFS_FBSD40_ENV +#include #include "rx/rx_kcommon.h" - #ifdef RXK_LISTENER_ENV -int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, - int nvecs, int *alength) -{ +int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, + int nvecs, int *alength) +{ struct socket *asocket = (struct socket *)so; struct uio u; int i; struct iovec iov[RX_MAXIOVECS]; - struct sockaddr *sa; + struct sockaddr *sa = NULL; int code; int haveGlock = ISAFS_GLOCK(); /*AFS_STATCNT(osi_NetReceive);*/ - if (nvecs > RX_MAXIOVECS) { + if (nvecs > RX_MAXIOVECS) osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs); - } - for (i = 0 ; i < nvecs ; i++) { - iov[i].iov_base = dvec[i].iov_base; - iov[i].iov_len = dvec[i].iov_len; - } + for (i = 0 ; i < nvecs ; i++) + iov[i] = dvec[i]; - u.uio_iov=&iov[0]; - u.uio_iovcnt=nvecs; - u.uio_offset=0; - u.uio_resid=*alength; - u.uio_segflg=UIO_SYSSPACE; - u.uio_rw=UIO_READ; - u.uio_procp=NULL; + u.uio_iov = &iov[0]; + u.uio_iovcnt = nvecs; + u.uio_offset = 0; + u.uio_resid = *alength; + u.uio_segflg = UIO_SYSSPACE; + u.uio_rw = UIO_READ; + u.uio_procp = NULL; - if (haveGlock) { + if (haveGlock) AFS_GUNLOCK(); - } code = soreceive(asocket, &sa, &u, NULL, NULL, NULL); -#if KNET_DEBUG + if (haveGlock) + AFS_GLOCK(); + if (code) { +#if KNET_DEBUG if (code == EINVAL) - Debugger("afs NetReceive busted"); + Debugger("afs NetReceive busted"); else - printf("y"); - } + printf("y"); +#else + return code; #endif - if (haveGlock) { - AFS_GLOCK(); } - *alength=*alength-u.uio_resid; + *alength -= u.uio_resid; if (sa) { - if (sa->sa_family == AF_INET) { - if (addr) *addr=*(struct sockaddr_in *)sa; - } else { - printf("Unknown socket family %d in NetReceive\n", sa->sa_family); - } + if (sa->sa_family == AF_INET) { + if (addr) + *addr = *(struct sockaddr_in *) sa; + } else + printf("Unknown socket family %d in NetReceive\n", sa->sa_family); + FREE(sa, M_SONAME); } return code; } @@ -89,65 +88,57 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, extern int rxk_ListenerPid; void osi_StopListener(void) { - struct proc *p; + struct proc *p; - soclose(rx_socket); - p=pfind(rxk_ListenerPid); - if (p) - psignal(p, SIGUSR1); + soclose(rx_socket); + p = pfind(rxk_ListenerPid); + if (p) + psignal(p, SIGUSR1); } -int +int osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec, int nvecs, afs_int32 alength, int istack) { register afs_int32 code; - int s; - int len; int i; struct iovec iov[RX_MAXIOVECS]; - char *tdata; struct uio u; int haveGlock = ISAFS_GLOCK(); AFS_STATCNT(osi_NetSend); - if (nvecs > RX_MAXIOVECS) { + if (nvecs > RX_MAXIOVECS) osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs); - } - for (i = 0 ; i < nvecs ; i++) { - iov[i].iov_base = dvec[i].iov_base; - iov[i].iov_len = dvec[i].iov_len; - } + for (i = 0 ; i < nvecs ; i++) + iov[i] = dvec[i]; - u.uio_iov=&iov[0]; - u.uio_iovcnt=nvecs; - u.uio_offset=0; - u.uio_resid=alength; - u.uio_segflg=UIO_SYSSPACE; - u.uio_rw=UIO_WRITE; - u.uio_procp=NULL; + u.uio_iov = &iov[0]; + u.uio_iovcnt = nvecs; + u.uio_offset = 0; + u.uio_resid = alength; + u.uio_segflg = UIO_SYSSPACE; + u.uio_rw = UIO_WRITE; + u.uio_procp = NULL; - addr->sin_len=sizeof(struct sockaddr_in); + addr->sin_len = sizeof(struct sockaddr_in); - if (haveGlock) { + if (haveGlock) AFS_GUNLOCK(); - } #if KNET_DEBUG printf("+"); #endif - code = sosend(asocket, addr, &u, NULL, NULL, 0, curproc); + code = sosend(asocket, (struct sockaddr *) addr, &u, NULL, NULL, 0, curproc); #if KNET_DEBUG if (code) { if (code == EINVAL) - Debugger("afs NetSend busted"); + Debugger("afs NetSend busted"); else - printf("z"); + printf("z"); } #endif - if (haveGlock) { + if (haveGlock) AFS_GLOCK(); - } return code; } #else