projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #116 from C4K3/deprecate-autotools
[umurmur.git]
/
src
/
server.c
diff --git
a/src/server.c
b/src/server.c
index 9bb6ccb801e44294ca872145f99b5b30a56de4fc..9dc0c29b57969c59bfc0a5222f2d33e6dffef3b6 100644
(file)
--- a/
src/server.c
+++ b/
src/server.c
@@
-44,9
+44,11
@@
#include "client.h"
#include "conf.h"
#include "log.h"
#include "client.h"
#include "conf.h"
#include "log.h"
+#include "memory.h"
#include "timer.h"
#include "version.h"
#include "util.h"
#include "timer.h"
#include "version.h"
#include "util.h"
+#include "sharedmemory.h"
/* globals */
bool_t shutdown_server;
/* globals */
bool_t shutdown_server;
@@
-66,11
+68,11
@@
void checkIPversions()
int testsocket = -1;
testsocket = socket(PF_INET, SOCK_STREAM, 0);
int testsocket = -1;
testsocket = socket(PF_INET, SOCK_STREAM, 0);
- hasv4 = (errno == EAFNOSUPPORT) ? false : true;
+ hasv4 = (errno == EAFNOSUPPORT
|| errno == EPROTONOSUPPORT
) ? false : true;
if (!(testsocket < 0)) close(testsocket);
testsocket = socket(PF_INET6, SOCK_STREAM, 0);
if (!(testsocket < 0)) close(testsocket);
testsocket = socket(PF_INET6, SOCK_STREAM, 0);
- hasv6 = (errno == EAFNOSUPPORT) ? false : true;
+ hasv6 = (errno == EAFNOSUPPORT
|| errno == EPROTONOSUPPORT
) ? false : true;
if (!(testsocket < 0)) close(testsocket);
if(!hasv4)
if (!(testsocket < 0)) close(testsocket);
if(!hasv4)
@@
-84,7
+86,6
@@
void checkIPversions()
Log_info("IPv6 is not supported by this system");
nofServerSocks -= 2;
}
Log_info("IPv6 is not supported by this system");
nofServerSocks -= 2;
}
-
if(nofServerSocks == 0)
{
Log_fatal("Neither IPv4 nor IPv6 are supported by this system");
if(nofServerSocks == 0)
{
Log_fatal("Neither IPv4 nor IPv6 are supported by this system");
@@
-94,11
+95,11
@@
void checkIPversions()
/* Initialize the address structures for IPv4 and IPv6 */
struct sockaddr_storage** Server_setupAddressesAndPorts()
{
/* Initialize the address structures for IPv4 and IPv6 */
struct sockaddr_storage** Server_setupAddressesAndPorts()
{
- struct sockaddr_storage** addresses =
c
alloc(2, sizeof(void*));
+ struct sockaddr_storage** addresses =
Memory_safeC
alloc(2, sizeof(void*));
- struct sockaddr_storage* v4address =
c
alloc(1, sizeof(struct sockaddr_storage));
+ struct sockaddr_storage* v4address =
Memory_safeC
alloc(1, sizeof(struct sockaddr_storage));
v4address->ss_family = AF_INET;
v4address->ss_family = AF_INET;
- struct sockaddr_storage* v6address =
c
alloc(1, sizeof(struct sockaddr_storage));
+ struct sockaddr_storage* v6address =
Memory_safeC
alloc(1, sizeof(struct sockaddr_storage));
v6address->ss_family = AF_INET6;
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
v6address->ss_family = AF_INET6;
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
@@
-208,7
+209,7
@@
void Server_runLoop(struct pollfd* pollfds)
void Server_setupTCPSockets(struct sockaddr_storage* addresses[2], struct pollfd* pollfds)
{
void Server_setupTCPSockets(struct sockaddr_storage* addresses[2], struct pollfd* pollfds)
{
-
uint8_
t yes = 1;
+
in
t yes = 1;
int sockets[2];
if (hasv4) {
int sockets[2];
if (hasv4) {
@@
-261,8
+262,7
@@
void Server_setupUDPSockets(struct sockaddr_storage* addresses[2], struct pollfd
int val = 0;
int sockets[2] = {-1, -1};
int val = 0;
int sockets[2] = {-1, -1};
- if((udpsocks = calloc(nofServerSocks / 2, sizeof(int))) == NULL)
- Log_fatal("Out of memory (%s:%s)", __FILE__, __LINE__);
+ udpsocks = Memory_safeCalloc(nofServerSocks / 2, sizeof(int));
if (hasv4) {
sockets[0] = socket(PF_INET, SOCK_DGRAM, 0);
if (hasv4) {
sockets[0] = socket(PF_INET, SOCK_DGRAM, 0);
@@
-315,8
+315,7
@@
void Server_run()
checkIPversions();
/* max clients + server sokets + client connecting that will be disconnected */
checkIPversions();
/* 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");
+ pollfds = Memory_safeCalloc((getIntConf(MAX_CLIENTS) + nofServerSocks + 1) , sizeof(struct pollfd));
/* Figure out bind address and port */
struct sockaddr_storage** addresses = Server_setupAddressesAndPorts();
/* Figure out bind address and port */
struct sockaddr_storage** addresses = Server_setupAddressesAndPorts();