Skip to content

Commit cfeeecd

Browse files
committed
Remove the tcp_local field from the TCP component.
Instead use the OPAL process name to get the name of the local process. Signed-off-by: George Bosilca <[email protected]>
1 parent dc7d2f5 commit cfeeecd

File tree

5 files changed

+11
-28
lines changed

5 files changed

+11
-28
lines changed

opal/mca/btl/tcp/btl_tcp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ int mca_btl_tcp_del_procs(struct mca_btl_base_module_t* btl,
156156
OPAL_THREAD_LOCK(&tcp_btl->tcp_endpoints_mutex);
157157
for( i = 0; i < nprocs; i++ ) {
158158
mca_btl_tcp_endpoint_t* tcp_endpoint = endpoints[i];
159-
if(tcp_endpoint->endpoint_proc != mca_btl_tcp_proc_local()) {
160-
opal_list_remove_item(&tcp_btl->tcp_endpoints, (opal_list_item_t*)tcp_endpoint);
161-
OBJ_RELEASE(tcp_endpoint);
162-
}
159+
opal_list_remove_item(&tcp_btl->tcp_endpoints, (opal_list_item_t*)tcp_endpoint);
160+
OBJ_RELEASE(tcp_endpoint);
163161
opal_progress_event_users_decrement();
164162
}
165163
OPAL_THREAD_UNLOCK(&tcp_btl->tcp_endpoints_mutex);

opal/mca/btl/tcp/btl_tcp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ struct mca_btl_tcp_component_t {
107107
uint32_t tcp_num_btls; /**< number of interfaces available to the TCP component */
108108
unsigned int tcp_num_links; /**< number of logical links per physical device */
109109
struct mca_btl_tcp_module_t **tcp_btls; /**< array of available BTL modules */
110-
struct mca_btl_tcp_proc_t* tcp_local; /**< local proc struct */
111110
int tcp_free_list_num; /**< initial size of free lists */
112111
int tcp_free_list_max; /**< maximum size of free lists */
113112
int tcp_free_list_inc; /**< number of elements to alloc when growing free lists */

opal/mca/btl/tcp/btl_tcp_endpoint.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ mca_btl_tcp_endpoint_dump(int level,
150150
opal_socklen_t obtlen;
151151
opal_socklen_t addrlen = sizeof(inaddr);
152152
mca_btl_tcp_frag_t* item;
153-
mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local();
154153

155154
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s: ", msg);
156155
if (used >= DEBUG_LENGTH) goto out;
@@ -280,7 +279,7 @@ mca_btl_tcp_endpoint_dump(int level,
280279
opal_output_verbose(level, opal_btl_base_framework.framework_output,
281280
"[%s:%d:%s][%s -> %s] %s",
282281
fname, lineno, funcname,
283-
(NULL != this_proc ? OPAL_NAME_PRINT(mca_btl_tcp_proc_local()->proc_opal->proc_name) : "unknown"),
282+
OPAL_NAME_PRINT(opal_proc_local_get()->proc_name),
284283
(NULL != btl_endpoint->endpoint_proc ? OPAL_NAME_PRINT(btl_endpoint->endpoint_proc->proc_opal->proc_name) : "unknown remote"),
285284
outmsg);
286285
}
@@ -408,8 +407,7 @@ mca_btl_tcp_endpoint_send_blocking(mca_btl_base_endpoint_t* btl_endpoint,
408407
static int mca_btl_tcp_endpoint_send_connect_ack(mca_btl_base_endpoint_t* btl_endpoint)
409408
{
410409
/* send process identifier to remote endpoint */
411-
mca_btl_tcp_proc_t* btl_proc = mca_btl_tcp_proc_local();
412-
opal_process_name_t guid = btl_proc->proc_opal->proc_name;
410+
opal_process_name_t guid = opal_proc_local_get()->proc_name;
413411

414412
OPAL_PROCESS_NAME_HTON(guid);
415413
if(mca_btl_tcp_endpoint_send_blocking(btl_endpoint, &guid, sizeof(guid)) !=
@@ -422,7 +420,6 @@ static int mca_btl_tcp_endpoint_send_connect_ack(mca_btl_base_endpoint_t* btl_en
422420
static void *mca_btl_tcp_endpoint_complete_accept(int fd, int flags, void *context)
423421
{
424422
mca_btl_base_endpoint_t* btl_endpoint = (mca_btl_base_endpoint_t*)context;
425-
mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local();
426423
struct timeval now = {0, 0};
427424
int cmpval;
428425

@@ -451,7 +448,7 @@ static void *mca_btl_tcp_endpoint_complete_accept(int fd, int flags, void *conte
451448
}
452449

453450
cmpval = opal_compare_proc(btl_endpoint->endpoint_proc->proc_opal->proc_name,
454-
this_proc->proc_opal->proc_name);
451+
opal_proc_local_get()->proc_name);
455452
if((btl_endpoint->endpoint_sd < 0) ||
456453
(btl_endpoint->endpoint_state != MCA_BTL_TCP_CONNECTED &&
457454
cmpval < 0)) {

opal/mca/btl/tcp/btl_tcp_proc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc)
163163
break;
164164
}
165165

166-
if(NULL == mca_btl_tcp_component.tcp_local && (proc == opal_proc_local_get())) {
167-
mca_btl_tcp_component.tcp_local = btl_proc;
168-
}
169-
170166
/* convert the OPAL addr_family field to OS constants,
171167
* so we can check for AF_INET (or AF_INET6) and don't have
172168
* to deal with byte ordering anymore.
@@ -745,8 +741,8 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t *name)
745741
mca_btl_base_endpoint_t *endpoint;
746742
opal_proc_t *opal_proc;
747743

748-
BTL_VERBOSE(("adding tcp proc for unknown peer {.jobid = 0x%x, .vpid = 0x%x}",
749-
name->jobid, name->vpid));
744+
BTL_VERBOSE(("adding tcp proc for unknown peer {%s}",
745+
OPAL_NAME_PRINT(*name)));
750746

751747
opal_proc = opal_proc_for_name (*name);
752748
if (NULL == opal_proc) {
@@ -761,6 +757,7 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t *name)
761757
if (NULL != endpoint && NULL == proc) {
762758
/* get the proc and continue on (could probably just break here) */
763759
proc = endpoint->endpoint_proc;
760+
break;
764761
}
765762
}
766763
}
@@ -808,6 +805,9 @@ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr
808805
return;
809806
}
810807
OPAL_THREAD_UNLOCK(&btl_proc->proc_lock);
808+
opal_output(0, "btl: tcp: Incoming connection from %s does not match known addresses for peer %s. Drop !\n",
809+
opal_net_get_hostname((struct sockaddr*)addr),
810+
OPAL_NAME_PRINT(btl_proc->proc_opal->proc_name));
811811
/* No further use of this socket. Close it */
812812
CLOSE_THE_SOCKET(sd);
813813
}

opal/mca/btl/tcp/btl_tcp_proc.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,5 @@ int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);
111111
void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t*, struct sockaddr*, int);
112112
bool mca_btl_tcp_proc_tosocks(mca_btl_tcp_addr_t*, struct sockaddr_storage*);
113113

114-
/**
115-
* Inlined function to return local TCP proc instance.
116-
*/
117-
118-
static inline mca_btl_tcp_proc_t* mca_btl_tcp_proc_local(void)
119-
{
120-
if(NULL == mca_btl_tcp_component.tcp_local)
121-
mca_btl_tcp_component.tcp_local = mca_btl_tcp_proc_create(opal_proc_local_get());
122-
return mca_btl_tcp_component.tcp_local;
123-
}
124-
125114
END_C_DECLS
126115
#endif

0 commit comments

Comments
 (0)