4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
33 #include "isns_server.h"
34 #include "isns_msgq.h"
35 #include "isns_cache.h"
45 q
= (msg_queue_t
*)calloc(1, sizeof (msg_queue_t
));
48 if (sema_init(&q
->q_sema
, 0, USYNC_THREAD
, NULL
) ||
49 pthread_mutex_init(&q
->q_mutex
, NULL
)) {
67 msg
= (msg_text_t
*)calloc(1, sizeof (msg_text_t
));
76 (void) pthread_mutex_lock(&q
->q_mutex
);
78 if (q
->q_head
== NULL
) {
84 q
->q_tail
->next
= msg
;
85 msg
->prev
= q
->q_tail
;
89 (void) pthread_mutex_unlock(&q
->q_mutex
);
91 (void) sema_post(&q
->q_sema
);
103 while (sema_wait(&q
->q_sema
)) {
107 (void) pthread_mutex_lock(&q
->q_mutex
);
111 q
->q_head
= msg
->next
;
112 if (q
->q_head
== NULL
) {
116 (void) pthread_mutex_unlock(&q
->q_mutex
);