/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <pthread.h>
#include <memory.h>
#include "queue.h"
#include <stdio.h>
#include <assert.h>
#include "plugin.h"
#define DEBUG 0
#if DEBUG
extern FILE *__auditd_debug_file_open();
#else
#define DPRINT(x)
#endif
void
{
q->auq_count = 0;
#if DEBUG
}
#endif
}
/*
* enqueue() caller creates queue entry
*/
void
{
(void) pthread_mutex_lock(&q->auq_lock);
q->auq_count));
q->auq_head = p;
else {
}
q->auq_tail = p;
q->auq_count++;
"count=%d, pnext=%p\n", (void *)q, (void *)p, (void *)q->auq_head,
(void *)((audit_link_t *)p)->aln_next));
(void) pthread_mutex_unlock(&q->auq_lock);
}
/*
* audit_dequeue() returns entry; caller is responsible for free
*/
int
{
(void) pthread_mutex_lock(&q->auq_lock);
"tail=%p, count=%d\n", (void *)q, (void *)*p,
(void) pthread_mutex_unlock(&q->auq_lock);
return (1);
}
q->auq_count--;
/* if *p is the last, next is NULL */
"count=%d, pnext=%p\n", (void *)q, (void *)*p, (void *)q->auq_head,
(void *)((audit_link_t *)*p)->aln_next));
(void) pthread_mutex_unlock(&q->auq_lock);
return (0);
}
/*
* increment ref count
*/
void
{
(void) pthread_mutex_lock(l);
p->abq_ref_count++;
(void *)p, p->abq_ref_count));
(void) pthread_mutex_unlock(l);
}
/*
* decrement reference count; if it reaches zero,
* return a pointer to it. Otherwise, return NULL.
*/
{
(void) pthread_mutex_lock(l);
(void *)p, p->abq_ref_count));
if (--(p->abq_ref_count) > 0) {
(void) pthread_mutex_unlock(l);
return (NULL);
}
(void) pthread_mutex_unlock(l);
return (p);
}
int
{
int size;
(void) pthread_mutex_lock(&q->auq_lock);
(void) pthread_mutex_unlock(&q->auq_lock);
return (size);
}
void
{
(void) pthread_mutex_destroy(&q->auq_lock);
}