Skip to content

Commit dda1ab4

Browse files
committed
oob/usock: error if the unix socket path is too long
That typically occurs on OSX where $TMPDIR can be long, a user-friendly error message will is displayed if mca_oob_verbose >= 2, and Open MPI will fall back to oob/tcp master does things differently (and better), so this is a one-off commit for the v2 branch
1 parent ee139f5 commit dda1ab4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

orte/mca/oob/usock/oob_usock_component.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void connection_event_handler(int incoming_sd, short flags, void* cbdata)
205205
static int component_startup(void)
206206
{
207207
int rc=ORTE_SUCCESS;
208+
char *usock_path;
208209

209210
opal_output_verbose(2, orte_oob_base_framework.framework_output,
210211
"%s USOCK STARTUP",
@@ -213,11 +214,29 @@ static int component_startup(void)
213214
/* setup the path to the daemon rendezvous point */
214215
memset(&mca_oob_usock_component.address, 0, sizeof(struct sockaddr_un));
215216
mca_oob_usock_component.address.sun_family = AF_UNIX;
216-
snprintf(mca_oob_usock_component.address.sun_path,
217-
sizeof(mca_oob_usock_component.address.sun_path)-1,
217+
asprintf(&usock_path,
218218
"%s/%s/%s/0/%s", orte_process_info.tmpdir_base,
219219
orte_process_info.top_session_dir,
220220
ORTE_JOB_FAMILY_PRINT(ORTE_PROC_MY_NAME->jobid), "usock");
221+
if (NULL == usock_path) {
222+
rc = ORTE_ERR_OUT_OF_RESOURCE;
223+
ORTE_ERROR_LOG(rc);
224+
}
225+
226+
/* If usock_path is too long, just fail, so the caller
227+
* may provide the user with a proper help... *Cough*, *Cough* OSX... */
228+
if ((strlen(usock_path) + 1) > sizeof(mca_oob_usock_component.address.sun_path)) {
229+
opal_output_verbose(2, orte_oob_base_framework.framework_output,
230+
"usock path too long: strlen(%s) > %d\nyou might want to check you $TMPDIR or $TMP environment variable",
231+
usock_path, (int)sizeof(mca_oob_usock_component.address.sun_path)-1);
232+
free(usock_path);
233+
return ORTE_ERR_NOT_SUPPORTED;
234+
235+
}
236+
237+
strncpy(mca_oob_usock_component.address.sun_path, usock_path, sizeof(mca_oob_usock_component.address.sun_path)-1);
238+
free(usock_path);
239+
221240
opal_output_verbose(2, orte_oob_base_framework.framework_output,
222241
"SUNPATH: %s", mca_oob_usock_component.address.sun_path);
223242

0 commit comments

Comments
 (0)