FreeBSD/sys/security/audit/audit_pipe.c
/*
 * Append individual record to a queue -- allocate queue-local buffer, and
 * add to the queue.  If the queue is full or we can't allocate memory, drop
 * the newest record.
 */
Append individual record to a queue -- allocate queue-local buffer, and
add to the queue.  If the queue is full or we can't allocate memory, drop
the newest record.
Append individual record to a queue -- allocate queue - local buffer and add to the queue . If the queue is full or we can ' t allocate memory drop the newest record .
static void
audit_pipe_append(struct audit_pipe *ap, void *record, u_int record_len)
{
	struct audit_pipe_entry *ape;
	AUDIT_PIPE_LOCK_ASSERT(ap);
	if (ap->ap_qlen >= ap->ap_qlimit) {
		ap->ap_drops++;
		audit_pipe_drops++;
		return;
	}
	ape = malloc(sizeof(*ape), M_AUDIT_PIPE_ENTRY, M_NOWAIT | M_ZERO);
	if (ape == NULL) {
		ap->ap_drops++;
		audit_pipe_drops++;
		return;
	}
	ape->ape_record = malloc(record_len, M_AUDIT_PIPE_ENTRY, M_NOWAIT);
	if (ape->ape_record == NULL) {
		free(ape, M_AUDIT_PIPE_ENTRY);
		ap->ap_drops++;
		audit_pipe_drops++;
		return;
	}
	bcopy(record, ape->ape_record, record_len);
	ape->ape_record_len = record_len;
	TAILQ_INSERT_TAIL(&ap->ap_queue, ape, ape_queue);
	ap->ap_inserts++;
	ap->ap_qlen++;
	ap->ap_qbyteslen += ape->ape_record_len;
	selwakeuppri(&ap->ap_selinfo, PSOCK);
	KNOTE_LOCKED(&ap->ap_selinfo.si_note, 0);
	if (ap->ap_flags & AUDIT_PIPE_ASYNC)
		pgsigio(&ap->ap_sigio, SIGIO, 0);
	cv_broadcast(&ap->ap_cv);
}
static void audit_pipe_append ( struct audit_pipe * ap , void * record , u_int record_len ) { struct audit_pipe_entry * ape ; AUDIT_PIPE_LOCK_ASSERT ( ap ) ; if ( ap -> ap_qlen >= ap -> ap_qlimit ) { ap -> ap_drops ++ ; audit_pipe_drops ++ ; return ; } ape = malloc ( sizeof ( * ape ) , M_AUDIT_PIPE_ENTRY , M_NOWAIT | M_ZERO ) ; if ( ape == NULL ) { ap -> ap_drops ++ ; audit_pipe_drops ++ ; return ; } ape -> ape_record = malloc ( record_len , M_AUDIT_PIPE_ENTRY , M_NOWAIT ) ; if ( ape -> ape_record == NULL ) { free ( ape , M_AUDIT_PIPE_ENTRY ) ; ap -> ap_drops ++ ; audit_pipe_drops ++ ; return ; } bcopy ( record , ape -> ape_record , record_len ) ; ape -> ape_record_len = record_len ; TAILQ_INSERT_TAIL ( & ap -> ap_queue , ape , ape_queue ) ; ap -> ap_inserts ++ ; ap -> ap_qlen ++ ; ap -> ap_qbyteslen += ape -> ape_record_len ; selwakeuppri ( & ap -> ap_selinfo , PSOCK ) ; KNOTE_LOCKED ( & ap -> ap_selinfo . si_note , 0 ) ; if ( ap -> ap_flags & AUDIT_PIPE_ASYNC ) pgsigio ( & ap -> ap_sigio , SIGIO , 0 ) ; cv_broadcast ( & ap -> ap_cv ) ; }
Append individual record to a queue -- allocate queue-local buffer, and
 add to the queue.
Append individual record to a queue -- allocate queue - local buffer and add to the queue .