1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-02-11 12:24:40 +00:00
parent 509f005be7
commit 7c808317dc
1367 changed files with 394342 additions and 413129 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,28 +40,27 @@
namespace multicast
{
class MulticastImpl
{
public:
MulticastImpl(int min_receivers, const std::string& ifName, int portBase = 9000, int bufSize = 8 * 1024 * 1024);
~MulticastImpl();
public:
MulticastImpl(int min_receivers, const std::string& ifName, int portBase = 9000,
int bufSize = 8 * 1024 * 1024);
~MulticastImpl();
void startSender();
void doTransfer(const uint8_t* buf, uint32_t len);
void startSender();
void doTransfer(const uint8_t* buf, uint32_t len);
void startReceiver();
void receive(messageqcpp::SBS obs);
void startReceiver();
void receive(messageqcpp::SBS obs);
struct net_config fNet_config;
struct stat_config fStat_config;
struct client_config fClient_config;
std::string fIfName;
int fSock[3];
participantsDb_t fDb;
struct net_config fNet_config;
struct stat_config fStat_config;
struct client_config fClient_config;
std::string fIfName;
int fSock[3];
participantsDb_t fDb;
};
}
} // namespace multicast
#endif

View File

@ -23,14 +23,14 @@
typedef struct fifo
{
unsigned char* dataBuffer;
unsigned int dataBufSize;
unsigned char* dataBuffer;
unsigned int dataBufSize;
produconsum_t freeMemQueue; /* queue for free memory */
produconsum_t data; /* queue for received data or data received
* from disk */
produconsum_t freeMemQueue; /* queue for free memory */
produconsum_t data; /* queue for received data or data received
* from disk */
pthread_t thread;
}* fifo_t;
pthread_t thread;
} * fifo_t;
#endif

View File

@ -36,37 +36,35 @@ using namespace config;
namespace multicast
{
Multicast::Multicast() :
fPMCount(1),
fIFName("eth0"),
fPortBase(9000),
fBufSize(8 * 1024 * 1024)
Multicast::Multicast() : fPMCount(1), fIFName("eth0"), fPortBase(9000), fBufSize(8 * 1024 * 1024)
{
int tmp;
string stmp;
int tmp;
string stmp;
Config* cf = Config::makeConfig();
Config* cf = Config::makeConfig();
tmp = Config::fromText(cf->getConfig("PrimitiveServers", "Count"));
tmp = Config::fromText(cf->getConfig("PrimitiveServers", "Count"));
if (tmp > 0) fPMCount = tmp;
if (tmp > 0)
fPMCount = tmp;
stmp = cf->getConfig("Multicast", "Interface");
stmp = cf->getConfig("Multicast", "Interface");
if (!stmp.empty()) fIFName = stmp;
if (!stmp.empty())
fIFName = stmp;
tmp = Config::fromText(cf->getConfig("Multicast", "PortBase"));
tmp = Config::fromText(cf->getConfig("Multicast", "PortBase"));
if (tmp > 0) fPortBase = tmp;
if (tmp > 0)
fPortBase = tmp;
tmp = Config::fromText(cf->getConfig("Multicast", "BufSize"));
tmp = Config::fromText(cf->getConfig("Multicast", "BufSize"));
if (tmp > 0) fBufSize = tmp;
if (tmp > 0)
fBufSize = tmp;
}
MulticastReceiver::MulticastReceiver() :
fPimpl(0)
MulticastReceiver::MulticastReceiver() : fPimpl(0)
{
}
@ -76,12 +74,11 @@ MulticastReceiver::~MulticastReceiver()
SBS MulticastReceiver::receive()
{
throw runtime_error("Multicast is not available");
return fByteStream;
throw runtime_error("Multicast is not available");
return fByteStream;
}
MulticastSender::MulticastSender() :
fPimpl(0)
MulticastSender::MulticastSender() : fPimpl(0)
{
}
@ -91,9 +88,9 @@ MulticastSender::~MulticastSender()
void MulticastSender::send(const ByteStream& msg)
{
throw runtime_error("Multicast is not available");
throw runtime_error("Multicast is not available");
}
} //namespace multicast
} // namespace multicast
//vim:ts=4 sw=4:
// vim:ts=4 sw=4:

View File

@ -31,104 +31,101 @@
namespace multicast
{
/** @brief MulticastReceive
* Wrapper for multicast proto
*/
* Wrapper for multicast proto
*/
class MulticastImpl;
class Multicast
{
public:
/** @brief ctor
* Base class
*/
Multicast();
public:
/** @brief ctor
* Base class
*/
Multicast();
/** @brief dtor
*/
virtual ~Multicast()
{
destroy();
}
/** @brief dtor
*/
virtual ~Multicast()
{
destroy();
}
virtual void destroy() { }
virtual void destroy()
{
}
int PMCount() const
{
return fPMCount;
}
std::string iFName() const
{
return fIFName;
}
int portBase() const
{
return fPortBase;
}
int bufSize() const
{
return fBufSize;
}
private:
int fPMCount;
std::string fIFName;
int fPortBase;
int fBufSize;
int PMCount() const
{
return fPMCount;
}
std::string iFName() const
{
return fIFName;
}
int portBase() const
{
return fPortBase;
}
int bufSize() const
{
return fBufSize;
}
private:
int fPMCount;
std::string fIFName;
int fPortBase;
int fBufSize;
};
class MulticastReceiver: public Multicast
class MulticastReceiver : public Multicast
{
public:
/** @brief ctor
*
*/
MulticastReceiver();
public:
/** @brief ctor
*
*/
MulticastReceiver();
~MulticastReceiver();
~MulticastReceiver();
messageqcpp::SBS receive();
messageqcpp::SBS receive();
private:
// not copyable
MulticastReceiver(const MulticastReceiver& rhs);
MulticastReceiver& operator=(const MulticastReceiver& rhs);
private:
// not copyable
MulticastReceiver(const MulticastReceiver& rhs);
MulticastReceiver& operator=(const MulticastReceiver& rhs);
messageqcpp::SBS fByteStream;
messageqcpp::SBS fByteStream;
MulticastImpl* fPimpl;
MulticastImpl* fPimpl;
};
class MulticastSender : public Multicast
{
public:
/** @brief ctor
*
*/
MulticastSender();
public:
/** @brief ctor
*
*/
MulticastSender();
~MulticastSender();
~MulticastSender();
/** @brief receive
*
* @param bytestream to send
*/
void send(const messageqcpp::ByteStream& bs);
/** @brief receive
*
* @param bytestream to send
*/
void send(const messageqcpp::ByteStream& bs);
private:
// Not copyable
MulticastSender(const MulticastSender& rhs);
MulticastSender& operator=(const MulticastSender& rhs);
private:
//Not copyable
MulticastSender(const MulticastSender& rhs);
MulticastSender& operator=(const MulticastSender& rhs);
MulticastImpl* fPimpl;
MulticastImpl* fPimpl;
};
} //namespace
#endif //MULTICAST_H
} // namespace multicast
#endif // MULTICAST_H

View File

@ -19,8 +19,8 @@
#define SOCKLIB_H
#ifndef UDPCAST_CONFIG_H
# define UDPCAST_CONFIG_H
# include "mcsconfig.h"
#define UDPCAST_CONFIG_H
#include "mcsconfig.h"
#endif
#include <sys/types.h>
@ -65,7 +65,7 @@
#endif
#define RECEIVER_PORT(x) (x)
#define SENDER_PORT(x) ((x)+1)
#define SENDER_PORT(x) ((x) + 1)
#define loseSendPacket udpc_loseSendPacket
#define loseRecvPacket udpc_loseRecvPacket
@ -93,20 +93,20 @@ int RecvMsg(int s, struct msghdr* msg, int flags);
struct net_if
{
struct in_addr addr;
struct in_addr bcast;
const char* name;
struct in_addr addr;
struct in_addr bcast;
const char* name;
#ifdef SIOCGIFINDEX
int index;
int index;
#endif
};
typedef struct net_if net_if_t;
typedef enum addr_type_t
{
ADDR_TYPE_UCAST,
ADDR_TYPE_MCAST,
ADDR_TYPE_BCAST
ADDR_TYPE_UCAST,
ADDR_TYPE_MCAST,
ADDR_TYPE_BCAST
} addr_type_t;
void doAutoRateLimit(int sock, int dir, int qsize, int size);
@ -117,14 +117,11 @@ void printMyIp(net_if_t* net_if);
int getSendBuf(int sock);
#define SEND(s, msg, to) \
doSend(s, &msg, sizeof(msg), &to)
#define SEND(s, msg, to) doSend(s, &msg, sizeof(msg), &to)
#define RECV(s, msg, from, portBase ) \
doReceive((s), &msg, sizeof(msg), &from, (portBase) )
#define RECV(s, msg, from, portBase) doReceive((s), &msg, sizeof(msg), &from, (portBase))
#define BCAST_CONTROL(s, msg) \
doSend(s, &msg, sizeof(msg), &net_config->controlMcastAddr)
#define BCAST_CONTROL(s, msg) doSend(s, &msg, sizeof(msg), &net_config->controlMcastAddr)
void setIpFromString(struct sockaddr_in* addr, char* ip);
@ -136,31 +133,30 @@ int udpc_socklibFatal(int code);
struct iovec
{
void* iov_base;
int iov_len;
void* iov_base;
int iov_len;
};
struct msghdr
{
void* msg_name;
int msg_namelen;
struct iovec* msg_iov;
int msg_iovlen;
void* msg_name;
int msg_namelen;
struct iovec* msg_iov;
int msg_iovlen;
};
ssize_t sendmsg(int s, const struct msghdr* msg, int flags);
ssize_t recvmsg (int fd, struct msghdr* msg, int flags);
ssize_t recvmsg(int fd, struct msghdr* msg, int flags);
#define usleep(x) Sleep((x)/1000)
#define sleep(x) Sleep(1000L*(x))
#define usleep(x) Sleep((x) / 1000)
#define sleep(x) Sleep(1000L * (x))
#endif /* __MINGW32__ */
static inline void initMsgHdr(struct msghdr* hdr)
{
#ifndef WINDOWS
hdr->msg_control = 0;
hdr->msg_controllen = 0;
hdr->msg_flags = 0;
hdr->msg_control = 0;
hdr->msg_controllen = 0;
hdr->msg_flags = 0;
#endif
}

View File

@ -18,7 +18,6 @@
#ifndef STATISTICS_H
#define STATISTICS_H
typedef struct receiver_stats* receiver_stats_t;
typedef struct sender_stats* sender_stats_t;
@ -26,17 +25,15 @@ typedef struct sender_stats* sender_stats_t;
#define receiverStatsStartTimer udpc_receiverStatsStartTimer
#define displayReceiverStats udpc_displayReceiverStats
receiver_stats_t udpc_allocReadStats(int fd, long statPeriod,
int printUncompressedPos);
receiver_stats_t udpc_allocReadStats(int fd, long statPeriod, int printUncompressedPos);
void udpc_receiverStatsStartTimer(receiver_stats_t);
void udpc_displayReceiverStats(receiver_stats_t, int isFinal);
#define allocSenderStats udpc_allocSenderStats
#define displaySenderStats udpc_displaySenderStats
sender_stats_t udpc_allocSenderStats(int fd, FILE* logfile, long bwPeriod,
long statPeriod, int printUncompressedPos);
void udpc_displaySenderStats(sender_stats_t, int blockSize, int sliceSize,
int isFinal);
sender_stats_t udpc_allocSenderStats(int fd, FILE* logfile, long bwPeriod, long statPeriod,
int printUncompressedPos);
void udpc_displaySenderStats(sender_stats_t, int blockSize, int sliceSize, int isFinal);
#endif

View File

@ -30,129 +30,115 @@ typedef HANDLE pthread_cond_t;
struct timespec
{
unsigned long tv_sec;
unsigned long tv_nsec;
unsigned long tv_sec;
unsigned long tv_nsec;
};
static inline int pthread_create(pthread_t* thread, void* dummy1,
LPTHREAD_START_ROUTINE start_routine,
static inline int pthread_create(pthread_t* thread, void* dummy1, LPTHREAD_START_ROUTINE start_routine,
void* arg)
{
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start_routine,
arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
return *thread != NULL ? 0 : -1;
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start_routine, arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
return *thread != NULL ? 0 : -1;
}
static inline int pthread_join(pthread_t th, void** thread_return)
{
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
}
static inline int pthread_mutex_init(pthread_mutex_t* mutex, void* dummy)
static inline int pthread_mutex_init(pthread_mutex_t* mutex, void* dummy)
{
InitializeCriticalSection(mutex);
InitializeCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t* mutex)
{
EnterCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t* cond, void* dummy)
{
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if (*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t* mutex)
static inline int pthread_cond_signal(pthread_cond_t* cond)
{
EnterCriticalSection(mutex);
return 0;
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
static inline int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t* cond, void* dummy)
{
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if (*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_cond_signal(pthread_cond_t* cond)
{
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_cond_wait(pthread_cond_t* cond,
pthread_mutex_t* mutex)
{
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r = WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r = WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
}
static inline void pthread_cancel(pthread_t* thread)
{
TerminateThread(thread, 0);
TerminateThread(thread, 0);
}
#define ETIMEDOUT -2
#define MILLION 1000000
#define MILLION 1000000
#define BILLION 1000000000
static inline int pthread_cond_timedwait(pthread_cond_t* cond,
pthread_mutex_t* mutex,
struct timespec* ts)
static inline int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, struct timespec* ts)
{
int r;
struct timeval tv;
long delta;
int r;
struct timeval tv;
long delta;
gettimeofday(&tv, NULL);
gettimeofday(&tv, NULL);
delta = (ts->tv_sec - tv.tv_sec) * 1000 +
(ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
delta = (ts->tv_sec - tv.tv_sec) * 1000 + (ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
if (delta < 0)
delta = 0;
if (delta < 0)
delta = 0;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
ResetEvent(*cond);
LeaveCriticalSection(mutex);
switch (WaitForSingleObject(*cond, delta ))
{
case WAIT_OBJECT_0:
r = 0;
break;
switch (WaitForSingleObject(*cond, delta))
{
case WAIT_OBJECT_0: r = 0; break;
case WAIT_TIMEOUT:
r = ETIMEDOUT;
break;
case WAIT_TIMEOUT: r = ETIMEDOUT; break;
default:
r = -1;
break;
}
default: r = -1; break;
}
EnterCriticalSection(mutex);
return r;
EnterCriticalSection(mutex);
return r;
}
#define THREAD_RETURN DWORD WINAPI
#else /* __MINGW32__ */
#include <pthread.h>
#define THREAD_RETURN void *
#define THREAD_RETURN void*
#endif /* __MINGW32__ */
#endif

View File

@ -37,20 +37,18 @@ int openFile(struct disk_config* config);
int openPipe(struct disk_config* config, int in, int* pid);
int localReader(struct fifo* fifo, int in);
#define BCAST_DATA(s, msg) \
doSend(s, &msg, sizeof(msg), &net_config->dataMcastAddr)
#define BCAST_DATA(s, msg) doSend(s, &msg, sizeof(msg), &net_config->dataMcastAddr)
/**
* "switched network" mode: server already starts sending next slice before
* first one is acknowledged. Do not use on old coax networks
*/
#define FLAG_SN 0x0001
#define FLAG_SN 0x0001
/**
* "not switched network" mode: network is known not to be switched
*/
#define FLAG_NOTSN 0x0002
#define FLAG_NOTSN 0x0002
/**
* Asynchronous mode: do not any confirmation at all from clients.
@ -58,14 +56,12 @@ int localReader(struct fifo* fifo, int in);
*/
#define FLAG_ASYNC 0x0004
/**
* Point-to-point transmission mode: use unicast in the (frequent)
* special case where there is only one receiver.
*/
#define FLAG_POINTOPOINT 0x0008
/**
* Do automatic rate limitation by monitoring socket's send buffer
* size. Not very useful, as this still doesn't protect against the
@ -94,7 +90,6 @@ int localReader(struct fifo* fifo, int in);
*/
#define FLAG_NOPOINTOPOINT 0x0040
/*
* Don't ask for keyboard input on sender end.
*/

View File

@ -28,28 +28,28 @@
*/
enum opCode
{
/* Receiver to sender */
/* Receiver to sender */
CMD_OK, /* all is ok, no need to retransmit anything */
CMD_RETRANSMIT, /* receiver asks for some data to be retransmitted */
CMD_GO, /* receiver tells server to start */
CMD_CONNECT_REQ, /* receiver tries to find out server's address */
CMD_DISCONNECT, /* receiver wants to disconnect itself */
CMD_OK, /* all is ok, no need to retransmit anything */
CMD_RETRANSMIT, /* receiver asks for some data to be retransmitted */
CMD_GO, /* receiver tells server to start */
CMD_CONNECT_REQ, /* receiver tries to find out server's address */
CMD_DISCONNECT, /* receiver wants to disconnect itself */
CMD_UNUSED, /* obsolete version of CMD_HELLO, dating back to the
* time when we had little endianness (PC). This
* opcode contained a long unnoticed bug with parsing of
* blocksize */
CMD_UNUSED, /* obsolete version of CMD_HELLO, dating back to the
* time when we had little endianness (PC). This
* opcode contained a long unnoticed bug with parsing of
* blocksize */
/* Sender to receiver */
CMD_REQACK, /* server request acknowledgments from receiver */
CMD_CONNECT_REPLY, /* receiver tries to find out server's address */
/* Sender to receiver */
CMD_REQACK, /* server request acknowledgments from receiver */
CMD_CONNECT_REPLY, /* receiver tries to find out server's address */
CMD_DATA, /* a block of data */
CMD_FEC, /* a forward-error-correction block */
CMD_DATA, /* a block of data */
CMD_FEC, /* a forward-error-correction block */
CMD_HELLO_NEW, /* sender says he's up */
CMD_HELLO_STREAMING, /* retransmitted hello during streaming mode */
CMD_HELLO_NEW, /* sender says he's up */
CMD_HELLO_STREAMING, /* retransmitted hello during streaming mode */
};
/* Sender says he's up. This is not in the enum with the others,
@ -63,114 +63,110 @@ enum opCode
struct connectReq
{
unsigned short opCode;
short reserved;
int capabilities;
unsigned int rcvbuf;
unsigned short opCode;
short reserved;
int capabilities;
unsigned int rcvbuf;
};
struct retransmit
{
unsigned short opCode;
short reserved;
int sliceNo;
int rxmit;
unsigned char map[MAX_SLICE_SIZE / BITS_PER_CHAR];
unsigned short opCode;
short reserved;
int sliceNo;
int rxmit;
unsigned char map[MAX_SLICE_SIZE / BITS_PER_CHAR];
};
struct ok
{
unsigned short opCode;
short reserved;
int sliceNo;
unsigned short opCode;
short reserved;
int sliceNo;
} ok;
union message
{
unsigned short opCode;
struct ok ok;
struct retransmit retransmit;
struct connectReq connectReq;
struct go
{
unsigned short opCode;
struct ok ok;
short reserved;
} go;
struct retransmit retransmit;
struct connectReq connectReq;
struct go
{
unsigned short opCode;
short reserved;
} go;
struct disconnect
{
unsigned short opCode;
short reserved;
} disconnect;
struct disconnect
{
unsigned short opCode;
short reserved;
} disconnect;
};
struct connectReply
{
unsigned short opCode;
short reserved;
int clNr;
int blockSize;
int capabilities;
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
unsigned short opCode;
short reserved;
int clNr;
int blockSize;
int capabilities;
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
};
struct hello
{
unsigned short opCode;
short reserved;
int capabilities;
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
short blockSize;
unsigned short opCode;
short reserved;
int capabilities;
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
short blockSize;
};
union serverControlMsg
{
unsigned short opCode;
short reserved;
struct hello hello;
struct connectReply connectReply;
unsigned short opCode;
short reserved;
struct hello hello;
struct connectReply connectReply;
};
struct dataBlock
{
unsigned short opCode;
short reserved;
int sliceNo;
unsigned short blockNo;
unsigned short reserved2;
int bytes;
unsigned short opCode;
short reserved;
int sliceNo;
unsigned short blockNo;
unsigned short reserved2;
int bytes;
};
struct fecBlock
{
unsigned short opCode;
short stripes;
int sliceNo;
unsigned short blockNo;
unsigned short reserved2;
int bytes;
unsigned short opCode;
short stripes;
int sliceNo;
unsigned short blockNo;
unsigned short reserved2;
int bytes;
};
struct reqack
{
unsigned short opCode;
short reserved;
int sliceNo;
int bytes;
int rxmit;
unsigned short opCode;
short reserved;
int sliceNo;
int bytes;
int rxmit;
};
union serverDataMsg
{
unsigned short opCode;
struct reqack reqack;
struct dataBlock dataBlock;
struct fecBlock fecBlock;
unsigned short opCode;
struct reqack reqack;
struct dataBlock dataBlock;
struct fecBlock fecBlock;
};
/* ============================================
@ -204,14 +200,8 @@ union serverDataMsg
#define CAP_ASYNC 0x0020
/* Sender currently supports CAPABILITIES and MULTICAST */
#define SENDER_CAPABILITIES ( \
CAP_NEW_GEN | \
CAP_BIG_ENDIAN)
#define RECEIVER_CAPABILITIES ( \
CAP_NEW_GEN | \
CAP_BIG_ENDIAN)
#define SENDER_CAPABILITIES (CAP_NEW_GEN | CAP_BIG_ENDIAN)
#define RECEIVER_CAPABILITIES (CAP_NEW_GEN | CAP_BIG_ENDIAN)
#endif

View File

@ -26,12 +26,10 @@
#define BITS_PER_INT (sizeof(int) * 8)
#define BITS_PER_CHAR 8
#define MAP_ZERO(l, map) (memset(map, 0, ((l) + BITS_PER_INT - 1) / BIT_PER_INT))
#define BZERO(data) (memset((void*)&data, 0, sizeof(data)))
#define MAP_ZERO(l, map) (memset(map, 0, ((l) + BITS_PER_INT - 1)/ BIT_PER_INT))
#define BZERO(data) (memset((void *)&data, 0, sizeof(data)))
#define RDATABUFSIZE (2*(MAX_SLICE_SIZE + 1)* MAX_BLOCK_SIZE)
#define RDATABUFSIZE (2 * (MAX_SLICE_SIZE + 1) * MAX_BLOCK_SIZE)
#define DATABUFSIZE (RDATABUFSIZE + 4096 - RDATABUFSIZE % 4096)
@ -46,99 +44,99 @@ int udpc_waitForProcess(int pid, const char* message);
struct disk_config
{
int origOutFile;
const char* fileName;
char* pipeName;
int flags;
int origOutFile;
const char* fileName;
char* pipeName;
int flags;
struct timeval stats_last_printed;
struct timeval stats_last_printed;
};
#define MAX_GOVERNORS 10
struct net_config
{
net_if_t* net_if; /* Network interface (eth0, isdn0, etc.) on which to
* multicast */
int portBase; /* Port base */
int blockSize;
int sliceSize;
struct sockaddr_in controlMcastAddr;
struct sockaddr_in dataMcastAddr;
const char* mcastRdv;
int ttl;
int nrGovernors;
struct rateGovernor_t* rateGovernor[MAX_GOVERNORS];
void* rateGovernorData[MAX_GOVERNORS];
/*int async;*/
/*int pointopoint;*/
struct timeval ref_tv;
net_if_t* net_if; /* Network interface (eth0, isdn0, etc.) on which to
* multicast */
int portBase; /* Port base */
int blockSize;
int sliceSize;
struct sockaddr_in controlMcastAddr;
struct sockaddr_in dataMcastAddr;
const char* mcastRdv;
int ttl;
int nrGovernors;
struct rateGovernor_t* rateGovernor[MAX_GOVERNORS];
void* rateGovernorData[MAX_GOVERNORS];
/*int async;*/
/*int pointopoint;*/
struct timeval ref_tv;
enum discovery
{
DSC_DOUBLING,
DSC_REDUCING
} discovery;
enum discovery
{
DSC_DOUBLING,
DSC_REDUCING
} discovery;
/* int autoRate; do queue watching using TIOCOUTQ, to avoid overruns */
/* int autoRate; do queue watching using TIOCOUTQ, to avoid overruns */
int flags; /* non-capability command line flags */
int capabilities;
int flags; /* non-capability command line flags */
int capabilities;
int min_slice_size;
int default_slice_size;
int max_slice_size;
unsigned int rcvbuf;
int min_slice_size;
int default_slice_size;
int max_slice_size;
unsigned int rcvbuf;
int rexmit_hello_interval; /* retransmission interval between hello's.
* If 0, hello message won't be retransmitted
*/
int autostart; /* autostart after that many retransmits */
int rexmit_hello_interval; /* retransmission interval between hello's.
* If 0, hello message won't be retransmitted
*/
int autostart; /* autostart after that many retransmits */
int requestedBufSize; /* requested receiver buffer */
int requestedBufSize; /* requested receiver buffer */
/* sender-specific parameters */
int min_receivers;
int max_receivers_wait;
int min_receivers_wait;
/* sender-specific parameters */
int min_receivers;
int max_receivers_wait;
int min_receivers_wait;
int retriesUntilDrop;
int retriesUntilDrop;
/* receiver-specif parameters */
int exitWait; /* How many milliseconds to wait on program exit */
/* receiver-specif parameters */
int exitWait; /* How many milliseconds to wait on program exit */
int startTimeout; /* Timeout at start */
int startTimeout; /* Timeout at start */
/* FEC config */
/* FEC config */
#ifdef BB_FEATURE_UDPCAST_FEC
int fec_redundancy; /* how much fec blocks are added per group */
int fec_stripesize; /* size of FEC group */
int fec_stripes; /* number of FEC stripes per slice */
int fec_redundancy; /* how much fec blocks are added per group */
int fec_stripesize; /* size of FEC group */
int fec_stripes; /* number of FEC stripes per slice */
#endif
int rehelloOffset; /* how far before end will rehello packet will
be retransmitted */
int rehelloOffset; /* how far before end will rehello packet will
be retransmitted */
};
struct stat_config
{
FILE* log; /* Log file for statistics */
long bwPeriod; /* How often are bandwidth estimations logged? */
FILE* log; /* Log file for statistics */
long bwPeriod; /* How often are bandwidth estimations logged? */
int statPeriod;
int printUncompressedPos;
int statPeriod;
int printUncompressedPos;
};
#define NR_CLIENT_SOCKS 4
struct client_config
{
int socks[NR_CLIENT_SOCKS];
struct sockaddr_in serverAddr;
int clientNumber;
int isStarted;
pthread_t thread;
int sender_is_newgen;
int socks[NR_CLIENT_SOCKS];
struct sockaddr_in serverAddr;
int clientNumber;
int isStarted;
pthread_t thread;
int sender_is_newgen;
};
void* rgInitGovernor(struct net_config* cfg, struct rateGovernor_t* gov);
@ -156,7 +154,7 @@ int udpc_shouldPrintUncompressedPos(int deflt, int fd, int pipe);
#define DEFLT_STAT_PERIOD 500000
#ifndef DEBUG
# define DEBUG 0
#define DEBUG 0
#endif
#endif

View File

@ -23,12 +23,11 @@
#define MALLOC(type) ((type*)calloc(1, sizeof(type)))
/* bitmap manipulation */
#define BITS_PER_ITEM(map) (sizeof(map[0])*8)
#define MASK(pos,map) (1 << ((pos) % (BITS_PER_ITEM(map))))
#define POS(pos,map) ((pos) / BITS_PER_ITEM(map))
#define SET_BIT(x, map) (map[POS(x,map)] |= MASK(x,map))
#define CLR_BIT(x, map) (map[POS(x,map)] &= ~MASK(x,map))
#define BIT_ISSET(x, map) (map[POS(x,map)] & MASK(x,map))
#define BITS_PER_ITEM(map) (sizeof(map[0]) * 8)
#define MASK(pos, map) (1 << ((pos) % (BITS_PER_ITEM(map))))
#define POS(pos, map) ((pos) / BITS_PER_ITEM(map))
#define SET_BIT(x, map) (map[POS(x, map)] |= MASK(x, map))
#define CLR_BIT(x, map) (map[POS(x, map)] &= ~MASK(x, map))
#define BIT_ISSET(x, map) (map[POS(x, map)] & MASK(x, map))
#endif