WIP: Fix the Proxy-State issue.
[libradsec.git] / udp.c
diff --git a/udp.c b/udp.c
index 2724a1d..ff7ad77 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2006-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,6 +20,7 @@
 #include <arpa/inet.h>
 #include <regex.h>
 #include <pthread.h>
+#include <assert.h>
 #include "radsecproxy.h"
 #include "hostport.h"
 
@@ -85,7 +82,9 @@ static char **getlistenerargs() {
 
 void udpsetsrcres() {
     if (!srcres)
-       srcres = resolvepassiveaddrinfo(protoopts ? protoopts->sourcearg : NULL, NULL, protodefs.socktype);
+       srcres =
+            resolvepassiveaddrinfo(protoopts ? protoopts->sourcearg : NULL,
+                                   AF_UNSPEC, NULL, protodefs.socktype);
 }
 
 void removeudpclientfromreplyq(struct client *c) {
@@ -317,6 +316,7 @@ void addclientudp(struct client *client) {
 }
 
 void addserverextraudp(struct clsrvconf *conf) {
+    assert(list_first(conf->hostports) != NULL);
     switch (((struct hostportres *)list_first(conf->hostports)->data)->addrinfo->ai_family) {
     case AF_INET:
        if (client4_sock < 0) {
@@ -348,15 +348,15 @@ void initextraudp() {
     }
 
     if (client4_sock >= 0)
-       if (pthread_create(&cl4th, NULL, udpclientrd, (void *)&client4_sock))
+       if (pthread_create(&cl4th, &pthread_attr, udpclientrd, (void *)&client4_sock))
            debugx(1, DBG_ERR, "pthread_create failed");
     if (client6_sock >= 0)
-       if (pthread_create(&cl6th, NULL, udpclientrd, (void *)&client6_sock))
+       if (pthread_create(&cl6th, &pthread_attr, udpclientrd, (void *)&client6_sock))
            debugx(1, DBG_ERR, "pthread_create failed");
 
     if (find_clconf_type(handle, NULL)) {
        server_replyq = newqueue();
-       if (pthread_create(&srvth, NULL, udpserverwr, (void *)server_replyq))
+       if (pthread_create(&srvth, &pthread_attr, udpserverwr, (void *)server_replyq))
            debugx(1, DBG_ERR, "pthread_create failed");
     }
 }