/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <poll.h>
#ifdef DEBUG
#include <time.h>
#endif
#include "isns_server.h"
#include "isns_cache.h"
#include "isns_pdu.h"
#include "isns_msgq.h"
#include "isns_func.h"
#include "isns_log.h"
#include "isns_provider.h"
/* external functions */
#ifdef DEBUG
extern void dump_pdu1(isns_pdu_t *);
extern int verbose_tc;
#endif
extern boolean_t time_to_exit;
void *
void *arg
)
{
int status = 0;
combined_pdu = NULL;
while (status == 0 &&
time_to_exit == B_FALSE &&
if (ISNS_MSG_RECEIVED_ENABLED()) {
} else {
}
}
goto conn_done;
}
combined_pdu = pdu;
} else {
if (combined_pdu == NULL ||
/* expect the first pdu, the same tranx id */
/* and the next sequence id */
goto conn_done;
}
pdu->payload_len);
if (new_combined_pdu == NULL) {
goto conn_done;
}
(void) memcpy((void *)new_combined_pdu,
(void *)combined_pdu,
(void) memcpy((void *)payload_ptr,
pdu->payload_len);
}
#ifdef DEBUG
time_t t;
clock_t c;
if (verbose_tc != 0) {
c = clock();
}
#endif
if (packet_split_verify(conn) == 0) {
}
switch (status) {
case -1:
/* error */
break;
case 0:
"Response status: %d.", status);
if (ISNS_MSG_RESPONDED_ENABLED()) {
(struct sockaddr_in *)ssp;
} else {
}
}
break;
default:
/* no need to send response message */
status = 0;
break;
}
#ifdef DEBUG
if (verbose_tc != 0) {
c = clock() - c;
printf("time %d clock %.4lf -msg response\n",
t, c / (double)CLOCKS_PER_SEC);
}
#endif
combined_pdu = NULL;
}
}
}
if (combined_pdu != NULL) {
}
/* decrease the thread ref count */
return (NULL);
}
/* the iSNS server port watcher */
void *
/* LINTED E_FUNC_ARG_UNUSED */
void *arg
)
{
int s, f;
int poll_ret;
/* IPv4 */
sizeof (opt));
"binding on server port failed: %%m");
goto watch_failed;
}
"successful binding on server port.");
} else {
"cannot create socket: %%m.");
goto watch_failed;
}
if (listen(s, 5) < 0) {
"listening on server port failed: %%m.");
goto watch_failed;
}
/* waiting for connections */
for (;;) {
if (time_to_exit) {
return (NULL);
}
if (poll_ret <= 0) {
continue;
}
/* allocate a connection argument */
"malloc() failed.");
goto watch_failed;
}
if (f < 0) {
"accepting connection failed: %%m.");
goto watch_failed;
}
} else {
}
"connection from %s:%d.", buf,
if (ISNS_CONNECTION_ACCEPTED_ENABLED()) {
}
/* create an isns connection */
isns_connection, (void *)conn) != 0) {
(void) close(f);
"pthread_create() failed.");
} else {
/* increase the thread ref count */
}
}
return (NULL);
}
)
{
(void) pthread_mutex_lock(&xid_mtx);
(void) pthread_mutex_unlock(&xid_mtx);
return (tmp);
}