Module Name: src Committed By: riz Date: Sun May 27 22:03:16 UTC 2012
Modified Files: src/sbin/iscsid: iscsid_globals.h iscsid_main.c Log Message: Implement the remaining bits of unthreaded operation. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/iscsid/iscsid_globals.h \ src/sbin/iscsid/iscsid_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/iscsid/iscsid_globals.h diff -u src/sbin/iscsid/iscsid_globals.h:1.5 src/sbin/iscsid/iscsid_globals.h:1.6 --- src/sbin/iscsid/iscsid_globals.h:1.5 Sun May 27 17:27:33 2012 +++ src/sbin/iscsid/iscsid_globals.h Sun May 27 22:03:16 2012 @@ -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. @@ -399,13 +399,8 @@ int debug_level; /* How much info to #define LOCK_SESSIONS verify_sessions() #define UNLOCK_SESSIONS #endif -#ifdef ISCSI_NOTHREAD -#define LOCK_SESSIONS event_handler(NULL) -#define UNLOCK_SESSIONS do {} while(0) -#else -#define LOCK_SESSIONS pthread_mutex_lock(&sesslist_lock) -#define UNLOCK_SESSIONS pthread_mutex_unlock(&sesslist_lock) -#endif +#define LOCK_SESSIONS if (nothreads) event_handler(NULL); else pthread_mutex_lock(&sesslist_lock) +#define UNLOCK_SESSIONS if (!nothreads) pthread_mutex_unlock(&sesslist_lock) /* Check whether ID is present */ Index: src/sbin/iscsid/iscsid_main.c diff -u src/sbin/iscsid/iscsid_main.c:1.5 src/sbin/iscsid/iscsid_main.c:1.6 --- src/sbin/iscsid/iscsid_main.c:1.5 Sun May 27 20:05:04 2012 +++ src/sbin/iscsid/iscsid_main.c Sun May 27 22:03:16 2012 @@ -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. @@ -477,15 +477,14 @@ process_message(iscsid_request_t *req, i void exit_daemon(void) { - if (nothreads) { - LOCK_SESSIONS; - } + LOCK_SESSIONS; deregister_event_handler(); #ifndef ISCSI_MINIMAL dereg_all_isns_servers(); #endif + close(client_sock); printf("iSCSI Daemon Exits\n"); exit(0); } @@ -559,9 +558,13 @@ main(int argc, char **argv) len = sizeof(iscsid_request_t); if (nothreads) { - ret = recvfrom(client_sock, req, len, MSG_PEEK | - MSG_WAITALL, (struct sockaddr *)(void *)&from, - &fromlen); + do { + ret = recvfrom(client_sock, req, len, MSG_PEEK | + MSG_WAITALL, (struct sockaddr *)(void *)&from, + &fromlen); + if (ret == -1) + event_handler(NULL); + } while (ret == -1 && errno == EAGAIN); } else { do { ret = recvfrom(client_sock, req, len, MSG_PEEK |