talloc_steal the packet after reading it
[freeradius.git] / src / main / listen.c
index 3b1ec30..339e1e6 100644 (file)
@@ -247,6 +247,7 @@ RADCLIENT *client_listener_find(rad_listen_t *listener,
                talloc_free(request);
                goto unknown;
        }
+       (void) talloc_steal(request, request->packet);
        request->reply = rad_alloc_reply(request, request->packet);
        if (!request->reply) {
                talloc_free(request);
@@ -429,7 +430,7 @@ static int dual_tcp_recv(rad_listen_t *listener)
         *      Allocate a packet for partial reads.
         */
        if (!sock->packet) {
-               sock->packet = rad_alloc(sock, 0);
+               sock->packet = rad_alloc(sock, false);
                if (!sock->packet) return 0;
 
                sock->packet->sockfd = listener->fd;
@@ -2501,12 +2502,8 @@ static int listen_bind(rad_listen_t *this)
 }
 
 
-static int listener_free(void *ctx)
+static int _listener_free(rad_listen_t *this)
 {
-       rad_listen_t *this;
-
-       this = talloc_get_type_abort(ctx, rad_listen_t);
-
        /*
         *      Other code may have eaten the FD.
         */
@@ -2571,7 +2568,7 @@ static rad_listen_t *listen_alloc(TALLOC_CTX *ctx, RAD_LISTEN_TYPE type)
        this->encode = master_listen[this->type].encode;
        this->decode = master_listen[this->type].decode;
 
-       talloc_set_destructor((void *) this, listener_free);
+       talloc_set_destructor(this, _listener_free);
 
        this->data = talloc_zero_array(this, uint8_t, master_listen[this->type].inst_size);