Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/iscsid Implement the remaining bits of unthreaded opera...



details:   https://anonhg.NetBSD.org/src/rev/ce644b533c6c
branches:  trunk
changeset: 779431:ce644b533c6c
user:      riz <riz%NetBSD.org@localhost>
date:      Sun May 27 22:03:16 2012 +0000

description:
Implement the remaining bits of unthreaded operation.

diffstat:

 sbin/iscsid/iscsid_globals.h |  11 +++--------
 sbin/iscsid/iscsid_main.c    |  17 ++++++++++-------
 2 files changed, 13 insertions(+), 15 deletions(-)

diffs (69 lines):

diff -r 17c1ddb125cf -r ce644b533c6c sbin/iscsid/iscsid_globals.h
--- a/sbin/iscsid/iscsid_globals.h      Sun May 27 20:11:58 2012 +0000
+++ b/sbin/iscsid/iscsid_globals.h      Sun May 27 22:03:16 2012 +0000
@@ -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 @@
 #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 */
 
diff -r 17c1ddb125cf -r ce644b533c6c sbin/iscsid/iscsid_main.c
--- a/sbin/iscsid/iscsid_main.c Sun May 27 20:11:58 2012 +0000
+++ b/sbin/iscsid/iscsid_main.c Sun May 27 22:03:16 2012 +0000
@@ -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 @@
 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 @@
                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 |



Home | Main Index | Thread Index | Old Index