Implement the remaining bits of unthreaded operation.

This commit is contained in:
riz 2012-05-27 22:03:16 +00:00
parent 763e2736f6
commit 1b247119f1
2 changed files with 13 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: iscsid_globals.h,v 1.5 2012/05/27 17:27:33 riz Exp $ */ /* $NetBSD: iscsid_globals.h,v 1.6 2012/05/27 22:03:16 riz Exp $ */
/*- /*-
* Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@ -399,13 +399,8 @@ int debug_level; /* How much info to display */
#define LOCK_SESSIONS verify_sessions() #define LOCK_SESSIONS verify_sessions()
#define UNLOCK_SESSIONS #define UNLOCK_SESSIONS
#endif #endif
#ifdef ISCSI_NOTHREAD #define LOCK_SESSIONS if (nothreads) event_handler(NULL); else pthread_mutex_lock(&sesslist_lock)
#define LOCK_SESSIONS event_handler(NULL) #define UNLOCK_SESSIONS if (!nothreads) pthread_mutex_unlock(&sesslist_lock)
#define UNLOCK_SESSIONS do {} while(0)
#else
#define LOCK_SESSIONS pthread_mutex_lock(&sesslist_lock)
#define UNLOCK_SESSIONS pthread_mutex_unlock(&sesslist_lock)
#endif
/* Check whether ID is present */ /* Check whether ID is present */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iscsid_main.c,v 1.5 2012/05/27 20:05:04 christos Exp $ */ /* $NetBSD: iscsid_main.c,v 1.6 2012/05/27 22:03:16 riz Exp $ */
/*- /*-
* Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@ -477,15 +477,14 @@ process_message(iscsid_request_t *req, iscsid_response_t **prsp, int *prsp_temp)
void void
exit_daemon(void) exit_daemon(void)
{ {
if (nothreads) {
LOCK_SESSIONS; LOCK_SESSIONS;
}
deregister_event_handler(); deregister_event_handler();
#ifndef ISCSI_MINIMAL #ifndef ISCSI_MINIMAL
dereg_all_isns_servers(); dereg_all_isns_servers();
#endif #endif
close(client_sock);
printf("iSCSI Daemon Exits\n"); printf("iSCSI Daemon Exits\n");
exit(0); exit(0);
} }
@ -559,9 +558,13 @@ main(int argc, char **argv)
len = sizeof(iscsid_request_t); len = sizeof(iscsid_request_t);
if (nothreads) { if (nothreads) {
do {
ret = recvfrom(client_sock, req, len, MSG_PEEK | ret = recvfrom(client_sock, req, len, MSG_PEEK |
MSG_WAITALL, (struct sockaddr *)(void *)&from, MSG_WAITALL, (struct sockaddr *)(void *)&from,
&fromlen); &fromlen);
if (ret == -1)
event_handler(NULL);
} while (ret == -1 && errno == EAGAIN);
} else { } else {
do { do {
ret = recvfrom(client_sock, req, len, MSG_PEEK | ret = recvfrom(client_sock, req, len, MSG_PEEK |