* Fix windows makefile to deal with spaces in topdir
* offset time to Unix epoch so that gettimeofday returns sane values on windows * attempted hack at making non-blocking I/O work for iovecs in Windows This commit was SVN r3485.
Этот коммит содержится в:
родитель
6f824e6dc3
Коммит
a5c9184ba6
@ -9,10 +9,12 @@
|
||||
# include<time.h>
|
||||
#endif
|
||||
|
||||
#define EPOCHFILETIME (116444736000000000LL)
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
||||
|
||||
FILETIME file_time;
|
||||
ULARGE_INTEGER place_holder;
|
||||
LARGE_INTEGER place_holder;
|
||||
__int64 time;
|
||||
|
||||
|
||||
@ -25,7 +27,8 @@ int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
||||
place_holder.LowPart = file_time.dwLowDateTime;
|
||||
place_holder.HighPart = file_time.dwHighDateTime;
|
||||
time = place_holder.QuadPart;
|
||||
|
||||
time -= EPOCHFILETIME;
|
||||
|
||||
/* Now we can use arithmetic operations on time which is nothing but
|
||||
a 64 bit integer holding time in 100 nanosec intervals */
|
||||
|
||||
|
@ -12,111 +12,33 @@
|
||||
of code to handle the windows error flags
|
||||
*/
|
||||
|
||||
int writev(int fd,struct iovec * iov,int cnt) {
|
||||
|
||||
int i;
|
||||
int ret = 0;
|
||||
int rc;
|
||||
|
||||
for( i = 0; i < cnt; i++ ) {
|
||||
rc=writeconn( (SOCKET)fd, (char *)iov[i].iov_base, iov[i].iov_len );
|
||||
int
|
||||
writev(int fd,struct iovec * iov,int cnt)
|
||||
{
|
||||
int err;
|
||||
DWORD sendlen;
|
||||
|
||||
/* return 0 if this is a non-blocking socket and no data was available
|
||||
for reading. Else, return the error back to the users */
|
||||
if(rc < 0) {
|
||||
return (errno == EAGAIN) ? ret : rc;
|
||||
}
|
||||
ret += rc;
|
||||
}
|
||||
err = WSASend((SOCKET) fd, &(iov->data), cnt, &sendlen, 0, NULL, NULL);
|
||||
|
||||
return ret;
|
||||
if (err < 0) {
|
||||
return err;
|
||||
} else {
|
||||
return (int) sendlen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int readv(int fd,struct iovec * iov,int cnt) {
|
||||
|
||||
int i;
|
||||
int ret = 0;
|
||||
int rc;
|
||||
|
||||
for( i = 0; i < cnt; i++ ) {
|
||||
rc=readconn( (SOCKET)fd, (char *)iov[i].iov_base, iov[i].iov_len );
|
||||
int
|
||||
readv(int fd,struct iovec * iov,int cnt)
|
||||
{
|
||||
int err;
|
||||
DWORD recvlen = 0;
|
||||
DWORD flags = 0;
|
||||
err = WSARecv((SOCKET) fd, &(iov->data), cnt, &recvlen, &flags, NULL, NULL);
|
||||
|
||||
/* return 0 if this is a non-blocking socket and no data was available
|
||||
for reading. Else, return the error back to the users */
|
||||
if(rc < 0) {
|
||||
return (errno == EAGAIN) ? ret : rc;
|
||||
}
|
||||
ret += rc;
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (err < 0) {
|
||||
return err;
|
||||
} else {
|
||||
return (int) recvlen;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ANJU: This function does not handle the non-blocking IO at all. Yet
|
||||
to add modifications which will enable non-blocking IO */
|
||||
int writeconn (int s, char *data, int len) {
|
||||
|
||||
int i;
|
||||
int tosend = len;
|
||||
int gone = 0;
|
||||
int fluffed = 0;
|
||||
|
||||
for (i=0; tosend > 0; ) {
|
||||
|
||||
gone = write(s, &data[i], tosend);
|
||||
|
||||
if (0 > gone) {
|
||||
fluffed++;
|
||||
if (RETRIES == fluffed) {
|
||||
/* There was code in here to close the socket. I think
|
||||
that would not be the best thing to do in case of
|
||||
nono-blocking sockets. In any case, I need to look
|
||||
up hpw winsocks function before making concrete
|
||||
changes. This will do for compilation for now */
|
||||
return (i);
|
||||
}
|
||||
} else {
|
||||
i += gone;
|
||||
tosend -= gone;
|
||||
fluffed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
ANJU: This function does not handle the non-blocking IO at all. Yet
|
||||
to add modifications which will enable non-blocking IO */
|
||||
int readconn (int s, char *data, int len) {
|
||||
|
||||
int i;
|
||||
unsigned int toget = (unsigned)len;
|
||||
int got, fluffed = 0;
|
||||
|
||||
for (i=0; toget > 0; ) {
|
||||
|
||||
got = read(s, &data[i], toget);
|
||||
|
||||
/* Check if some error has occured */
|
||||
if (0 > got) {
|
||||
fluffed++;
|
||||
if (RETRIES == fluffed) {
|
||||
/* There was code in here to close the socket. I think
|
||||
that would not be the best thing to do in case of
|
||||
nono-blocking sockets. In any case, I need to look
|
||||
up hpw winsocks function before making concrete
|
||||
changes. This will do for compilation for now */
|
||||
return (i);
|
||||
}
|
||||
} else {
|
||||
i += got;
|
||||
toget -= got;
|
||||
fluffed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -5,15 +5,16 @@
|
||||
#ifndef OMPI_UIO_H
|
||||
#define OMPI_UIO_H
|
||||
|
||||
#define RETRIES 2 /* ft-mpi defines it this way */
|
||||
#include "ompi_declspec.h"
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* define the iovec structure */
|
||||
struct iovec{
|
||||
void * iov_base;
|
||||
size_t iov_len;
|
||||
struct iovec {
|
||||
WSABUF data;
|
||||
};
|
||||
|
||||
#define iov_base data.buf
|
||||
#define iov_len data.len
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
extern "C" {
|
||||
@ -35,17 +36,6 @@ OMPI_DECLSPEC int writev (int fd, struct iovec *iov, int cnt);
|
||||
buffer.
|
||||
*/
|
||||
OMPI_DECLSPEC int readv (int fd, struct iovec *iov, int cnt);
|
||||
|
||||
/* static inlined helper functions to push the write through.
|
||||
This was almost completely lifted from ft-mpi code. please
|
||||
check Harness/hcore/share/snipe_lite.c for more details.
|
||||
The only difference being that harness code was implemented
|
||||
for blocking operations only */
|
||||
|
||||
OMPI_DECLSPEC int writeconn (int s,char * data,int len);
|
||||
|
||||
OMPI_DECLSPEC int readconn (int s,char * data,int len);
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ prebuild:
|
||||
> "${topdir}/src/util/show_help_lex.c" 2>/dev/null
|
||||
@echo -n "Copying static-components.h to the right directories ......"
|
||||
@for dirs in ${STATIC_LIBS}; do \
|
||||
(dir=mca/$${dirs}/base; comp_name=$${dirs}_static-components.h; cp ${topdir}/src/win32/generated_include/$${comp_name} $${dir}/static-components.h;); \
|
||||
(dir="mca/$${dirs}/base"; comp_name="$${dirs}_static-components.h"; cp "${topdir}/src/win32/generated_include/$${comp_name}" "$${dir}/static-components.h";); \
|
||||
done
|
||||
@echo "done"
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user