-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/common/sock/poll/sock_misc.i
-: 0:Graph:sock.gcno
-: 0:Data:sock.gcda
-: 0:Runs:4381
-: 0:Programs:1376
-: 1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
-: 2:
-: 3:/*
-: 4: * (C) 2001 by Argonne National Laboratory.
-: 5: * See COPYRIGHT in top-level directory.
-: 6: */
-: 7:
-: 8:#if 0
-: 9:/* FIXME: Who uses this and why? */
-: 10:#undef FUNCNAME
-: 11:#define FUNCNAME MPIDU_Sock_hostname_to_host_description
-: 12:#undef FCNAME
-: 13:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 14:int MPIDU_Sock_hostname_to_host_description(char *hostname, char *host_description, int len)
-: 15:{
-: 16: int mpi_errno = MPI_SUCCESS;
-: 17: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
-: 18:
-: 19: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
-: 20:
-: 21: MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-: 22:
-: 23: if (MPIU_Strncpy(host_description, hostname, (size_t) len))
|
-: 24: /* --BEGIN ERROR HANDLING-- */
-: 25: {
-: 26: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
-: 27: "**sock|badhdmax", 0);
-: 28: }
-: 29: /* --END ERROR HANDLING-- */
-: 30: fn_exit:
-: 31: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
-: 32: return mpi_errno;
-: 33:}
-: 34:#endif
-: 35:
-: 36:/* This routine is called in mpid/ch3/util/sock/ch3u_connect_sock.c */
-: 37:/* FIXME: This routine is misnamed; it is really get_interface_name (in the
-: 38: case where there are several networks available to the calling process,
-: 39: this picks one but even in the current code can pick a different
-: 40: interface if a particular environment variable is set) .
-: 41:
-: 42: This routine is used in smpd so we should not change its name yet. */
-: 43:#undef FUNCNAME
-: 44:#define FUNCNAME MPIDU_Sock_get_host_description
-: 45:#undef FCNAME
-: 46:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 47:int MPIDU_Sock_get_host_description(int myRank,
-: 48: char * host_description, int len)
|
#####: 49:{
-: 50: char * env_hostname;
-: 51: int rc;
#####: 52: int mpi_errno = MPI_SUCCESS;
-: 53: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-: 54:
-: 55: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-: 56:
-: 57: MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
|
-: 58: /* --BEGIN ERROR HANDLING-- */
#####: 59: if (len < 0)
-: 60: {
#####: 61: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 62: FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
-: 63: "**sock|badhdmax", NULL);
#####: 64: goto fn_exit;
-: 65: }
-: 66: /* --END ERROR HANDLING-- */
-: 67:
-: 68: /* FIXME: Is this documented? How does it work if the process manager
-: 69: cannot give each process a different value for an environment
-: 70: name? What if a different interface is needed? */
-: 71: /* Use hostname supplied in environment variable, if it exists */
|
#####: 72: env_hostname = getenv("MPICH_INTERFACE_HOSTNAME");
-: 73:
#####: 74: if (!env_hostname) {
-: 75: /* See if there is a per-process name for the interfaces (e.g.,
-: 76: the process manager only delievers the same values for the
-: 77: environment to each process */
-: 78: char namebuf[1024];
#####: 79: MPIU_Snprintf( namebuf, sizeof(namebuf),
-: 80: "MPICH_INTERFACE_HOSTNAME_R_%d", myRank );
#####: 81: env_hostname = getenv( namebuf );
-: 82: }
-: 83:
#####: 84: if (env_hostname != NULL)
-: 85: {
#####: 86: rc = MPIU_Strncpy(host_description, env_hostname, (size_t) len);
|
-: 87: /* --BEGIN ERROR HANDLING-- */
#####: 88: if (rc != 0)
-: 89: {
#####: 90: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
-: 91: "**sock|badhdlen", NULL);
-: 92: }
-: 93: /* --END ERROR HANDLING-- */
-: 94: }
-: 95: else {
|
#####: 96: rc = gethostname(host_description, len);
|
-: 97: /* --BEGIN ERROR HANDLING-- */
#####: 98: if (rc == -1)
-: 99: {
#####: 100: if (errno == EINVAL)
-: 101: {
#####: 102: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
-: 103: "**sock|badhdlen", NULL);
-: 104: }
#####: 105: else if (errno == EFAULT)
-: 106: {
#####: 107: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
-: 108: "**sock|badhdbuf", NULL);
-: 109: }
-: 110: else
-: 111: {
#####: 112: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
-: 113: "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIU_Strerror(errno));
-: 114: }
-: 115: }
-: 116: /* --END ERROR HANDLING-- */
-: 117: }
-: 118:
|
#####: 119: fn_exit:
|
-: 120: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
|
#####: 121: return mpi_errno;
-: 122:}
-: 123:
-: 124:
-: 125:#undef FUNCNAME
-: 126:#define FUNCNAME MPIDU_Sock_native_to_sock
-: 127:#undef FCNAME
-: 128:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 129:int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIVE_FD fd, void *user_ptr,
-: 130: struct MPIDU_Sock ** sockp)
#####: 131:{
#####: 132: struct MPIDU_Sock * sock = NULL;
-: 133: struct pollfd * pollfd;
-: 134: struct pollinfo * pollinfo;
-: 135: int rc;
-: 136: long flags;
#####: 137: int mpi_errno = MPI_SUCCESS;
-: 138: MPIDI_STATE_DECL(MPID_STATE_SOCK_NATIVE_TO_SOCK);
-: 139:
-: 140: MPIDI_FUNC_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
-: 141:
-: 142: MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-: 143:
-: 144: /* allocate sock and poll structures */
#####: 145: mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
|
-: 146: /* --BEGIN ERROR HANDLING-- */
#####: 147: if (mpi_errno != MPI_SUCCESS)
-: 148: {
#####: 149: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
-: 150: "**sock|sockalloc", NULL);
#####: 151: goto fn_fail;
-: 152: }
-: 153: /* --END ERROR HANDLING-- */
-: 154:
|
#####: 155: pollfd = MPIDU_Socki_sock_get_pollfd(sock);
#####: 156: pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-: 157:
-: 158: /* set file descriptor to non-blocking */
#####: 159: flags = fcntl(fd, F_GETFL, 0);
|
-: 160: /* --BEGIN ERROR HANDLING-- */
#####: 161: if (flags == -1)
-: 162: {
#####: 163: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
-: 164: "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
#####: 165: goto fn_fail;
-: 166: }
-: 167: /* --END ERROR HANDLING-- */
|
#####: 168: rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
-: 169: /* --BEGIN ERROR HANDLING-- */
#####: 170: if (rc == -1)
-: 171: {
#####: 172: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
-: 173: "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
#####: 174: goto fn_fail;
-: 175: }
-: 176: /* --END ERROR HANDLING-- */
-: 177:
-: 178: /* initialize sock and poll structures */
|
#####: 179: pollfd->fd = -1;
#####: 180: pollfd->events = 0;
#####: 181: pollfd->revents = 0;
-: 182:
#####: 183: pollinfo->fd = fd;
#####: 184: pollinfo->user_ptr = user_ptr;
#####: 185: pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
#####: 186: pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
-: 187:
#####: 188: *sockp = sock;
-: 189:
#####: 190: fn_exit:
|
-: 191: MPIDI_FUNC_EXIT(MPID_STATE_SOCK_NATIVE_TO_SOCK);
|
#####: 192: return mpi_errno;
-: 193:
|
-: 194: /* --BEGIN ERROR HANDLING-- */
#####: 195: fn_fail:
#####: 196: if (sock != NULL)
-: 197: {
#####: 198: MPIDU_Socki_sock_free(sock);
-: 199: }
-: 200:
-: 201: goto fn_exit;
-: 202: /* --END ERROR HANDLING-- */
-: 203:}
-: 204:
-: 205:
-: 206:#undef FUNCNAME
-: 207:#define FUNCNAME MPIDU_Sock_set_user_ptr
-: 208:#undef FCNAME
-: 209:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 210:int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
|
#####: 211:{
#####: 212: int mpi_errno = MPI_SUCCESS;
-: 213: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
-: 214:
-: 215: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
-: 216:
-: 217: MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-: 218:
#####: 219: if (sock != MPIDU_SOCK_INVALID_SOCK &&
-: 220: sock->sock_set != MPIDU_SOCK_INVALID_SET)
-: 221: {
#####: 222: MPIDU_Socki_sock_get_pollinfo(sock)->user_ptr = user_ptr;
-: 223: }
|
-: 224: /* --BEGIN ERROR HANDLING-- */
-: 225: else
-: 226: {
#####: 227: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
-: 228: "**sock|badsock", NULL);
-: 229: }
-: 230: /* --END ERROR HANDLING-- */
-: 231:
-: 232:#ifdef USE_SOCK_VERIFY
-: 233: fn_exit:
-: 234:#endif
-: 235: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
|
#####: 236: return mpi_errno;
-: 237:}
-: 238:
-: 239:
-: 240:/* FIXME: What is this for? It appears to be used in debug printing and
-: 241: in smpd */
-: 242:#undef FUNCNAME
-: 243:#define FUNCNAME MPIDU_Sock_get_sock_id
-: 244:#undef FCNAME
-: 245:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 246:int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
#####: 247:{
-: 248: int id;
-: 249: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
-: 250:
-: 251: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
-: 252:
#####: 253: if (sock != MPIDU_SOCK_INVALID_SOCK)
-: 254: {
#####: 255: if (sock->sock_set != MPIDU_SOCK_INVALID_SET)
-: 256: {
#####: 257: id = MPIDU_Socki_sock_get_pollinfo(sock)->sock_id;
-: 258: }
-: 259: else
-: 260: {
#####: 261: id = -1;
-: 262: }
-: 263: }
-: 264: else
-: 265: {
#####: 266: id = -1;
-: 267: }
-: 268:
|
-: 269: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
|
#####: 270: return id;
-: 271:}
-: 272:
-: 273:#undef FUNCNAME
-: 274:#define FUNCNAME MPIDU_Sock_get_sock_set_id
-: 275:#undef FCNAME
-: 276:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 277:int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
#####: 278:{
-: 279: int id;
-: 280: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
-: 281:
-: 282: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
-: 283:
#####: 284: if (sock_set != MPIDU_SOCK_INVALID_SET)
-: 285: {
#####: 286: id = sock_set->id;
-: 287: }
-: 288: else
-: 289: {
#####: 290: id = -1;
-: 291: }
-: 292:
|
-: 293: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
|
#####: 294: return id;
-: 295:}
-: 296:
-: 297:/* FIXME: This function violates the internationalization design by
-: 298: using English language strings rather than the error translation mechanism.
-: 299: This unnecessarily breaks the goal of allowing internationalization.
-: 300: Read the design documentation and if there is a problem, raise it rather
-: 301: than ignoring it.
-: 302:*/
-: 303:/* FIXME: This appears to only be used in smpd */
-: 304:/* FIXME: It appears that this function was used instead of making use of the
-: 305: existing MPI-2 features to extend MPI error classes and code, of to export
-: 306: messages to non-MPI application (smpd?) */
-: 307:#undef FUNCNAME
-: 308:#define FUNCNAME MPIDU_Sock_get_error_class_string
-: 309:#undef FCNAME
-: 310:#define FCNAME MPIU_QUOTE(FUNCNAME)
|
-: 311:/* --BEGIN ERROR HANDLING-- */
-: 312:int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length)
#####: 313:{
-: 314: MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
-: 315:
-: 316: MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
#####: 317: switch (MPIR_ERR_GET_CLASS(error))
-: 318: {
-: 319: case MPIDU_SOCK_ERR_FAIL:
#####: 320: MPIU_Strncpy(error_string, "generic socket failure", length);
#####: 321: break;
-: 322: case MPIDU_SOCK_ERR_INIT:
#####: 323: MPIU_Strncpy(error_string, "socket module not initialized", length);
#####: 324: break;
-: 325: case MPIDU_SOCK_ERR_NOMEM:
#####: 326: MPIU_Strncpy(error_string, "not enough memory to complete the socket operation", length);
#####: 327: break;
-: 328: case MPIDU_SOCK_ERR_BAD_SET:
#####: 329: MPIU_Strncpy(error_string, "invalid socket set", length);
#####: 330: break;
-: 331: case MPIDU_SOCK_ERR_BAD_SOCK:
#####: 332: MPIU_Strncpy(error_string, "invalid socket", length);
#####: 333: break;
-: 334: case MPIDU_SOCK_ERR_BAD_HOST:
#####: 335: MPIU_Strncpy(error_string, "host description buffer not large enough", length);
#####: 336: break;
-: 337: case MPIDU_SOCK_ERR_BAD_HOSTNAME:
#####: 338: MPIU_Strncpy(error_string, "invalid host name", length);
#####: 339: break;
-: 340: case MPIDU_SOCK_ERR_BAD_PORT:
#####: 341: MPIU_Strncpy(error_string, "invalid port", length);
#####: 342: break;
-: 343: case MPIDU_SOCK_ERR_BAD_BUF:
#####: 344: MPIU_Strncpy(error_string, "invalid buffer", length);
#####: 345: break;
-: 346: case MPIDU_SOCK_ERR_BAD_LEN:
#####: 347: MPIU_Strncpy(error_string, "invalid length", length);
#####: 348: break;
-: 349: case MPIDU_SOCK_ERR_SOCK_CLOSED:
#####: 350: MPIU_Strncpy(error_string, "socket closed", length);
#####: 351: break;
-: 352: case MPIDU_SOCK_ERR_CONN_CLOSED:
#####: 353: MPIU_Strncpy(error_string, "socket connection closed", length);
#####: 354: break;
-: 355: case MPIDU_SOCK_ERR_CONN_FAILED:
#####: 356: MPIU_Strncpy(error_string, "socket connection failed", length);
#####: 357: break;
-: 358: case MPIDU_SOCK_ERR_INPROGRESS:
#####: 359: MPIU_Strncpy(error_string, "socket operation in progress", length);
#####: 360: break;
-: 361: case MPIDU_SOCK_ERR_TIMEOUT:
#####: 362: MPIU_Strncpy(error_string, "socket operation timed out", length);
#####: 363: break;
-: 364: case MPIDU_SOCK_ERR_INTR:
#####: 365: MPIU_Strncpy(error_string, "socket operation interrupted", length);
#####: 366: break;
-: 367: case MPIDU_SOCK_ERR_NO_NEW_SOCK:
#####: 368: MPIU_Strncpy(error_string, "no new connection available", length);
#####: 369: break;
-: 370: default:
#####: 371: MPIU_Snprintf(error_string, length, "unknown socket error %d", error);
-: 372: break;
-: 373: }
-: 374: MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
#####: 375: return MPI_SUCCESS;
-: 376:}
-: 377:/* --END ERROR HANDLING-- */
|