Return free memory more aggressively.
[radsecproxy.git] / tcp.c
diff --git a/tcp.c b/tcp.c
index c04309d..0ad574c 100644 (file)
--- a/tcp.c
+++ b/tcp.c
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2008-2009 Stig Venaas <venaas@uninett.no>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
+/* Copyright (c) 2007-2009, UNINETT AS
+ * Copyright (c) 2012, NORDUnet A/S */
+/* See LICENSE for licensing information. */
 
 #include <signal.h>
 #include <sys/socket.h>
@@ -24,9 +20,8 @@
 #include <arpa/inet.h>
 #include <regex.h>
 #include <pthread.h>
-#include "list.h"
-#include "hostport.h"
 #include "radsecproxy.h"
+#include "hostport.h"
 
 #ifdef RADPROT_TCP
 #include "debug.h"
@@ -79,7 +74,9 @@ static char **getlistenerargs() {
 
 void tcpsetsrcres() {
     if (!srcres)
-       srcres = resolvepassiveaddrinfo(protoopts ? protoopts->sourcearg : NULL, NULL, protodefs.socktype);
+       srcres =
+            resolvepassiveaddrinfo(protoopts ? protoopts->sourcearg : NULL,
+                                   AF_UNSPEC, NULL, protodefs.socktype);
 }
 
 int tcpconnect(struct server *server, struct timeval *when, int timeout, char *text) {
@@ -275,7 +272,7 @@ void tcpserverrd(struct client *client) {
 
     debug(DBG_DBG, "tcpserverrd: starting for %s", addr2string(client->addr));
 
-    if (pthread_create(&tcpserverwrth, NULL, tcpserverwr, (void *)client)) {
+    if (pthread_create(&tcpserverwrth, &pthread_attr, tcpserverwr, (void *)client)) {
        debug(DBG_ERR, "tcpserverrd: pthread_create failed");
        return;
     }
@@ -356,7 +353,7 @@ void *tcplistener(void *arg) {
            debug(DBG_WARN, "accept failed");
            continue;
        }
-       if (pthread_create(&tcpserverth, NULL, tcpservernew, (void *)&s)) {
+       if (pthread_create(&tcpserverth, &pthread_attr, tcpservernew, (void *)&s)) {
            debug(DBG_ERR, "tcplistener: pthread_create failed");
            shutdown(s, SHUT_RDWR);
            close(s);
@@ -372,3 +369,7 @@ const struct protodefs *tcpinit(uint8_t h) {
     return NULL;
 }
 #endif
+
+/* Local Variables: */
+/* c-file-style: "stroustrup" */
+/* End: */