projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some optimizations
[umurmur.git]
/
src
/
server.c
diff --git
a/src/server.c
b/src/server.c
index 27244a2b95c2950a3624183dcfab61297e5d878b..704f650d880bdc7f57e934d1203fcde115eb2085 100644
(file)
--- a/
src/server.c
+++ b/
src/server.c
@@
-55,7
+55,7
@@
extern char *bindaddr6;
extern int bindport;
extern int bindport6;
int* udpsocks;
extern int bindport;
extern int bindport6;
int* udpsocks;
-bool hasv4 = true, hasv6 = true;
+bool
_t
hasv4 = true, hasv6 = true;
const int on = 1;
int nofServerSocks = 4;
const int on = 1;
int nofServerSocks = 4;
@@
-120,14
+120,8
@@
void Server_runLoop(struct pollfd* pollfds)
struct sockaddr_storage remote;
int i;
struct sockaddr_storage remote;
int i;
- if (nofServerSocks == 4) {
- pollfds[0].revents = 0;
- pollfds[1].revents = 0;
- pollfds[2].revents = 0;
- pollfds[3].revents = 0;
- } else {
- pollfds[0].revents = 0;
- pollfds[1].revents = 0;
+ for(i = 0; i < nofServerSocks; i++) {
+ pollfds[i].revents = 0;
}
clientcount = Client_getfds(&pollfds[nofServerSocks]);
}
clientcount = Client_getfds(&pollfds[nofServerSocks]);
@@
-275,13
+269,13
@@
void Server_run()
{
struct pollfd *pollfds;
{
struct pollfd *pollfds;
- /* max clients + listen sock + udp sock + client connecting that will be disconnected */
- if ((pollfds = calloc((getIntConf(MAX_CLIENTS) + 5) , sizeof(struct pollfd))) == NULL)
- Log_fatal("out of memory");
-
/* Figure out bind address and port */
struct sockaddr_storage** addresses = Server_setupAddressesAndPorts();
/* Figure out bind address and port */
struct sockaddr_storage** addresses = Server_setupAddressesAndPorts();
+ /* max clients + server sokets + client connecting that will be disconnected */
+ if ((pollfds = calloc((getIntConf(MAX_CLIENTS) + nofServerSocks + 1) , sizeof(struct pollfd))) == NULL)
+ Log_fatal("out of memory");
+
/* Prepare TCP sockets */
Server_setupTCPSockets(addresses, pollfds);
/* Prepare TCP sockets */
Server_setupTCPSockets(addresses, pollfds);