[Open-FCoE] [PATCH 01/15] fcoe-utils: Change sa_select_loop to have a return value

Robert Love robert.w.love at intel.com
Thu Jul 16 17:00:26 UTC 2009


It is desired to move the debug macros out of fcoemon_debug.h
and into fcoemon.h. Since fcoemon_utils is a utility library
that could be used for other applications it can provide a
logging facility, but the specific macros for each application
should be in each applications header files.

This means that any of the fcoemon_utils.[ch] helper functions
should not do any logging themselves, becuase they are part of
the utility library and not the application.

sa_select_loop() is the only example of a helper function that
does logging too. It logs when select() fails.

This patch has sa_select_loop() return 1 when it fails so the
caller can log the error message and exit. It will return 0
on success.

Signed-off-by: Robert Love <robert.w.love at intel.com>
---

 fcoemon.c       |    6 +++++-
 fcoemon_utils.c |    6 +++---
 fcoemon_utils.h |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fcoemon.c b/fcoemon.c
index d42c39b..d0b493a 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -1925,7 +1925,11 @@ int main(int argc, char **argv)
 	fcm_link_init();	/* NETLINK_ROUTE protocol */
 	fcm_dcbd_init();
 
-	sa_select_loop();
+	rc = sa_select_loop();
+	if (rc < 0) {
+		SA_LOG_ERR(rc, "select error\n");
+		exit(EXIT_FAILURE);
+	}
 	fcm_dcbd_shutdown();
 	return 0;
 }
diff --git a/fcoemon_utils.c b/fcoemon_utils.c
index e98d259..ab36240 100644
--- a/fcoemon_utils.c
+++ b/fcoemon_utils.c
@@ -498,8 +498,7 @@ sa_select_call_deferred_funcs(void)
 	}
 }
 
-void
-sa_select_loop(void)
+int sa_select_loop(void)
 {
 	struct sa_sel_state *ss = &sa_sel_state;
 	struct sa_sel_fd *fp;
@@ -533,7 +532,7 @@ sa_select_loop(void)
 		if (rv == -1) {
 			if (errno == EINTR)
 				continue;
-			SA_LOG_ERR_EXIT(errno, "select error");
+			return errno;
 		}
 
 		fp = ss->ts_fd;
@@ -568,6 +567,7 @@ sa_select_loop(void)
 		if (ss->ts_defer_list.tqh_first != NULL)
 			sa_select_call_deferred_funcs();
 	}
+	return 0;
 }
 
 void
diff --git a/fcoemon_utils.h b/fcoemon_utils.h
index e8c5de9..f154c77 100644
--- a/fcoemon_utils.h
+++ b/fcoemon_utils.h
@@ -256,7 +256,7 @@ u_int sa_timer_get_secs(void);
 /*
  * Enter the polling loop which never exits.
  */
-void sa_select_loop(void);
+int sa_select_loop(void);
 
 /*
  * Set callback for every time through the select loop.




More information about the devel mailing list