Restored lost files and changes in version 1.3.1 to depot.

This commit is contained in:
crs
2007-06-17 11:19:18 +00:00
parent 73acb7860d
commit 52ae656411
199 changed files with 27622 additions and 13726 deletions

View File

@@ -31,9 +31,6 @@
#if HAVE_POLL
# include <poll.h>
# if HAVE_ALLOCA_H
# include <alloca.h>
# endif
#else
# if HAVE_SYS_SELECT_H
# include <sys/select.h>
@@ -47,13 +44,6 @@
# include <stdio.h>
#endif
#if HAVE_ALLOCA_H
# define freea(x_)
#else
# define alloca(x_) malloc(x_)
# define freea(x_) free(x_)
#endif
static const int s_family[] = {
PF_UNSPEC,
PF_INET
@@ -291,8 +281,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
}
// allocate space for translated query
struct pollfd* pfd = reinterpret_cast<struct pollfd*>(
alloca((1 + num) * sizeof(struct pollfd)));
struct pollfd* pfd = new struct pollfd[1 + num];
// translate query
for (int i = 0; i < num; ++i) {
@@ -322,7 +311,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
n = poll(pfd, n, t);
// reset the unblock pipe
if (unblockPipe != NULL && (pfd[num].revents & POLLIN) != 0) {
if (n > 0 && unblockPipe != NULL && (pfd[num].revents & POLLIN) != 0) {
// the unblock event was signalled. flush the pipe.
char dummy[100];
do {
@@ -338,10 +327,10 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
if (errno == EINTR) {
// interrupted system call
ARCH->testCancelThread();
freea(pfd);
delete[] pfd;
return 0;
}
freea(pfd);
delete[] pfd;
throwError(errno);
}
@@ -362,7 +351,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
}
}
freea(pfd);
delete[] pfd;
return n;
}
@@ -452,7 +441,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
SELECT_TYPE_ARG5 timeout2P);
// reset the unblock pipe
if (unblockPipe != NULL && FD_ISSET(unblockPipe[0], &readSet)) {
if (n > 0 && unblockPipe != NULL && FD_ISSET(unblockPipe[0], &readSet)) {
// the unblock event was signalled. flush the pipe.
char dummy[100];
do {
@@ -594,6 +583,29 @@ CArchNetworkBSD::setNoDelayOnSocket(CArchSocket s, bool noDelay)
return (oflag != 0);
}
bool
CArchNetworkBSD::setReuseAddrOnSocket(CArchSocket s, bool reuse)
{
assert(s != NULL);
// get old state
int oflag;
socklen_t size = sizeof(oflag);
if (getsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR,
(optval_t*)&oflag, &size) == -1) {
throwError(errno);
}
int flag = reuse ? 1 : 0;
size = sizeof(flag);
if (setsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR,
(optval_t*)&flag, size) == -1) {
throwError(errno);
}
return (oflag != 0);
}
std::string
CArchNetworkBSD::getHostName()
{