diff mbox

[1/7] ibacm: Delay opening address file until assigning addresses

Message ID CF9C39F99A89134C9CF9C4CCB68B8DDF25CC92EACF@orsmsx501.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hefty, Sean March 5, 2011, 12:05 a.m. UTC
None
diff mbox

Patch

diff --git a/src/acm.c b/src/acm.c
index 1f3c470..38f41d2 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -203,7 +203,6 @@  static SOCKET listen_socket;
 static struct acm_client client[FD_SETSIZE - 1];
 
 static FILE *flog;
-static FILE *faddr;
 static lock_t log_lock;
 PER_THREAD char log_data[ACM_MAX_ADDRESS];
 
@@ -2389,6 +2388,7 @@  err:
 
 static int acm_assign_ep_names(struct acm_ep *ep)
 {
+	FILE *faddr;
 	char *dev_name;
 	char s[120];
 	char dev[32], addr[32], pkey_str[8];
@@ -2401,7 +2401,11 @@  static int acm_assign_ep_names(struct acm_ep *ep)
 	acm_log(1, "device %s, port %d, pkey 0x%x\n",
 		dev_name, ep->port->port_num, ep->pkey);
 
-	rewind(faddr);
+	if (!(faddr = acm_open_addr_file())) {
+		acm_log(0, "ERROR - address file not found\n");
+		return -1;
+	}
+
 	while (fgets(s, sizeof s, faddr)) {
 		if (s[0] == '#')
 			continue;
@@ -2445,6 +2449,7 @@  static int acm_assign_ep_names(struct acm_ep *ep)
 			}
 		}
 	}
+	fclose(faddr);
 
 	return !index;
 }
@@ -2969,11 +2974,6 @@  int CDECL_FUNC main(int argc, char **argv)
 	DListInit(&timeout_list);
 	event_init(&timeout_event);
 
-	if (!(faddr = acm_open_addr_file())) {
-		acm_log(0, "ERROR - address file not found\n");
-		return -1;
-	}
-
 	umad_init();
 	ibdev = ibv_get_device_list(&dev_cnt);
 	if (!ibdev) {
@@ -2990,7 +2990,6 @@  int CDECL_FUNC main(int argc, char **argv)
 		acm_log(0, "ERROR - no active devices\n");
 		return -1;
 	}
-	fclose(faddr);
 
 	acm_log(1, "initiating multicast joins\n");
 	acm_join_groups();