From 68a62b8335b7ac2f602ad6106ab6ffeedd35de0f Mon Sep 17 00:00:00 2001 From: ericm Date: Thu, 21 Aug 2003 04:16:54 +0000 Subject: [PATCH] [tcpnal]: merge LiuKai's cygwin patch --- lnet/ulnds/connection.c | 27 +++++++++++++++++---------- lnet/ulnds/procapi.c | 1 - lnet/ulnds/proclib.c | 1 - lnet/ulnds/socklnd/connection.c | 27 +++++++++++++++++---------- lnet/ulnds/socklnd/procapi.c | 1 - lnet/ulnds/socklnd/proclib.c | 1 - lnet/ulnds/socklnd/tcplnd.c | 17 ++++++++++++++++- lnet/ulnds/tcplnd.c | 17 ++++++++++++++++- lustre/portals/unals/connection.c | 27 +++++++++++++++++---------- lustre/portals/unals/procapi.c | 1 - lustre/portals/unals/proclib.c | 1 - lustre/portals/unals/tcpnal.c | 17 ++++++++++++++++- 12 files changed, 99 insertions(+), 39 deletions(-) diff --git a/lnet/ulnds/connection.c b/lnet/ulnds/connection.c index 0fe6e60..b40a17c 100644 --- a/lnet/ulnds/connection.c +++ b/lnet/ulnds/connection.c @@ -34,13 +34,15 @@ #include #include #include -#include #include #include #include #include #include #include +#ifndef __CYGWIN__ +#include +#endif /* global variable: acceptor port */ @@ -113,22 +115,27 @@ int read_connection(connection c, unsigned char *dest, int len) { - int offset=0,rc; + int offset = 0,rc; - if (len){ + if (len) { do { - if((rc=syscall(SYS_read, c->fd, dest+offset, len-offset))<=0){ - if (errno==EINTR) { - rc=0; +#ifndef __CYGWIN__ + rc = syscall(SYS_read, c->fd, dest+offset, len-offset); +#else + rc = recv(c->fd, dest+offset, len-offset, 0); +#endif + if (rc <= 0) { + if (errno == EINTR) { + rc = 0; } else { remove_connection(c); - return(0); + return (0); } } - offset+=rc; - } while (offset #include #include -#include #include #include #include diff --git a/lnet/ulnds/proclib.c b/lnet/ulnds/proclib.c index 57aeaad..dcd64ed 100644 --- a/lnet/ulnds/proclib.c +++ b/lnet/ulnds/proclib.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/lnet/ulnds/socklnd/connection.c b/lnet/ulnds/socklnd/connection.c index 0fe6e60..b40a17c 100644 --- a/lnet/ulnds/socklnd/connection.c +++ b/lnet/ulnds/socklnd/connection.c @@ -34,13 +34,15 @@ #include #include #include -#include #include #include #include #include #include #include +#ifndef __CYGWIN__ +#include +#endif /* global variable: acceptor port */ @@ -113,22 +115,27 @@ int read_connection(connection c, unsigned char *dest, int len) { - int offset=0,rc; + int offset = 0,rc; - if (len){ + if (len) { do { - if((rc=syscall(SYS_read, c->fd, dest+offset, len-offset))<=0){ - if (errno==EINTR) { - rc=0; +#ifndef __CYGWIN__ + rc = syscall(SYS_read, c->fd, dest+offset, len-offset); +#else + rc = recv(c->fd, dest+offset, len-offset, 0); +#endif + if (rc <= 0) { + if (errno == EINTR) { + rc = 0; } else { remove_connection(c); - return(0); + return (0); } } - offset+=rc; - } while (offset #include #include -#include #include #include #include diff --git a/lnet/ulnds/socklnd/proclib.c b/lnet/ulnds/socklnd/proclib.c index 57aeaad..dcd64ed 100644 --- a/lnet/ulnds/socklnd/proclib.c +++ b/lnet/ulnds/socklnd/proclib.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/lnet/ulnds/socklnd/tcplnd.c b/lnet/ulnds/socklnd/tcplnd.c index b8641b5..f14a1fc 100644 --- a/lnet/ulnds/socklnd/tcplnd.c +++ b/lnet/ulnds/socklnd/tcplnd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,11 @@ #include #include #include +#ifndef __CYGWIN__ +#include +#else +#include +#endif /* Function: tcpnal_send * Arguments: nal: pointer to my nal control block @@ -65,6 +69,10 @@ int tcpnal_send(nal_cb_t *n, connection c; bridge b=(bridge)n->nal_data; struct iovec tiov[257]; +#ifdef __CYGWIN__ + static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; + int i; +#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -90,7 +98,14 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); +#ifndef __CYGWIN__ syscall(SYS_writev, c->fd, tiov, niov+1); +#else + pthread_mutex_lock(&send_lock); + for (i = 0; i <= niov; i++) + send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + pthread_mutex_unlock(&send_lock); +#endif #endif lib_finalize(n, private, cookie); diff --git a/lnet/ulnds/tcplnd.c b/lnet/ulnds/tcplnd.c index b8641b5..f14a1fc 100644 --- a/lnet/ulnds/tcplnd.c +++ b/lnet/ulnds/tcplnd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,11 @@ #include #include #include +#ifndef __CYGWIN__ +#include +#else +#include +#endif /* Function: tcpnal_send * Arguments: nal: pointer to my nal control block @@ -65,6 +69,10 @@ int tcpnal_send(nal_cb_t *n, connection c; bridge b=(bridge)n->nal_data; struct iovec tiov[257]; +#ifdef __CYGWIN__ + static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; + int i; +#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -90,7 +98,14 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); +#ifndef __CYGWIN__ syscall(SYS_writev, c->fd, tiov, niov+1); +#else + pthread_mutex_lock(&send_lock); + for (i = 0; i <= niov; i++) + send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + pthread_mutex_unlock(&send_lock); +#endif #endif lib_finalize(n, private, cookie); diff --git a/lustre/portals/unals/connection.c b/lustre/portals/unals/connection.c index 0fe6e60..b40a17c 100644 --- a/lustre/portals/unals/connection.c +++ b/lustre/portals/unals/connection.c @@ -34,13 +34,15 @@ #include #include #include -#include #include #include #include #include #include #include +#ifndef __CYGWIN__ +#include +#endif /* global variable: acceptor port */ @@ -113,22 +115,27 @@ int read_connection(connection c, unsigned char *dest, int len) { - int offset=0,rc; + int offset = 0,rc; - if (len){ + if (len) { do { - if((rc=syscall(SYS_read, c->fd, dest+offset, len-offset))<=0){ - if (errno==EINTR) { - rc=0; +#ifndef __CYGWIN__ + rc = syscall(SYS_read, c->fd, dest+offset, len-offset); +#else + rc = recv(c->fd, dest+offset, len-offset, 0); +#endif + if (rc <= 0) { + if (errno == EINTR) { + rc = 0; } else { remove_connection(c); - return(0); + return (0); } } - offset+=rc; - } while (offset #include #include -#include #include #include #include diff --git a/lustre/portals/unals/proclib.c b/lustre/portals/unals/proclib.c index 57aeaad..dcd64ed 100644 --- a/lustre/portals/unals/proclib.c +++ b/lustre/portals/unals/proclib.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/portals/unals/tcpnal.c b/lustre/portals/unals/tcpnal.c index b8641b5..f14a1fc 100644 --- a/lustre/portals/unals/tcpnal.c +++ b/lustre/portals/unals/tcpnal.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,11 @@ #include #include #include +#ifndef __CYGWIN__ +#include +#else +#include +#endif /* Function: tcpnal_send * Arguments: nal: pointer to my nal control block @@ -65,6 +69,10 @@ int tcpnal_send(nal_cb_t *n, connection c; bridge b=(bridge)n->nal_data; struct iovec tiov[257]; +#ifdef __CYGWIN__ + static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; + int i; +#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -90,7 +98,14 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); +#ifndef __CYGWIN__ syscall(SYS_writev, c->fd, tiov, niov+1); +#else + pthread_mutex_lock(&send_lock); + for (i = 0; i <= niov; i++) + send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + pthread_mutex_unlock(&send_lock); +#endif #endif lib_finalize(n, private, cookie); -- 1.8.3.1