[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2-463-g15e323d
Service Account
noreply at mpich.org
Tue Sep 27 14:51:37 CDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".
The branch, master has been updated
via 15e323d1f9ea9ba16b8b59993b8a75c3867afadd (commit)
via 802c218a6bb2c15d0765672379d63ab56ba3e581 (commit)
via b9d1a6cc4095382505ca58d0825eb5b54507db36 (commit)
via ad88e485e8a4cefb96b2924e3aa4f21ff33aa181 (commit)
via 20c70de9358df3eb3ae5ceef3d3c58fc3f14fc69 (commit)
from 0b2c485f02706c5988b878dc69dd350794847ff4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/15e323d1f9ea9ba16b8b59993b8a75c3867afadd
commit 15e323d1f9ea9ba16b8b59993b8a75c3867afadd
Author: Pavan Balaji <balaji at anl.gov>
Date: Tue Feb 2 21:00:38 2016 -0600
sock: cleanup namespace for CH3 internal code.
We should not use the MPIDU_ namespace for the CH3 internal code.
Nemesis specific code should be namespaced as such.
Signed-off-by: Sangmin Seo <sseo at anl.gov>
diff --git a/maint/extracterrmsgs b/maint/extracterrmsgs
index 14f0880..2359bd1 100755
--- a/maint/extracterrmsgs
+++ b/maint/extracterrmsgs
@@ -728,7 +728,7 @@ sub ProcessFile
if ($errClassLoc >= 0 && $checkErrClass) {
if (!($args[$errClassLoc] =~ /^MPI_ERR_/) &&
!($args[$errClassLoc] =~ /^MPI_T_ERR_/) &&
- !($args[$errClassLoc] =~ /^MPIDU_SOCK_ERR_/) &&
+ !($args[$errClassLoc] =~ /^MPIDI_CH3I_SOCK_ERR_/) &&
!($args[$errClassLoc] =~ /^MPIX_ERR_/) &&
!($args[$errClassLoc] =~ /^errclass/) &&
!($args[$errClassLoc] =~ /^\*\(errflag_\)/) &&
diff --git a/maint/extractstates.in b/maint/extractstates.in
index 7ff5162..88a4200 100644
--- a/maint/extractstates.in
+++ b/maint/extractstates.in
@@ -57,8 +57,8 @@ require "$maintdir/extractstrings";
'MPID_STATE_READV' => 'readv',
'MPID_STATE_WRITEV' => 'writev',
'MPID_STATE_MEMCPY' => 'memcpy',
- 'MPID_STATE_MPIDU_SOCK_LISTEN', # used in sock code
- 'MPID_STATE_MPIDU_SOCK_ACCEPT',
+ 'MPID_STATE_MPIDI_CH3I_SOCK_LISTEN', # used in sock code
+ 'MPID_STATE_MPIDI_CH3I_SOCK_ACCEPT',
'MPID_STATE_POLL' => 'poll',
# MPICH internal implementation routines
'MPID_STATE_UPDATE_REQUEST' => 'update_request',
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_getip.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_getip.c
index 3835971..22c7fa7 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_getip.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_getip.c
@@ -58,13 +58,13 @@ static int dbg_ifname = 0;
#define FUNCNAME MPIDI_GetIPInterface
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDI_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
+int MPIDI_GetIPInterface( MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found )
{
int mpi_errno = MPI_SUCCESS;
char *buf_ptr = NULL, *ptr;
int buf_len, buf_len_prev;
int fd;
- MPIDU_Sock_ifaddr_t myifaddr;
+ MPIDI_CH3I_nem_tcp_ifaddr_t myifaddr;
int nfound = 0, foundLocalhost = 0;
/* We predefine the LSB and MSB localhost addresses */
unsigned int localhost = 0x0100007f;
@@ -225,7 +225,7 @@ fn_fail:
#else /* things needed to find the interfaces */
/* In this case, just return false for interfaces found */
-int MPIDI_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
+int MPIDI_GetIPInterface( MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found )
{
*found = 0;
return MPI_SUCCESS;
@@ -244,7 +244,7 @@ int MPIDI_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
#define FUNCNAME MPIDI_Get_IP_for_iface
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDI_Get_IP_for_iface(const char *ifname, MPIDU_Sock_ifaddr_t *ifaddr, int *found)
+int MPIDI_Get_IP_for_iface(const char *ifname, MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found)
{
int mpi_errno = MPI_SUCCESS;
int fd, ret;
@@ -283,7 +283,7 @@ fn_fail:
#define FUNCNAME MPIDI_Get_IP_for_iface
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDI_Get_IP_for_iface(const char *ifname, MPIDU_Sock_ifaddr_t *ifaddr, int *found)
+int MPIDI_Get_IP_for_iface(const char *ifname, MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found)
{
if (found != NULL)
*found = FALSE;
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_impl.h b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_impl.h
index 8a69317..fa27cd4 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_impl.h
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_impl.h
@@ -163,19 +163,19 @@ int MPID_nem_tcp_pkt_unpause_handler(MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt, intpt
/* interface utilities */
/*S
- MPIDU_Sock_ifaddr_t - Structure to hold an Internet address.
+ MPIDI_CH3I_nem_tcp_ifaddr_t - Structure to hold an Internet address.
+ len - Length of the address. 4 for IPv4, 16 for IPv6.
- ifaddr - Address bytes (as bytes, not characters)
S*/
-typedef struct MPIDU_Sock_ifaddr_t {
+typedef struct MPIDI_CH3I_nem_tcp_ifaddr_t {
unsigned int len;
int type;
unsigned char ifaddr[16];
-} MPIDU_Sock_ifaddr_t;
-int MPIDI_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found );
-int MPIDI_Get_IP_for_iface(const char *ifname, MPIDU_Sock_ifaddr_t *ifaddr, int *found);
+} MPIDI_CH3I_nem_tcp_ifaddr_t;
+int MPIDI_GetIPInterface( MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found );
+int MPIDI_Get_IP_for_iface(const char *ifname, MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr, int *found);
/* Keys for business cards */
#define MPIDI_CH3I_PORT_KEY "port"
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
index fd5e5a1..867a835 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
@@ -295,7 +295,7 @@ fn_fail:
*/
static int GetSockInterfaceAddr(int myRank, char *ifname, int maxIfname,
- MPIDU_Sock_ifaddr_t *ifaddr)
+ MPIDI_CH3I_nem_tcp_ifaddr_t *ifaddr)
{
const char *ifname_string;
int mpi_errno = MPI_SUCCESS;
@@ -412,7 +412,7 @@ int MPID_nem_tcp_get_business_card (int my_rank, char **bc_val_p, int *val_max_s
{
int mpi_errno = MPI_SUCCESS;
int str_errno = MPL_STR_SUCCESS;
- MPIDU_Sock_ifaddr_t ifaddr;
+ MPIDI_CH3I_nem_tcp_ifaddr_t ifaddr;
char ifname[MAX_HOST_DESCRIPTION_LEN];
int ret;
struct sockaddr_in sock_id;
diff --git a/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h b/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
index a7a4ded..897c80b 100644
--- a/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
+++ b/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
@@ -49,7 +49,7 @@ typedef struct MPIDI_CH3I_VC
struct MPIR_Request * sendq_head;
struct MPIR_Request * sendq_tail;
MPIDI_CH3I_VC_state_t state;
- struct MPIDU_Sock *sock;
+ struct MPIDI_CH3I_Sock *sock;
struct MPIDI_CH3I_Connection * conn;
}
MPIDI_CH3I_VC;
diff --git a/src/mpid/ch3/channels/sock/include/mpidu_sock.h b/src/mpid/ch3/channels/sock/include/mpidu_sock.h
index 5a47c48..dbd0b4a 100644
--- a/src/mpid/ch3/channels/sock/include/mpidu_sock.h
+++ b/src/mpid/ch3/channels/sock/include/mpidu_sock.h
@@ -4,8 +4,8 @@
* See COPYRIGHT in top-level directory.
*/
-#if !defined(MPIDU_SOCK_H_INCLUDED)
-#define MPIDU_SOCK_H_INCLUDED
+#if !defined(MPIDI_CH3I_SOCK_H_INCLUDED)
+#define MPIDI_CH3I_SOCK_H_INCLUDED
#if defined(__cplusplus)
#if !defined(CPLUSPLUS_BEGIN)
@@ -32,7 +32,7 @@ CPLUSPLUS_BEGIN
/*D
-MPIDU_SOCK_ERR - Extended error classes specific to the Sock module
+MPIDI_CH3I_SOCK_ERR - Extended error classes specific to the Sock module
Notes:
The actual meaning of these error classes is defined by each function.
@@ -46,50 +46,50 @@ D*/
natural grouping of codes to a class, (c) this approach can only be used
by one module and hence breaks any component design, and (d) this is
what the MPI dynamic error codes and classes was designed for. */
-#define MPIDU_SOCK_SUCCESS MPI_SUCCESS
-#define MPIDU_SOCK_ERR_FAIL MPICH_ERR_LAST_CLASS + 1
-#define MPIDU_SOCK_ERR_INIT MPICH_ERR_LAST_CLASS + 2
-#define MPIDU_SOCK_ERR_NOMEM MPICH_ERR_LAST_CLASS + 3
-#define MPIDU_SOCK_ERR_BAD_SET MPICH_ERR_LAST_CLASS + 4
-#define MPIDU_SOCK_ERR_BAD_SOCK MPICH_ERR_LAST_CLASS + 5
-#define MPIDU_SOCK_ERR_BAD_HOST MPICH_ERR_LAST_CLASS + 6
-#define MPIDU_SOCK_ERR_BAD_HOSTNAME MPICH_ERR_LAST_CLASS + 7
-#define MPIDU_SOCK_ERR_BAD_PORT MPICH_ERR_LAST_CLASS + 8
-#define MPIDU_SOCK_ERR_BAD_BUF MPICH_ERR_LAST_CLASS + 9
-#define MPIDU_SOCK_ERR_BAD_LEN MPICH_ERR_LAST_CLASS + 10
-#define MPIDU_SOCK_ERR_SOCK_CLOSED MPICH_ERR_LAST_CLASS + 11
-#define MPIDU_SOCK_ERR_CONN_CLOSED MPICH_ERR_LAST_CLASS + 12
-#define MPIDU_SOCK_ERR_CONN_FAILED MPICH_ERR_LAST_CLASS + 13
-#define MPIDU_SOCK_ERR_INPROGRESS MPICH_ERR_LAST_CLASS + 14
-#define MPIDU_SOCK_ERR_TIMEOUT MPICH_ERR_LAST_CLASS + 15
-#define MPIDU_SOCK_ERR_INTR MPICH_ERR_LAST_CLASS + 16
-#define MPIDU_SOCK_ERR_NO_NEW_SOCK MPICH_ERR_LAST_CLASS + 17
+#define MPIDI_CH3I_SOCK_SUCCESS MPI_SUCCESS
+#define MPIDI_CH3I_SOCK_ERR_FAIL MPICH_ERR_LAST_CLASS + 1
+#define MPIDI_CH3I_SOCK_ERR_INIT MPICH_ERR_LAST_CLASS + 2
+#define MPIDI_CH3I_SOCK_ERR_NOMEM MPICH_ERR_LAST_CLASS + 3
+#define MPIDI_CH3I_SOCK_ERR_BAD_SET MPICH_ERR_LAST_CLASS + 4
+#define MPIDI_CH3I_SOCK_ERR_BAD_SOCK MPICH_ERR_LAST_CLASS + 5
+#define MPIDI_CH3I_SOCK_ERR_BAD_HOST MPICH_ERR_LAST_CLASS + 6
+#define MPIDI_CH3I_SOCK_ERR_BAD_HOSTNAME MPICH_ERR_LAST_CLASS + 7
+#define MPIDI_CH3I_SOCK_ERR_BAD_PORT MPICH_ERR_LAST_CLASS + 8
+#define MPIDI_CH3I_SOCK_ERR_BAD_BUF MPICH_ERR_LAST_CLASS + 9
+#define MPIDI_CH3I_SOCK_ERR_BAD_LEN MPICH_ERR_LAST_CLASS + 10
+#define MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED MPICH_ERR_LAST_CLASS + 11
+#define MPIDI_CH3I_SOCK_ERR_CONN_CLOSED MPICH_ERR_LAST_CLASS + 12
+#define MPIDI_CH3I_SOCK_ERR_CONN_FAILED MPICH_ERR_LAST_CLASS + 13
+#define MPIDI_CH3I_SOCK_ERR_INPROGRESS MPICH_ERR_LAST_CLASS + 14
+#define MPIDI_CH3I_SOCK_ERR_TIMEOUT MPICH_ERR_LAST_CLASS + 15
+#define MPIDI_CH3I_SOCK_ERR_INTR MPICH_ERR_LAST_CLASS + 16
+#define MPIDI_CH3I_SOCK_ERR_NO_NEW_SOCK MPICH_ERR_LAST_CLASS + 17
/*E
-MPIDU_Sock_op_t - enumeration of posted operations that can be completed by the Sock module
+MPIDI_CH3I_Sock_op_t - enumeration of posted operations that can be completed by the Sock module
Notes:
-MPIDU_SOCK_OP_ACCEPT is different that the other operations. When returned by MPIDU_Sock_wait(), operations other than
-MPIDU_SOCK_OP_ACCEPT mark the completion of a previously posted operation. MPIDU_SOCK_OP_ACCEPT indicates that a new connection is
-being formed and that MPIDU_Sock_accept() should be called.
+MPIDI_CH3I_SOCK_OP_ACCEPT is different that the other operations. When returned by MPIDI_CH3I_Sock_wait(), operations other than
+MPIDI_CH3I_SOCK_OP_ACCEPT mark the completion of a previously posted operation. MPIDI_CH3I_SOCK_OP_ACCEPT indicates that a new connection is
+being formed and that MPIDI_CH3I_Sock_accept() should be called.
Module:
Utility-Sock
E*/
-typedef enum MPIDU_Sock_op
+typedef enum MPIDI_CH3I_Sock_op
{
- MPIDU_SOCK_OP_READ,
- MPIDU_SOCK_OP_WRITE,
- MPIDU_SOCK_OP_ACCEPT,
- MPIDU_SOCK_OP_CONNECT,
- MPIDU_SOCK_OP_CLOSE,
- MPIDU_SOCK_OP_WAKEUP
-} MPIDU_Sock_op_t;
+ MPIDI_CH3I_SOCK_OP_READ,
+ MPIDI_CH3I_SOCK_OP_WRITE,
+ MPIDI_CH3I_SOCK_OP_ACCEPT,
+ MPIDI_CH3I_SOCK_OP_CONNECT,
+ MPIDI_CH3I_SOCK_OP_CLOSE,
+ MPIDI_CH3I_SOCK_OP_WAKEUP
+} MPIDI_CH3I_Sock_op_t;
/*S
-MPIDU_Sock_event_t - event structure returned by MPIDU_Sock_wait() describing the operation that completed
+MPIDI_CH3I_Sock_event_t - event structure returned by MPIDI_CH3I_Sock_wait() describing the operation that completed
Fields:
+ op_type - type of operation that completed
@@ -103,22 +103,22 @@ The num_bytes field is only used when a posted read or write operation completes
Module:
Utility-Sock
S*/
-typedef struct MPIDU_Sock_event
+typedef struct MPIDI_CH3I_Sock_event
{
- MPIDU_Sock_op_t op_type;
+ MPIDI_CH3I_Sock_op_t op_type;
size_t num_bytes;
void * user_ptr;
int error;
-} MPIDU_Sock_event_t;
+} MPIDI_CH3I_Sock_event_t;
/*@
-MPIDU_Sock_init - initialize the Sock communication library
+MPIDI_CH3I_Sock_init - initialize the Sock communication library
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - initialization completed successfully
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure; initialization failed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure; initialization failed
Notes:
The Sock module may be initialized multiple times. The implementation should perform reference counting if necessary.
@@ -126,17 +126,17 @@ The Sock module may be initialized multiple times. The implementation should pe
Module:
Utility-Sock
@*/
-int MPIDU_Sock_init(void);
+int MPIDI_CH3I_Sock_init(void);
/*@
-MPIDU_Sock_finalize - shutdown the Sock communication library
+MPIDI_CH3I_Sock_finalize - shutdown the Sock communication library
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - shutdown completed successfully
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure; shutdown failed
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure; shutdown failed
Notes:
<BRT> What are the semantics of finalize? Is it responsible for releasing any resources (socks and sock sets) that the calling
@@ -145,11 +145,11 @@ code(s) leaked? Should it block until all OS resources are released?
Module:
Utility-Sock
@*/
-int MPIDU_Sock_finalize(void);
+int MPIDI_CH3I_Sock_finalize(void);
/*@
-MPIDU_Sock_get_host_description - obtain a description of the host's
+MPIDI_CH3I_Sock_get_host_description - obtain a description of the host's
communication capabilities
Input Parameters:
@@ -161,27 +161,27 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - description successfully obtained and placed in host_description
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_LEN - len parameter is less than zero
-. MPIDU_SOCK_ERR_BAD_HOST - host_description parameter not big enough to
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - len parameter is less than zero
+. MPIDI_CH3I_SOCK_ERR_BAD_HOST - host_description parameter not big enough to
store required information
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - unable to obtain network interface information from OS
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - unable to obtain network interface information from OS
Notes:
The host description string returned by the function is defined by the
implementation and should not be interpreted by the
-application. This string is to be supplied to MPIDU_Sock_post_connect() when
+application. This string is to be supplied to MPIDI_CH3I_Sock_post_connect() when
one wishes to form a connection with this host.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_get_host_description(int myRank, char * host_description, int len);
+int MPIDI_CH3I_Sock_get_host_description(int myRank, char * host_description, int len);
/*@
-MPIDU_Sock_hostname_to_host_description - convert a host name to a description of the host's communication capabilities
+MPIDI_CH3I_Sock_hostname_to_host_description - convert a host name to a description of the host's communication capabilities
Input Parameters:
+ hostname - host name string
@@ -190,35 +190,35 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - description successfully obtained and placed in host_description
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_LEN - len parameter is less than zero
-. MPIDU_SOCK_ERR_BAD_HOSTNAME - hostname parameter not valid
-. MPIDU_SOCK_ERR_BAD_HOST - host_description parameter not big enough to store required information
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - unable to obtain network interface information from OS
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - len parameter is less than zero
+. MPIDI_CH3I_SOCK_ERR_BAD_HOSTNAME - hostname parameter not valid
+. MPIDI_CH3I_SOCK_ERR_BAD_HOST - host_description parameter not big enough to store required information
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - unable to obtain network interface information from OS
Notes:
The host description string returned by the function is defined by the implementation and should not be interpreted by the
-application. This string is to be supplied to MPIDU_Sock_post_connect() when one wishes to form a connection with the host
+application. This string is to be supplied to MPIDI_CH3I_Sock_post_connect() when one wishes to form a connection with the host
specified by hostname.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_hostname_to_host_description(char *hostname, char * host_description, int len);
+int MPIDI_CH3I_Sock_hostname_to_host_description(char *hostname, char * host_description, int len);
/*@
-MPIDU_Sock_create_set - create a new sock set object
+MPIDI_CH3I_Sock_create_set - create a new sock set object
Output Parameter:
. set - pointer to the new sock set object
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - new sock set successfully create
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - pointer to the sock set object is bad
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - pointer to the sock set object is bad
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure
Notes:
A sock set contains zero or more sock objects. Each sock object belongs to a single sock set and is bound to that set for the life
@@ -227,11 +227,11 @@ of that object.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_create_set(MPIDU_Sock_set_t * set);
+int MPIDI_CH3I_Sock_create_set(MPIDI_CH3I_Sock_set_t * set);
/*@
-MPIDU_Sock_close_open_sockets - close the first open sockets of a sock_element
+MPIDI_CH3I_Sock_close_open_sockets - close the first open sockets of a sock_element
Input Parameter:
. set - set to be considered
@@ -241,10 +241,10 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - sock set successfully destroyed
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - unable to destroy the sock set (<BRT> because it still contained active sock objects?)
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - unable to destroy the sock set (<BRT> because it still contained active sock objects?)
Notes:
@@ -254,21 +254,21 @@ be called repeatedly, untiluser_ptr == NULL. The reason for this is
that the overlying protocoll may need the user_ptr for further cleanup.
@*/
-int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_ptr );
+int MPIDI_CH3I_Sock_close_open_sockets(struct MPIDI_CH3I_Sock_set * sock_set, void** user_ptr );
/*@
-MPIDU_Sock_destroy_set - destroy an existing sock set, releasing an internal resource associated with that set
+MPIDI_CH3I_Sock_destroy_set - destroy an existing sock set, releasing an internal resource associated with that set
Input Parameter:
. set - set to be destroyed
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - sock set successfully destroyed
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - unable to destroy the sock set (<BRT> because it still contained active sock objects?)
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - unable to destroy the sock set (<BRT> because it still contained active sock objects?)
Notes:
<BRT> What are the semantics for destroying a sock set that still contains active sock objects? sock objects by definition
@@ -279,11 +279,11 @@ It is consider erroneous to destroy a set that still contains sock objects or is
Module:
Utility-Sock
@*/
-int MPIDU_Sock_destroy_set(MPIDU_Sock_set_t set);
+int MPIDI_CH3I_Sock_destroy_set(MPIDI_CH3I_Sock_set_t set);
/*@
-MPIDU_Sock_native_to_sock - convert a native file descriptor/handle to a sock object
+MPIDI_CH3I_Sock_native_to_sock - convert a native file descriptor/handle to a sock object
Input Parameters:
+ set - sock set to which the new sock should be added
@@ -295,15 +295,15 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - sock successfully created
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_BAD_NATIVE_FD - invalid native file descriptor
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure; listener sock could not be created
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_BAD_NATIVE_FD - invalid native file descriptor
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure; listener sock could not be created
Notes:
The constraints on which file descriptors/handles may be converted to a sock object are defined by the implementation. The
-implementation may return MPIDU_SOCK_ERR_BAD_NATIVE_FD if the descriptor/handle cannot be used with the implementation. It is
+implementation may return MPIDI_CH3I_SOCK_ERR_BAD_NATIVE_FD if the descriptor/handle cannot be used with the implementation. It is
possible, however, that the conversion of an inappropriate descriptor/handle may complete successfully but the sock object may not
function properly.
@@ -312,11 +312,11 @@ The addition of a new sock object to the sock set may occur while other threads
Thread safety of simultaneously operations on the same sock set must be guaranteed by the Sock implementation.
@*/
-int MPIDU_Sock_native_to_sock(MPIDU_Sock_set_t set, MPIDU_SOCK_NATIVE_FD fd, void * user_ptr, MPIDU_Sock_t * sock);
+int MPIDI_CH3I_Sock_native_to_sock(MPIDI_CH3I_Sock_set_t set, MPIDI_CH3I_SOCK_NATIVE_FD fd, void * user_ptr, MPIDI_CH3I_Sock_t * sock);
/*@
-MPIDU_Sock_listen - establish a listener sock
+MPIDI_CH3I_Sock_listen - establish a listener sock
Input Parameters:
+ set - sock set to which the listening sock should be added
@@ -329,30 +329,30 @@ Output Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - listener sock successfully established
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_BAD_PORT - port number is out of range or pointer to port parameter is invalid
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure; listener sock could not be created
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_BAD_PORT - port number is out of range or pointer to port parameter is invalid
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure; listener sock could not be created
Events generated:
-. MPIDU_SOCK_OP_ACCEPT - each time a new connection is being formed and needs to be accepted (with MPIDU_Sock_accept())
+. MPIDI_CH3I_SOCK_OP_ACCEPT - each time a new connection is being formed and needs to be accepted (with MPIDI_CH3I_Sock_accept())
Event errors:
+ MPI_SUCCESS - new sock waiting to be accepted
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure?
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure?
Notes:
While not a post routine, this routine can generate events. In fact,
-unlike the post routine, many MPIDU_SOCK_OP_ACCEPT events can
+unlike the post routine, many MPIDI_CH3I_SOCK_OP_ACCEPT events can
be generated from a listener (typically one per incoming connection attempt).
The implementation may generate an event as soon it is notified that a
new connection is forming. In such an implementation,
-MPIDU_Sock_accept() may be responsible for finalizing the connection.
+MPIDI_CH3I_Sock_accept() may be responsible for finalizing the connection.
It is also possible that the connection may fail to
-complete, causing MPIDU_Sock_accept() to be unable to obtain a sock
+complete, causing MPIDI_CH3I_Sock_accept() to be unable to obtain a sock
despite the event notification.
The environment variable MPICH_PORT_RANGE=min:max may be used to
@@ -367,11 +367,11 @@ must be guaranteed by the Sock implementation.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_listen(MPIDU_Sock_set_t set, void * user_ptr, int * port, MPIDU_Sock_t * sock);
+int MPIDI_CH3I_Sock_listen(MPIDI_CH3I_Sock_set_t set, void * user_ptr, int * port, MPIDI_CH3I_Sock_t * sock);
/*@
-MPIDU_Sock_accept - obtain the sock object associated with a new connection
+MPIDI_CH3I_Sock_accept - obtain the sock object associated with a new connection
Input Parameters:
+ listener_sock - listener sock object from which to obtain the new connection
@@ -383,33 +383,33 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - new connection successfully established and associated with new sock objecta
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_NO_NEW_SOCK - no new connection was available
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid listener sock or bad pointer to new sock object
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - failed to acquire a new connection
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_NO_NEW_SOCK - no new connection was available
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid listener sock or bad pointer to new sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - failed to acquire a new connection
Notes:
-In the event of a connection failure, MPIDU_Sock_accept() may fail to acquire and return a new sock despite any
-MPIDU_SOCK_OP_ACCEPT event notification. On the other hand, MPIDU_Sock_accept() may return a sock for which the underlying
+In the event of a connection failure, MPIDI_CH3I_Sock_accept() may fail to acquire and return a new sock despite any
+MPIDI_CH3I_SOCK_OP_ACCEPT event notification. On the other hand, MPIDI_CH3I_Sock_accept() may return a sock for which the underlying
connection has already failed. (The Sock implementation may be unaware of the failure until read/write operations are performed.)
Thread safety:
The addition of the new sock object to the sock set may occur while other threads are performing operations on the same sock set.
Thread safety of simultaneously operations on the same sock set must be guaranteed by the Sock implementation.
-MPIDU_Sock_accept() may fail to return a new sock if multiple threads call MPIDU_Sock_accept() and queue of new connections is
-depleted. In this case, MPIDU_SOCK_ERR_NO_SOCK is returned.
+MPIDI_CH3I_Sock_accept() may fail to return a new sock if multiple threads call MPIDI_CH3I_Sock_accept() and queue of new connections is
+depleted. In this case, MPIDI_CH3I_SOCK_ERR_NO_SOCK is returned.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_accept(MPIDU_Sock_t listener_sock, MPIDU_Sock_set_t set, void * user_ptr, MPIDU_Sock_t * sock);
+int MPIDI_CH3I_Sock_accept(MPIDI_CH3I_Sock_t listener_sock, MPIDI_CH3I_Sock_set_t set, void * user_ptr, MPIDI_CH3I_Sock_t * sock);
/*@
-MPIDU_Sock_post_connect - request that a new connection be formed
+MPIDI_CH3I_Sock_post_connect - request that a new connection be formed
Input Parameters:
+ set - sock set to which the new sock object should be added
@@ -422,27 +422,27 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to form new connection successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set
-. MPIDU_SOCK_ERR_BAD_HOST - host description string is not valid
-. MPIDU_SOCK_ERR_BAD_PORT - port number is out of range
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure attempting to post connection request
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set
+. MPIDI_CH3I_SOCK_ERR_BAD_HOST - host description string is not valid
+. MPIDI_CH3I_SOCK_ERR_BAD_PORT - port number is out of range
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure attempting to post connection request
Events generated:
-. MPIDU_SOCK_OP_CONNECT
+. MPIDI_CH3I_SOCK_OP_CONNECT
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_CONN_FAILED - failed to connect to the remote host
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error?
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - failed to connect to the remote host
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error?
<BRT> Any other event errors? Does the sock channel require finer granularity?
Notes:
-The host description of the listening host is supplied MPIDU_Sock_get_host_description(). The intention is that the description
-contain an enumeration of interface information so that the MPIDU_Sock_connect() can try each of the interfaces until it succeeds
+The host description of the listening host is supplied MPIDI_CH3I_Sock_get_host_description(). The intention is that the description
+contain an enumeration of interface information so that the MPIDI_CH3I_Sock_connect() can try each of the interfaces until it succeeds
in forming a connection. Having a complete set of interface information also allows a particular interface be used selected by the
user at runtime using the MPICH_NETMASK. <BRT> The name of the environment variable seems wrong. Perhaps MPICH_INTERFACE? We
should ask the Systems group.
@@ -454,34 +454,34 @@ Thread safety of simultaneously operations on the same sock set must be guarante
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_connect(MPIDU_Sock_set_t set, void * user_ptr, char * host_description, int port, MPIDU_Sock_t * sock);
+int MPIDI_CH3I_Sock_post_connect(MPIDI_CH3I_Sock_set_t set, void * user_ptr, char * host_description, int port, MPIDI_CH3I_Sock_t * sock);
/*S
- MPIDU_Sock_ifaddr_t - Structure to hold an Internet address.
+ MPIDI_CH3I_Sock_ifaddr_t - Structure to hold an Internet address.
+ len - Length of the address. 4 for IPv4, 16 for IPv6.
- ifaddr - Address bytes (as bytes, not characters)
S*/
-typedef struct MPIDU_Sock_ifaddr_t {
+typedef struct MPIDI_CH3I_Sock_ifaddr_t {
int len, type;
unsigned char ifaddr[16];
-} MPIDU_Sock_ifaddr_t;
+} MPIDI_CH3I_Sock_ifaddr_t;
-/*@ MPIDU_Sock_post_connect_ifaddr - Post a connection given an interface
+/*@ MPIDI_CH3I_Sock_post_connect_ifaddr - Post a connection given an interface
address (bytes, not string).
- This is the basic routine. MPIDU_Sock_post_connect converts the
+ This is the basic routine. MPIDI_CH3I_Sock_post_connect converts the
host description into the ifaddr and calls this routine.
@*/
-int MPIDU_Sock_post_connect_ifaddr( MPIDU_Sock_set_t sock_set,
+int MPIDI_CH3I_Sock_post_connect_ifaddr( MPIDI_CH3I_Sock_set_t sock_set,
void * user_ptr,
- MPIDU_Sock_ifaddr_t *ifaddr, int port,
- MPIDU_Sock_t * sockp);
+ MPIDI_CH3I_Sock_ifaddr_t *ifaddr, int port,
+ MPIDI_CH3I_Sock_t * sockp);
/*@
-MPIDU_Sock_set_user_ptr - change the user pointer associated with a sock object
+MPIDI_CH3I_Sock_set_user_ptr - change the user pointer associated with a sock object
Input Parameters:
+ sock - sock object
@@ -489,71 +489,71 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - user pointer successfully updated
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-- MPIDU_SOCK_ERR_FAIL - other failure?
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure?
Module:
Utility-Sock
@*/
-int MPIDU_Sock_set_user_ptr(MPIDU_Sock_t sock, void * user_ptr);
+int MPIDI_CH3I_Sock_set_user_ptr(MPIDI_CH3I_Sock_t sock, void * user_ptr);
/*@
-MPIDU_Sock_post_close - request that an existing connection be closed
+MPIDI_CH3I_Sock_post_close - request that an existing connection be closed
Input Parameter:
. sock - sock object to be closed
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to close the connection was successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object or close already posted
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other failure?
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object or close already posted
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other failure?
Events generated:
-+ MPIDU_SOCK_OP_CLOSE
-. MPIDU_SOCK_OP_READ
-- MPIDU_SOCK_OP_WRITE
++ MPIDI_CH3I_SOCK_OP_CLOSE
+. MPIDI_CH3I_SOCK_OP_READ
+- MPIDI_CH3I_SOCK_OP_WRITE
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - an error occurred closing the sock; sock object is still destroyed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - an error occurred closing the sock; sock object is still destroyed
Notes:
If any other operations are posted on the specified sock, they will be terminated. An appropriate event will be generated for each
-terminated operation. All such events will be delivered by MPIDU_Sock_wait() prior to the delivery of the MPIDU_SOCK_OP_CLOSE
+terminated operation. All such events will be delivered by MPIDI_CH3I_Sock_wait() prior to the delivery of the MPIDI_CH3I_SOCK_OP_CLOSE
event.
-The sock object is destroyed just prior to the MPIDU_SOCK_OP_CLOSE event being returned by MPIDU_Sock_wait(). Any oustanding
+The sock object is destroyed just prior to the MPIDI_CH3I_SOCK_OP_CLOSE event being returned by MPIDI_CH3I_Sock_wait(). Any oustanding
references to the sock object held by the application should be considered invalid and not used again.
Thread safety:
-MPIDU_Sock_post_close() may be called while another thread is calling or blocking in MPIDU_Sock_wait() specifying the same sock set
-to which this sock belongs. If another thread is blocking MPIDU_Sock_wait() and the close operation causes the sock set to become
-empty, then MPIDU_Sock_wait() will return with an error.
+MPIDI_CH3I_Sock_post_close() may be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() specifying the same sock set
+to which this sock belongs. If another thread is blocking MPIDI_CH3I_Sock_wait() and the close operation causes the sock set to become
+empty, then MPIDI_CH3I_Sock_wait() will return with an error.
-Calling any of the immediate or post routines during or after the call to MPIDU_Sock_post_close() is consider an application error.
+Calling any of the immediate or post routines during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error.
The result of doing so is undefined. The application should coordinate the closing of a sock with the activities of other threads
to ensure that simultaneous calls do not occur.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_close(MPIDU_Sock_t sock);
+int MPIDI_CH3I_Sock_post_close(MPIDI_CH3I_Sock_t sock);
/*E
-MPIDU_Sock_progress_update_func_t - progress update callback functions
+MPIDI_CH3I_Sock_progress_update_func_t - progress update callback functions
If a pointer to a function of this type is passed to one of the post read or write functions, the implementation must honor the
following rules:
1) The sock progress engine will call this function when partial data has been read or written for the posted operation.
-2) All progress_update calls must complete before completion notification is signalled. In other words, MPIDU_Sock_wait() will not
+2) All progress_update calls must complete before completion notification is signalled. In other words, MPIDI_CH3I_Sock_wait() will not
return until all progress_update calls have completed.
Notes:
@@ -563,11 +563,11 @@ internal progress engine could block on an application routine.
Module:
Utility-Sock
E*/
-typedef int (* MPIDU_Sock_progress_update_func_t)(size_t num_bytes, void * user_ptr);
+typedef int (* MPIDI_CH3I_Sock_progress_update_func_t)(size_t num_bytes, void * user_ptr);
/*@
-MPIDU_Sock_post_read - request that data be read from a sock
+MPIDI_CH3I_Sock_post_read - request that data be read from a sock
Input Parameters:
+ sock - sock object from which data is to be read
@@ -578,56 +578,56 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to read was successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_LEN - length parameters must be greater than zero and maxlen must be greater than minlen
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post read
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - length parameters must be greater than zero and maxlen must be greater than minlen
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post read
Events generated:
-. MPIDU_SOCK_OP_READ
+. MPIDI_CH3I_SOCK_OP_READ
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by buf and maxlen resulted in a memory fault
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error completing the read
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by buf and maxlen resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error completing the read
Notes:
Only one read operation may be posted at a time. Furthermore, an immediate read may not be performed while a posted write is
outstanding. This is considered to be an application error, and the results of doing so are undefined. The implementation may
-choose to catch the error and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+choose to catch the error and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-If MPIDU_Sock_post_close() is called before the posted read operation completes, the read operation will be terminated and a
-MPIDU_SOCK_OP_READ event containing a MPIDU_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
-MPIDU_Sock_wait() prior to the MPIDU_SOCK_OP_CLOSE event.
+If MPIDI_CH3I_Sock_post_close() is called before the posted read operation completes, the read operation will be terminated and a
+MPIDI_CH3I_SOCK_OP_READ event containing a MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
+MPIDI_CH3I_Sock_wait() prior to the MPIDI_CH3I_SOCK_OP_CLOSE event.
Thread safety:
-MPIDU_Sock_post_read() may be called while another thread is attempting to perform an immediate write or post a write operation on
-the same sock. MPIDU_Sock_post_read() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the
+MPIDI_CH3I_Sock_post_read() may be called while another thread is attempting to perform an immediate write or post a write operation on
+the same sock. MPIDI_CH3I_Sock_post_read() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the
same sock set to which the specified sock belongs.
-MPIDU_Sock_post_write() may not be called while another thread is performing an immediate read on the same sock. This is
+MPIDI_CH3I_Sock_post_write() may not be called while another thread is performing an immediate read on the same sock. This is
considered to be an application error, and the results of doing so are undefined. The implementation may choose to catch the error
-and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_post_read() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result of
+Calling MPIDI_CH3I_Sock_post_read() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result of
doing so is undefined. The application should coordinate the closing of a sock with the activities of other threads to ensure that
one thread is not attempting to post a new operation while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_read(MPIDU_Sock_t sock, void * buf, size_t minbr, size_t maxbr,
- MPIDU_Sock_progress_update_func_t fn);
+int MPIDI_CH3I_Sock_post_read(MPIDI_CH3I_Sock_t sock, void * buf, size_t minbr, size_t maxbr,
+ MPIDI_CH3I_Sock_progress_update_func_t fn);
/*@
-MPIDU_Sock_post_readv - request that a vector of data be read from a sock
+MPIDI_CH3I_Sock_post_readv - request that a vector of data be read from a sock
Input Parameters:
+ sock - sock object from which the data is to read
@@ -637,55 +637,55 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to read was successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_LEN - iov_n is out of range
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post read
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - iov_n is out of range
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post read
Events generated:
-. MPIDU_SOCK_OP_READ
+. MPIDI_CH3I_SOCK_OP_READ
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error completing the read
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error completing the read
Notes:
Only one read operation may be posted at a time. Furthermore, an immediate read may not be performed while a posted write is
outstanding. This is considered to be an application error, and the results of doing so are undefined. The implementation may
-choose to catch the error and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+choose to catch the error and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-If MPIDU_Sock_post_close() is called before the posted read operation completes, the read operation will be terminated and a
-MPIDU_SOCK_OP_READ event containing a MPIDU_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
-MPIDU_Sock_wait() prior to the MPIDU_SOCK_OP_CLOSE event.
+If MPIDI_CH3I_Sock_post_close() is called before the posted read operation completes, the read operation will be terminated and a
+MPIDI_CH3I_SOCK_OP_READ event containing a MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
+MPIDI_CH3I_Sock_wait() prior to the MPIDI_CH3I_SOCK_OP_CLOSE event.
Thread safety:
-MPIDU_Sock_post_readv() may be called while another thread is attempting to perform an immediate write or post a write operation on
-the same sock. MPIDU_Sock_post_readv() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the
+MPIDI_CH3I_Sock_post_readv() may be called while another thread is attempting to perform an immediate write or post a write operation on
+the same sock. MPIDI_CH3I_Sock_post_readv() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the
same sock set to which the specified sock belongs.
-MPIDU_Sock_post_readv() may not be called while another thread is performing an immediate read on the same sock. This is
+MPIDI_CH3I_Sock_post_readv() may not be called while another thread is performing an immediate read on the same sock. This is
considered to be an application error, and the results of doing so are undefined. The implementation may choose to catch the error
-and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_post_readv() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result
+Calling MPIDI_CH3I_Sock_post_readv() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result
of doing so is undefined. The application should coordinate the closing of a sock with the activities of other threads to ensure
that one thread is not attempting to post a new operation while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn);
+int MPIDI_CH3I_Sock_post_readv(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDI_CH3I_Sock_progress_update_func_t fn);
/*@
-MPIDU_Sock_post_write - request that data be written to a sock
+MPIDI_CH3I_Sock_post_write - request that data be written to a sock
Input Parameters:
+ sock - sock object which the data is to be written
@@ -696,44 +696,44 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to write was successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_LEN - length parameters must be greater than zero and maxlen must be greater than minlen
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post write
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - length parameters must be greater than zero and maxlen must be greater than minlen
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post write
Events generated:
-. MPIDU_SOCK_OP_WRITE
+. MPIDI_CH3I_SOCK_OP_WRITE
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by buf and maxlen resulted in a memory fault
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error completing the write
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by buf and maxlen resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error completing the write
Notes:
Only one write operation may be posted at a time. Furthermore, an immediate write may not be performed while a posted write is
outstanding. This is considered to be an application error, and the results of doing so are undefined. The implementation may
-choose to catch the error and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+choose to catch the error and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-If MPIDU_Sock_post_close() is called before the posted write operation completes, the write operation will be terminated and a
-MPIDU_SOCK_OP_WRITE event containing a MPIDU_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
-MPIDU_Sock_wait() prior to the MPIDU_SOCK_OP_CLOSE event.
+If MPIDI_CH3I_Sock_post_close() is called before the posted write operation completes, the write operation will be terminated and a
+MPIDI_CH3I_SOCK_OP_WRITE event containing a MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
+MPIDI_CH3I_Sock_wait() prior to the MPIDI_CH3I_SOCK_OP_CLOSE event.
Thread safety:
-MPIDU_Sock_post_write() may be called while another thread is attempting to perform an immediate read or post a read operation on
-the same sock. MPIDU_Sock_post_write() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the
+MPIDI_CH3I_Sock_post_write() may be called while another thread is attempting to perform an immediate read or post a read operation on
+the same sock. MPIDI_CH3I_Sock_post_write() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the
same sock set to which the specified sock belongs.
-MPIDU_Sock_post_write() may not be called while another thread is performing an immediate write on the same sock. This is
+MPIDI_CH3I_Sock_post_write() may not be called while another thread is performing an immediate write on the same sock. This is
considered to be an application error, and the results of doing so are undefined. The implementation may choose to catch the error
-and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_post_write() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result
+Calling MPIDI_CH3I_Sock_post_write() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result
of doing so is undefined. The application should coordinate the closing of a sock with the activities of other threads to ensure
that one thread is not attempting to post a new operation while another thread is attempting to close the sock. <BRT> Do we really
need this flexibility?
@@ -741,12 +741,12 @@ need this flexibility?
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_write(MPIDU_Sock_t sock, void * buf, size_t min, size_t max,
- MPIDU_Sock_progress_update_func_t fn);
+int MPIDI_CH3I_Sock_post_write(MPIDI_CH3I_Sock_t sock, void * buf, size_t min, size_t max,
+ MPIDI_CH3I_Sock_progress_update_func_t fn);
/*@
-MPIDU_Sock_post_writev - request that a vector of data be written to a sock
+MPIDI_CH3I_Sock_post_writev - request that a vector of data be written to a sock
Input Parameters:
+ sock - sock object which the data is to be written
@@ -756,55 +756,55 @@ Input Parameters:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - request to write was successfully posted
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_LEN - iov_n is out of range
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post write
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - iov_n is out of range
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post write
Events generated:
-. MPIDU_SOCK_OP_WRITE
+. MPIDI_CH3I_SOCK_OP_WRITE
Event errors: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - successfully established
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error completing the write
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error completing the write
Notes:
Only one write operation may be posted at a time. Furthermore, an immediate write may not be performed while a posted write is
outstanding. This is considered to be an application error, and the results of doing so are undefined. The implementation may
-choose to catch the error and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+choose to catch the error and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-If MPIDU_Sock_post_close() is called before the posted write operation completes, the write operation will be terminated and a
-MPIDU_SOCK_OP_WRITE event containing a MPIDU_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
-MPIDU_Sock_wait() prior to the MPIDU_SOCK_OP_CLOSE event.
+If MPIDI_CH3I_Sock_post_close() is called before the posted write operation completes, the write operation will be terminated and a
+MPIDI_CH3I_SOCK_OP_WRITE event containing a MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED error will be generated. This event will be returned by
+MPIDI_CH3I_Sock_wait() prior to the MPIDI_CH3I_SOCK_OP_CLOSE event.
Thread safety:
-MPIDU_Sock_post_writev() may be called while another thread is attempting to perform an immediate read or post a read operation on
-the same sock. MPIDU_Sock_post_writev() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the
+MPIDI_CH3I_Sock_post_writev() may be called while another thread is attempting to perform an immediate read or post a read operation on
+the same sock. MPIDI_CH3I_Sock_post_writev() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the
same sock set to which the specified sock belongs.
-MPIDU_Sock_post_writev() may not be called while another thread is performing an immediate write on the same sock. This is
+MPIDI_CH3I_Sock_post_writev() may not be called while another thread is performing an immediate write on the same sock. This is
considered to be an application error, and the results of doing so are undefined. The implementation may choose to catch the error
-and return MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+and return MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_post_writev() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result
+Calling MPIDI_CH3I_Sock_post_writev() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result
of doing so is undefined. The application should coordinate the closing of a sock with the activities of other threads to ensure
that one thread is not attempting to post a new operation while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_post_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn);
+int MPIDI_CH3I_Sock_post_writev(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDI_CH3I_Sock_progress_update_func_t fn);
/*@
-MPIDU_Sock_wait - wait for an event
+MPIDI_CH3I_Sock_wait - wait for an event
Input Parameters:
+ set - sock set upon which to wait for an event
@@ -815,56 +815,56 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - a new event was returned
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set object
-. MPIDU_SOCK_ERR_TIMEOUT - a timeout occurred
-. MPIDU_SOCK_ERR_INTR - the routine was interrupted by a call to MPIDU_Sock_wakeup()
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error (are there any?)
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set object
+. MPIDI_CH3I_SOCK_ERR_TIMEOUT - a timeout occurred
+. MPIDI_CH3I_SOCK_ERR_INTR - the routine was interrupted by a call to MPIDI_CH3I_Sock_wakeup()
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error (are there any?)
Notes:
-MPIDU_Sock_wakeup() can be called from another thread to force MPIDU_Sock_wait() to return with a MPIDU_SOCK_ERR_INTR error.
-MPIDU_Sock_wakeup() may not be called from within a progress update function or any function directly or indirectly called by a
+MPIDI_CH3I_Sock_wakeup() can be called from another thread to force MPIDI_CH3I_Sock_wait() to return with a MPIDI_CH3I_SOCK_ERR_INTR error.
+MPIDI_CH3I_Sock_wakeup() may not be called from within a progress update function or any function directly or indirectly called by a
progress update function.
Thread safety:
New operations may be posted to sock contained in the specified sock set while another thread is calling or blocking in
-MPIDU_Sock_wait(). These operations should complete as though they were posted before MPIDU_Sock_wait() was called.
+MPIDI_CH3I_Sock_wait(). These operations should complete as though they were posted before MPIDI_CH3I_Sock_wait() was called.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_wait(MPIDU_Sock_set_t set, int timeout, MPIDU_Sock_event_t * event);
+int MPIDI_CH3I_Sock_wait(MPIDI_CH3I_Sock_set_t set, int timeout, MPIDI_CH3I_Sock_event_t * event);
/*@
-MPIDU_Sock_wakeup - wakeup a MPIDU_Sock_wait blocking in another thread
+MPIDI_CH3I_Sock_wakeup - wakeup a MPIDI_CH3I_Sock_wait blocking in another thread
Input Parameter:
. set - sock set upon which to wait for an event
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - wakeup request successfully processed
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SET - invalid sock set object
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory (is this possible?)
-- MPIDU_SOCK_ERR_FAIL - other error (are there any?)
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SET - invalid sock set object
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory (is this possible?)
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error (are there any?)
Notes:
-This routine forces a MPIDU_Sock_wait() blocking in another thread to wakeup and return a MPIDU_SOCK_ERR_INTR error.
-MPIDU_Sock_wakeup() may not be called from within a progress update function or any function directly or indirectly called by a
+This routine forces a MPIDI_CH3I_Sock_wait() blocking in another thread to wakeup and return a MPIDI_CH3I_SOCK_ERR_INTR error.
+MPIDI_CH3I_Sock_wakeup() may not be called from within a progress update function or any function directly or indirectly called by a
progress update function.
-The implementation should strive to only wakeup a MPIDU_Sock_wait() that is already blocking; however, it is acceptable (although
-undesireable) for it wakeup a MPIDU_Sock_wait() that is called in the future.
+The implementation should strive to only wakeup a MPIDI_CH3I_Sock_wait() that is already blocking; however, it is acceptable (although
+undesireable) for it wakeup a MPIDI_CH3I_Sock_wait() that is called in the future.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_wakeup(MPIDU_Sock_set_t set);
+int MPIDI_CH3I_Sock_wakeup(MPIDI_CH3I_Sock_set_t set);
/*@
-MPIDU_Sock_read - perform an immediate read
+MPIDI_CH3I_Sock_read - perform an immediate read
Input Parameters:
+ sock - sock object from which data is to be read
@@ -876,45 +876,45 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - no error encountered during the read operation
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by buf and len resulted in a memory fault
-. MPIDU_SOCK_ERR_BAD_LEN - length parameter must be greater than zero
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post read
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by buf and len resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - length parameter must be greater than zero
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post read
Notes:
An immediate read may not be performed while a posted read is outstanding on the same sock. This is considered to be an
application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
Thread safety:
-MPIDU_Sock_read() may be called while another thread is attempting to perform an immediate write or post a write operation on the
-same sock. MPIDU_Sock_read() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the same sock
+MPIDI_CH3I_Sock_read() may be called while another thread is attempting to perform an immediate write or post a write operation on the
+same sock. MPIDI_CH3I_Sock_read() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the same sock
set to which the specified sock belongs.
A immediate read may not be performed if another thread is performing an immediate read on the same sock. This is considered to be
an application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_read() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result of
-doing so is undefined, although the implementation may choose to return MPIDU_SOCK_ERR_SOCK_CLOSED if it is able to catch the
+Calling MPIDI_CH3I_Sock_read() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result of
+doing so is undefined, although the implementation may choose to return MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED if it is able to catch the
error. The application should coordinate the closing of a sock with the activities of other threads to ensure that one thread is
not attempting to perform an immediate read while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len, size_t * num_read);
+int MPIDI_CH3I_Sock_read(MPIDI_CH3I_Sock_t sock, void * buf, size_t len, size_t * num_read);
/*@
-MPIDU_Sock_readv - perform an immediate vector read
+MPIDI_CH3I_Sock_readv - perform an immediate vector read
Input Parameters:
+ sock - sock object from which data is to be read
@@ -926,45 +926,45 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - no error encountered during the read operation
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
-. MPIDU_SOCK_ERR_BAD_LEN - iov_n parameter must be greater than zero and not greater than MPL_IOV_LIMIT
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error attempting to post read
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - iov_n parameter must be greater than zero and not greater than MPL_IOV_LIMIT
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to post read
Notes:
An immediate read may not be performed while a posted read is outstanding on the same sock. This is considered to be an
application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
Thread safety:
-MPIDU_Sock_read() may be called while another thread is attempting to perform an immediate write or post a write operation on the
-same sock. MPIDU_Sock_read() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the same sock
+MPIDI_CH3I_Sock_read() may be called while another thread is attempting to perform an immediate write or post a write operation on the
+same sock. MPIDI_CH3I_Sock_read() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the same sock
set to which the specified sock belongs.
A immediate read may not be performed if another thread is performing an immediate read on the same sock. This is considered to be
an application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_read() during or after the call to MPIDU_Sock_post_close() is consider an application error. The result of
-doing so is undefined, although the implementation may choose to return MPIDU_SOCK_ERR_SOCK_CLOSED if it is able to catch the
+Calling MPIDI_CH3I_Sock_read() during or after the call to MPIDI_CH3I_Sock_post_close() is consider an application error. The result of
+doing so is undefined, although the implementation may choose to return MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED if it is able to catch the
error. The application should coordinate the closing of a sock with the activities of other threads to ensure that one thread is
not attempting to perform an immediate read while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_read);
+int MPIDI_CH3I_Sock_readv(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_read);
/*@
-MPIDU_Sock_write - perform an immediate write
+MPIDI_CH3I_Sock_write - perform an immediate write
Input Parameters:
+ sock - sock object to which data is to be written
@@ -976,44 +976,44 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - no error encountered during the write operation
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by buf and len resulted in a memory fault
-. MPIDU_SOCK_ERR_BAD_LEN - length parameter must be greater than zero
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error attempting to perform the write
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by buf and len resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - length parameter must be greater than zero
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to perform the write
Notes:
An immediate write may not be performed while a posted write is outstanding on the same sock. This is considered to be an
application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
Thread safety:
-MPIDU_Sock_write() may be called while another thread is attempting to perform an immediate read or post a read operation on the
-same sock. MPIDU_Sock_write() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the same sock
+MPIDI_CH3I_Sock_write() may be called while another thread is attempting to perform an immediate read or post a read operation on the
+same sock. MPIDI_CH3I_Sock_write() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the same sock
set to which the specified sock belongs.
A immediate write may not be performed if another thread is performing an immediate write on the same sock. This is considered to
be an application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_write() during or after the call to MPIDU_Sock_post_close() is consider to be an application error. The result
-of doing so is undefined, although the implementation may choose to return MPIDU_SOCK_ERR_SOCK_CLOSED if it is able to catch the
+Calling MPIDI_CH3I_Sock_write() during or after the call to MPIDI_CH3I_Sock_post_close() is consider to be an application error. The result
+of doing so is undefined, although the implementation may choose to return MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED if it is able to catch the
error. The application should coordinate the closing of a sock with the activities of other threads to ensure that one thread is
not attempting to perform an immediate write while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len, size_t * num_written);
+int MPIDI_CH3I_Sock_write(MPIDI_CH3I_Sock_t sock, void * buf, size_t len, size_t * num_written);
/*@
-MPIDU_Sock_writev - perform an immediate vector write
+MPIDI_CH3I_Sock_writev - perform an immediate vector write
Input Parameters:
+ sock - sock object to which data is to be written
@@ -1025,44 +1025,44 @@ Output Parameter:
Return value: a MPI error code with a Sock extended error class
+ MPI_SUCCESS - no error encountered during the write operation
-. MPIDU_SOCK_ERR_INIT - Sock module not initialized
-. MPIDU_SOCK_ERR_BAD_SOCK - invalid sock object
-. MPIDU_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
-. MPIDU_SOCK_ERR_BAD_LEN - iov_n parameter must be greater than zero and not greater than MPL_IOV_LIMIT
-. MPIDU_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
-. MPIDU_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
-. MPIDU_SOCK_ERR_CONN_FAILED - the connection failed
-. MPIDU_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
-. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory
-- MPIDU_SOCK_ERR_FAIL - other error attempting to perform the write
+. MPIDI_CH3I_SOCK_ERR_INIT - Sock module not initialized
+. MPIDI_CH3I_SOCK_ERR_BAD_SOCK - invalid sock object
+. MPIDI_CH3I_SOCK_ERR_BAD_BUF - using the buffer described by iov and iov_n resulted in a memory fault
+. MPIDI_CH3I_SOCK_ERR_BAD_LEN - iov_n parameter must be greater than zero and not greater than MPL_IOV_LIMIT
+. MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED - the sock object was closed locally
+. MPIDI_CH3I_SOCK_ERR_CONN_CLOSED - the connection was closed by the peer
+. MPIDI_CH3I_SOCK_ERR_CONN_FAILED - the connection failed
+. MPIDI_CH3I_SOCK_ERR_INPROGRESS - this operation overlapped with another like operation already in progress
+. MPIDI_CH3I_SOCK_ERR_NOMEM - unable to allocate required memory
+- MPIDI_CH3I_SOCK_ERR_FAIL - other error attempting to perform the write
Notes:
An immediate write may not be performed while a posted write is outstanding on the same sock. This is considered to be an
application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
Thread safety:
-MPIDU_Sock_write() may be called while another thread is attempting to perform an immediate read or post a read operation on the
-same sock. MPIDU_Sock_write() may also be called while another thread is calling or blocking in MPIDU_Sock_wait() on the same sock
+MPIDI_CH3I_Sock_write() may be called while another thread is attempting to perform an immediate read or post a read operation on the
+same sock. MPIDI_CH3I_Sock_write() may also be called while another thread is calling or blocking in MPIDI_CH3I_Sock_wait() on the same sock
set to which the specified sock belongs.
A immediate write may not be performed if another thread is performing an immediate write on the same sock. This is considered to
be an application error, and the results of doing so are undefined. The implementation may choose to catch the error and return
-MPIDU_SOCK_ERR_INPROGRESS, but it is not required to do so.
+MPIDI_CH3I_SOCK_ERR_INPROGRESS, but it is not required to do so.
-Calling MPIDU_Sock_write() during or after the call to MPIDU_Sock_post_close() is consider to be an application error. The result
-of doing so is undefined, although the implementation may choose to return MPIDU_SOCK_ERR_SOCK_CLOSED if it is able to catch the
+Calling MPIDI_CH3I_Sock_write() during or after the call to MPIDI_CH3I_Sock_post_close() is consider to be an application error. The result
+of doing so is undefined, although the implementation may choose to return MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED if it is able to catch the
error. The application should coordinate the closing of a sock with the activities of other threads to ensure that one thread is
not attempting to perform an immediate write while another thread is attempting to close the sock.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written);
+int MPIDI_CH3I_Sock_writev(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written);
/*@
-MPIDU_Sock_get_sock_id - get an integer identifier for a sock object
+MPIDI_CH3I_Sock_get_sock_id - get an integer identifier for a sock object
Input Parameter:
. sock - sock object
@@ -1078,11 +1078,11 @@ This function does not return an error code. Passing in an invalid sock object
Module:
Utility-Sock
@*/
-int MPIDU_Sock_get_sock_id(MPIDU_Sock_t sock);
+int MPIDI_CH3I_Sock_get_sock_id(MPIDI_CH3I_Sock_t sock);
/*@
-MPIDU_Sock_get_sock_set_id - get an integer identifier for a sock set object
+MPIDI_CH3I_Sock_get_sock_set_id - get an integer identifier for a sock set object
Input Parameter:
. sock set - sock set object
@@ -1100,11 +1100,11 @@ out).
Module:
Utility-Sock
@*/
-int MPIDU_Sock_get_sock_set_id(MPIDU_Sock_set_t set);
+int MPIDI_CH3I_Sock_get_sock_set_id(MPIDI_CH3I_Sock_set_t set);
/*@
-MPIDU_Sock_get_error_class_string - get a generic error string from an error code
+MPIDI_CH3I_Sock_get_error_class_string - get a generic error string from an error code
Input Parameter:
+ error - sock error
@@ -1122,9 +1122,9 @@ The returned string is the generic error message for the supplied error code.
Module:
Utility-Sock
@*/
-int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length);
+int MPIDI_CH3I_Sock_get_error_class_string(int error, char *error_string, size_t length);
CPLUSPLUS_END
-#endif /* !defined(MPIDU_SOCK_H_INCLUDED) */
+#endif /* !defined(MPIDI_CH3I_SOCK_H_INCLUDED) */
diff --git a/src/mpid/ch3/channels/sock/include/mpidu_socki.h b/src/mpid/ch3/channels/sock/include/mpidu_socki.h
index a50d8fc..cebf403 100644
--- a/src/mpid/ch3/channels/sock/include/mpidu_socki.h
+++ b/src/mpid/ch3/channels/sock/include/mpidu_socki.h
@@ -31,24 +31,24 @@ int gethostname(char *name, size_t len);
/* FIXME!!! */
#define SSIZE_MAX 65536
#endif
-#define MPIDU_SOCK_INFINITE_TIME -1
-#define MPIDU_SOCK_INVALID_SOCK NULL
-#define MPIDU_SOCK_INVALID_SET NULL
-#define MPIDU_SOCK_SIZE_MAX SSIZE_MAX
-#define MPIDU_SOCK_NATIVE_FD int
-
-typedef struct MPIDU_Sock_set * MPIDU_Sock_set_t;
-typedef struct MPIDU_Sock * MPIDU_Sock_t;
-typedef size_t MPIDU_Sock_size_t;
-
-#define MPIDU_SOCKI_STATE_LIST \
-MPID_STATE_MPIDU_SOCKI_READ, \
-MPID_STATE_MPIDU_SOCKI_WRITE, \
+#define MPIDI_CH3I_SOCK_INFINITE_TIME -1
+#define MPIDI_CH3I_SOCK_INVALID_SOCK NULL
+#define MPIDI_CH3I_SOCK_INVALID_SET NULL
+#define MPIDI_CH3I_SOCK_SIZE_MAX SSIZE_MAX
+#define MPIDI_CH3I_SOCK_NATIVE_FD int
+
+typedef struct MPIDI_CH3I_Sock_set * MPIDI_CH3I_Sock_set_t;
+typedef struct MPIDI_CH3I_Sock * MPIDI_CH3I_Sock_t;
+typedef size_t MPIDI_CH3I_Sock_size_t;
+
+#define MPIDI_CH3I_SOCKI_STATE_LIST \
+MPID_STATE_MPIDI_CH3I_SOCKI_READ, \
+MPID_STATE_MPIDI_CH3I_SOCKI_WRITE, \
MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC, \
MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE, \
-MPID_STATE_MPIDU_SOCKI_EVENT_ENQUEUE, \
-MPID_STATE_MPIDU_SOCKI_EVENT_DEQUEUE, \
-MPID_STATE_MPIDU_SOCKI_ADJUST_IOV, \
+MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE, \
+MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE, \
+MPID_STATE_MPIDI_CH3I_SOCKI_ADJUST_IOV, \
MPID_STATE_READ, \
MPID_STATE_READV, \
MPID_STATE_WRITE, \
@@ -56,7 +56,7 @@ MPID_STATE_WRITEV, \
MPID_STATE_POLL,
#if defined (MPL_USE_DBG_LOGGING)
-extern MPL_dbg_class MPIDU_DBG_SOCK_CONNECT;
+extern MPL_dbg_class MPIDI_CH3I_DBG_SOCK_CONNECT;
#endif /* MPL_USE_DBG_LOGGING */
#endif /* !defined(SOCKI_H_INCLUDED) */
diff --git a/src/mpid/ch3/channels/sock/src/ch3_isend.c b/src/mpid/ch3/channels/sock/src/ch3_isend.c
index 141b09e..a7c605f 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_isend.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_isend.c
@@ -61,7 +61,7 @@ int MPIDI_CH3_iSend(MPIDI_VC_t * vc, MPIR_Request * sreq, void * hdr,
/* MT: need some signalling to lock down our right to use the
channel, thus insuring that the progress engine does
also try to write */
- rc = MPIDU_Sock_write(vcch->sock, hdr, hdr_sz, &nb);
+ rc = MPIDI_CH3I_Sock_write(vcch->sock, hdr, hdr_sz, &nb);
if (rc == MPI_SUCCESS)
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
@@ -89,7 +89,7 @@ int MPIDI_CH3_iSend(MPIDI_VC_t * vc, MPIR_Request * sreq, void * hdr,
(MPL_DBG_FDEST,
"posting writev, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_writev(
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(
vcch->conn->sock, sreq->dev.iov,
sreq->dev.iov_count, NULL);
/* --BEGIN ERROR HANDLING-- */
@@ -112,7 +112,7 @@ int MPIDI_CH3_iSend(MPIDI_VC_t * vc, MPIR_Request * sreq, void * hdr,
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting write, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_write(vcch->conn->sock,
+ mpi_errno = MPIDI_CH3I_Sock_post_write(vcch->conn->sock,
sreq->dev.iov[0].MPL_IOV_BUF,
sreq->dev.iov[0].MPL_IOV_LEN,
sreq->dev.iov[0].MPL_IOV_LEN, NULL);
@@ -127,16 +127,16 @@ int MPIDI_CH3_iSend(MPIDI_VC_t * vc, MPIR_Request * sreq, void * hdr,
}
}
/* --BEGIN ERROR HANDLING-- */
- else if (MPIR_ERR_GET_CLASS(rc) == MPIDU_SOCK_ERR_NOMEM)
+ else if (MPIR_ERR_GET_CLASS(rc) == MPIDI_CH3I_SOCK_ERR_NOMEM)
{
MPL_DBG_MSG(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "MPIDU_Sock_write failed, out of memory");
+ "MPIDI_CH3I_Sock_write failed, out of memory");
sreq->status.MPI_ERROR = MPIR_ERR_MEMALLOCFAILED;
}
else
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "MPIDU_Sock_write failed, rc=%d", rc);
+ "MPIDI_CH3I_Sock_write failed, rc=%d", rc);
/* Connection just failed. Mark the request complete and
return an error. */
MPL_DBG_VCCHSTATECHANGE(vc,VC_STATE_FAILED);
diff --git a/src/mpid/ch3/channels/sock/src/ch3_isendv.c b/src/mpid/ch3/channels/sock/src/ch3_isendv.c
index 80ce60e..0188170 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_isendv.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_isendv.c
@@ -92,7 +92,7 @@ int MPIDI_CH3_iSendv(MPIDI_VC_t * vc, MPIR_Request * sreq,
Eventually it should be changed to agressively write
as much as possible. Ideally, the code would be shared between
the send routines and the progress engine. */
- rc = MPIDU_Sock_writev(vcch->sock, iov, n_iov, &nb);
+ rc = MPIDI_CH3I_Sock_writev(vcch->sock, iov, n_iov, &nb);
if (rc == MPI_SUCCESS)
{
int offset = 0;
@@ -116,7 +116,7 @@ int MPIDI_CH3_iSendv(MPIDI_VC_t * vc, MPIR_Request * sreq,
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting writev, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_writev(vcch->conn->sock,
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(vcch->conn->sock,
sreq->dev.iov + offset,
sreq->dev.iov_count - offset, NULL);
/* --BEGIN ERROR HANDLING-- */
@@ -153,7 +153,7 @@ int MPIDI_CH3_iSendv(MPIDI_VC_t * vc, MPIR_Request * sreq,
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting writev, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_writev(
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(
vcch->conn->sock, sreq->dev.iov,
sreq->dev.iov_count, NULL);
/* --BEGIN ERROR HANDLING-- */
@@ -169,16 +169,16 @@ int MPIDI_CH3_iSendv(MPIDI_VC_t * vc, MPIR_Request * sreq,
}
}
/* --BEGIN ERROR HANDLING-- */
- else if (MPIR_ERR_GET_CLASS(rc) == MPIDU_SOCK_ERR_NOMEM)
+ else if (MPIR_ERR_GET_CLASS(rc) == MPIDI_CH3I_SOCK_ERR_NOMEM)
{
MPL_DBG_MSG(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "MPIDU_Sock_writev failed, out of memory");
+ "MPIDI_CH3I_Sock_writev failed, out of memory");
sreq->status.MPI_ERROR = MPIR_ERR_MEMALLOCFAILED;
}
else
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "MPIDU_Sock_writev failed, rc=%d", rc);
+ "MPIDI_CH3I_Sock_writev failed, rc=%d", rc);
/* Connection just failed. Mark the request complete and
return an error. */
MPL_DBG_VCCHSTATECHANGE(vc,VC_STATE_FAILED);
diff --git a/src/mpid/ch3/channels/sock/src/ch3_istartmsg.c b/src/mpid/ch3/channels/sock/src/ch3_istartmsg.c
index ce68563..9a4384a 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_istartmsg.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_istartmsg.c
@@ -83,7 +83,7 @@ int MPIDI_CH3_iStartMsg(MPIDI_VC_t * vc, void * hdr, intptr_t hdr_sz,
/* MT: need some signalling to lock down our right to use the
channel, thus insuring that the progress engine does
not also try to write */
- rc = MPIDU_Sock_write(vcch->sock, hdr, hdr_sz, &nb);
+ rc = MPIDI_CH3I_Sock_write(vcch->sock, hdr, hdr_sz, &nb);
if (rc == MPI_SUCCESS)
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
@@ -108,7 +108,7 @@ int MPIDI_CH3_iStartMsg(MPIDI_VC_t * vc, void * hdr, intptr_t hdr_sz,
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting write, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_write(vcch->conn->sock, sreq->dev.iov[0].MPL_IOV_BUF,
+ mpi_errno = MPIDI_CH3I_Sock_post_write(vcch->conn->sock, sreq->dev.iov[0].MPL_IOV_BUF,
sreq->dev.iov[0].MPL_IOV_LEN, sreq->dev.iov[0].MPL_IOV_LEN, NULL);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
@@ -125,7 +125,7 @@ int MPIDI_CH3_iStartMsg(MPIDI_VC_t * vc, void * hdr, intptr_t hdr_sz,
else
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "ERROR - MPIDU_Sock_write failed, rc=%d", rc);
+ "ERROR - MPIDI_CH3I_Sock_write failed, rc=%d", rc);
sreq = MPIR_Request_create(MPIR_REQUEST_KIND__UNDEFINED);
if (!sreq) {
MPIR_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
diff --git a/src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c b/src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c
index 232ca90..d6132d8 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c
@@ -107,7 +107,7 @@ int MPIDI_CH3_iStartMsgv(MPIDI_VC_t * vc, MPL_IOV * iov, int n_iov,
/* MT - need some signalling to lock down our right to use the
channel, thus insuring that the progress engine does
also try to write */
- rc = MPIDU_Sock_writev(vcch->sock, iov, n_iov, &nb);
+ rc = MPIDI_CH3I_Sock_writev(vcch->sock, iov, n_iov, &nb);
if (rc == MPI_SUCCESS)
{
int offset = 0;
@@ -134,7 +134,7 @@ int MPIDI_CH3_iStartMsgv(MPIDI_VC_t * vc, MPL_IOV * iov, int n_iov,
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting writev, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
vcch->conn->send_active = sreq;
- mpi_errno = MPIDU_Sock_post_writev(vcch->conn->sock, sreq->dev.iov + offset,
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(vcch->conn->sock, sreq->dev.iov + offset,
sreq->dev.iov_count - offset, NULL);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
@@ -157,7 +157,7 @@ int MPIDI_CH3_iStartMsgv(MPIDI_VC_t * vc, MPL_IOV * iov, int n_iov,
else
{
MPL_DBG_MSG_D(MPIDI_CH3_DBG_CHANNEL,TYPICAL,
- "ERROR - MPIDU_Sock_writev failed, rc=%d", rc);
+ "ERROR - MPIDI_CH3I_Sock_writev failed, rc=%d", rc);
sreq = MPIR_Request_create(MPIR_REQUEST_KIND__UNDEFINED);
if (sreq == NULL) {
MPIR_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index 688dbce..0e8b2b0 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -37,8 +37,8 @@ volatile unsigned int MPIDI_CH3I_progress_completion_count = 0;
#endif
-MPIDU_Sock_set_t MPIDI_CH3I_sock_set = NULL;
-static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event);
+MPIDI_CH3I_Sock_set_t MPIDI_CH3I_sock_set = NULL;
+static int MPIDI_CH3I_Progress_handle_sock_event(MPIDI_CH3I_Sock_event_t * event);
static inline int connection_pop_sendq_req(MPIDI_CH3I_Connection_t * conn);
static inline int connection_post_recv_pkt(MPIDI_CH3I_Connection_t * conn);
@@ -61,7 +61,7 @@ static progress_hook_slot_t progress_hooks[MAX_PROGRESS_HOOKS];
#define FCNAME MPL_QUOTE(FUNCNAME)
static int MPIDI_CH3i_Progress_test(void)
{
- MPIDU_Sock_event_t event;
+ MPIDI_CH3I_Sock_event_t event;
int mpi_errno = MPI_SUCCESS;
int made_progress;
int i;
@@ -85,7 +85,7 @@ static int MPIDI_CH3i_Progress_test(void)
* MT: Another thread is already blocking in poll. Right now,
* calls to the progress routines are effectively
* serialized by the device. The only way another thread may
- * enter this function is if MPIDU_Sock_wait() blocks. If
+ * enter this function is if MPIDI_CH3I_Sock_wait() blocks. If
* this changes, a flag other than MPIDI_CH3I_Progress_blocked
* may be required to determine if another thread is in
* the progress engine.
@@ -104,7 +104,7 @@ static int MPIDI_CH3i_Progress_test(void)
}
}
- mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set, 0, &event);
+ mpi_errno = MPIDI_CH3I_Sock_wait(MPIDI_CH3I_sock_set, 0, &event);
if (mpi_errno == MPI_SUCCESS)
{
@@ -114,7 +114,7 @@ static int MPIDI_CH3i_Progress_test(void)
"**ch3|sock|handle_sock_event");
}
}
- else if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDU_SOCK_ERR_TIMEOUT)
+ else if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDI_CH3I_SOCK_ERR_TIMEOUT)
{
mpi_errno = MPI_SUCCESS;
goto fn_exit;
@@ -138,7 +138,7 @@ static int MPIDI_CH3i_Progress_test(void)
#define FCNAME MPL_QUOTE(FUNCNAME)
static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
{
- MPIDU_Sock_event_t event;
+ MPIDI_CH3I_Sock_event_t event;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_WAIT);
@@ -175,7 +175,7 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
* MT: Another thread is already blocking in poll. Right now,
* calls to MPIDI_CH3_Progress_wait() are effectively
* serialized by the device. The only way another thread may
- * enter this function is if MPIDU_Sock_wait() blocks. If
+ * enter this function is if MPIDI_CH3I_Sock_wait() blocks. If
* this changes, a flag other than MPIDI_CH3I_Progress_blocked
* may be required to determine if another thread is in
* the progress engine.
@@ -212,25 +212,25 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
we write separate code for each possibility */
if (MPIR_ThreadInfo.isThreaded) {
MPIDI_CH3I_progress_blocked = TRUE;
- mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
- MPIDU_SOCK_INFINITE_TIME, &event);
+ mpi_errno = MPIDI_CH3I_Sock_wait(MPIDI_CH3I_sock_set,
+ MPIDI_CH3I_SOCK_INFINITE_TIME, &event);
MPIDI_CH3I_progress_blocked = FALSE;
MPIDI_CH3I_progress_wakeup_signalled = FALSE;
}
else {
- mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
- MPIDU_SOCK_INFINITE_TIME, &event);
+ mpi_errno = MPIDI_CH3I_Sock_wait(MPIDI_CH3I_sock_set,
+ MPIDI_CH3I_SOCK_INFINITE_TIME, &event);
}
# else
- mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
- MPIDU_SOCK_INFINITE_TIME, &event);
+ mpi_errno = MPIDI_CH3I_Sock_wait(MPIDI_CH3I_sock_set,
+ MPIDI_CH3I_SOCK_INFINITE_TIME, &event);
# endif
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
- MPIR_Assert(MPIR_ERR_GET_CLASS(mpi_errno) != MPIDU_SOCK_ERR_TIMEOUT);
+ MPIR_Assert(MPIR_ERR_GET_CLASS(mpi_errno) != MPIDI_CH3I_SOCK_ERR_TIMEOUT);
MPIR_ERR_SET(mpi_errno,MPI_ERR_OTHER,"**progress_sock_wait");
goto fn_fail;
}
@@ -288,7 +288,7 @@ int MPIDI_CH3_Connection_terminate(MPIDI_VC_t * vc)
MPL_DBG_CONNSTATECHANGE(vc,vcch->conn,CONN_STATE_CLOSING);
vcch->conn->state = CONN_STATE_CLOSING;
MPL_DBG_MSG(MPIDI_CH3_DBG_DISCONNECT,TYPICAL,"Closing sock (Post_close)");
- mpi_errno = MPIDU_Sock_post_close(vcch->sock);
+ mpi_errno = MPIDI_CH3I_Sock_post_close(vcch->sock);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -324,13 +324,13 @@ int MPIDI_CH3I_Progress_init(void)
# endif
MPIR_THREAD_CHECK_END;
- mpi_errno = MPIDU_Sock_init();
+ mpi_errno = MPIDI_CH3I_Sock_init();
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
/* create sock set */
- mpi_errno = MPIDU_Sock_create_set(&MPIDI_CH3I_sock_set);
+ mpi_errno = MPIDI_CH3I_Sock_create_set(&MPIDI_CH3I_sock_set);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -377,25 +377,25 @@ int MPIDI_CH3I_Progress_finalize(void)
/* Close open connections */
- MPIDU_Sock_close_open_sockets(MPIDI_CH3I_sock_set,(void**) &conn);
+ MPIDI_CH3I_Sock_close_open_sockets(MPIDI_CH3I_sock_set,(void**) &conn);
while (conn != NULL) {
conn->state = CONN_STATE_CLOSING;
mpi_errno = MPIDI_CH3_Sockconn_handle_close_event(conn);
if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
- MPIDU_Sock_close_open_sockets(MPIDI_CH3I_sock_set,(void**) &conn);
+ MPIDI_CH3I_Sock_close_open_sockets(MPIDI_CH3I_sock_set,(void**) &conn);
}
/*
* MT: in a multi-threaded environment, finalize() should signal any
- * thread(s) blocking on MPIDU_Sock_wait() and wait for
+ * thread(s) blocking on MPIDI_CH3I_Sock_wait() and wait for
* those * threads to complete before destroying the progress engine
* data structures.
*/
- MPIDU_Sock_destroy_set(MPIDI_CH3I_sock_set);
- MPIDU_Sock_finalize();
+ MPIDI_CH3I_Sock_destroy_set(MPIDI_CH3I_sock_set);
+ MPIDI_CH3I_Sock_finalize();
MPIR_THREAD_CHECK_BEGIN;
/* FIXME should be appropriately abstracted somehow */
@@ -425,7 +425,7 @@ int MPIDI_CH3I_Progress_finalize(void)
void MPIDI_CH3I_Progress_wakeup(void)
{
MPL_DBG_MSG(MPIDI_CH3_DBG_OTHER,TYPICAL,"progress_wakeup called");
- MPIDU_Sock_wakeup(MPIDI_CH3I_sock_set);
+ MPIDI_CH3I_Sock_wakeup(MPIDI_CH3I_sock_set);
}
#endif
@@ -443,7 +443,7 @@ int MPIDI_CH3_Get_business_card(int myRank, char *value, int length)
#define FUNCNAME MPIDI_CH3I_Progress_handle_sock_event
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
+static int MPIDI_CH3I_Progress_handle_sock_event(MPIDI_CH3I_Sock_event_t * event)
{
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_HANDLE_SOCK_EVENT);
@@ -454,7 +454,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
switch (event->op_type)
{
- case MPIDU_SOCK_OP_READ:
+ case MPIDI_CH3I_SOCK_OP_READ:
{
MPIDI_CH3I_Connection_t * conn =
(MPIDI_CH3I_Connection_t *) event->user_ptr;
@@ -474,7 +474,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
{
/* FIXME: the following should be handled by the close
protocol */
- if (MPIR_ERR_GET_CLASS(event->error) != MPIDU_SOCK_ERR_CONN_CLOSED) {
+ if (MPIR_ERR_GET_CLASS(event->error) != MPIDI_CH3I_SOCK_ERR_CONN_CLOSED) {
mpi_errno = event->error;
MPIR_ERR_POP(mpi_errno);
}
@@ -564,7 +564,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
/* END OF SOCK_OP_READ */
- case MPIDU_SOCK_OP_WRITE:
+ case MPIDI_CH3I_SOCK_OP_WRITE:
{
MPIDI_CH3I_Connection_t * conn =
(MPIDI_CH3I_Connection_t *) event->user_ptr;
@@ -612,7 +612,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
iovp = sreq->dev.iov;
- mpi_errno = MPIDU_Sock_writev(conn->sock, iovp, sreq->dev.iov_count, &nb);
+ mpi_errno = MPIDI_CH3I_Sock_writev(conn->sock, iovp, sreq->dev.iov_count, &nb);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
@@ -656,7 +656,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL,VERBOSE,
(MPL_DBG_FDEST,"posting writev, vc=%p, conn=%p, sreq=0x%08x",
conn->vc, conn, sreq->handle));
- mpi_errno = MPIDU_Sock_post_writev(conn->sock, iovp, sreq->dev.iov_count, NULL);
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(conn->sock, iovp, sreq->dev.iov_count, NULL);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
@@ -682,14 +682,14 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
}
/* END OF SOCK_OP_WRITE */
- case MPIDU_SOCK_OP_ACCEPT:
+ case MPIDI_CH3I_SOCK_OP_ACCEPT:
{
mpi_errno = MPIDI_CH3_Sockconn_handle_accept_event();
if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
break;
}
- case MPIDU_SOCK_OP_CONNECT:
+ case MPIDI_CH3I_SOCK_OP_CONNECT:
{
mpi_errno = MPIDI_CH3_Sockconn_handle_connect_event(
(MPIDI_CH3I_Connection_t *) event->user_ptr,
@@ -698,7 +698,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
break;
}
- case MPIDU_SOCK_OP_CLOSE:
+ case MPIDI_CH3I_SOCK_OP_CLOSE:
{
mpi_errno = MPIDI_CH3_Sockconn_handle_close_event(
(MPIDI_CH3I_Connection_t *) event->user_ptr );
@@ -706,7 +706,7 @@ static int MPIDI_CH3I_Progress_handle_sock_event(MPIDU_Sock_event_t * event)
break;
}
- case MPIDU_SOCK_OP_WAKEUP:
+ case MPIDI_CH3I_SOCK_OP_WAKEUP:
{
MPIDI_CH3_Progress_signal_completion();
/* MPIDI_CH3I_progress_completion_count++; */
@@ -809,7 +809,7 @@ static inline int connection_pop_sendq_req(MPIDI_CH3I_Connection_t * conn)
if (conn->send_active != NULL)
{
MPL_DBG_MSG_P(MPIDI_CH3_DBG_CONNECT,TYPICAL,"conn=%p: Posting message from connection send queue", conn );
- mpi_errno = MPIDU_Sock_post_writev(conn->sock, conn->send_active->dev.iov, conn->send_active->dev.iov_count, NULL);
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(conn->sock, conn->send_active->dev.iov, conn->send_active->dev.iov_count, NULL);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -833,7 +833,7 @@ static inline int connection_post_recv_pkt(MPIDI_CH3I_Connection_t * conn)
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_CONNECTION_POST_RECV_PKT);
- mpi_errno = MPIDU_Sock_post_read(conn->sock, &conn->pkt, sizeof(conn->pkt), sizeof(conn->pkt), NULL);
+ mpi_errno = MPIDI_CH3I_Sock_post_read(conn->sock, &conn->pkt, sizeof(conn->pkt), sizeof(conn->pkt), NULL);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_SET(mpi_errno,MPI_ERR_OTHER, "**fail");
}
@@ -887,7 +887,7 @@ static int ReadMoreData( MPIDI_CH3I_Connection_t * conn, MPIR_Request *rreq )
iovp = rreq->dev.iov;
- mpi_errno = MPIDU_Sock_readv(conn->sock, iovp,
+ mpi_errno = MPIDI_CH3I_Sock_readv(conn->sock, iovp,
rreq->dev.iov_count, &nb);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS) {
@@ -935,7 +935,7 @@ static int ReadMoreData( MPIDI_CH3I_Connection_t * conn, MPIR_Request *rreq )
(MPL_DBG_FDEST,"posting readv, vc=%p, rreq=0x%08x",
conn->vc, rreq->handle));
conn->recv_active = rreq;
- mpi_errno = MPIDU_Sock_post_readv(conn->sock, iovp, rreq->dev.iov_count, NULL);
+ mpi_errno = MPIDI_CH3I_Sock_post_readv(conn->sock, iovp, rreq->dev.iov_count, NULL);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS) {
mpi_errno = MPIR_Err_create_code(
diff --git a/src/mpid/ch3/channels/sock/src/sock.c b/src/mpid/ch3/channels/sock/src/sock.c
index c287ee6..9ec72fd 100644
--- a/src/mpid/ch3/channels/sock/src/sock.c
+++ b/src/mpid/ch3/channels/sock/src/sock.c
@@ -32,33 +32,33 @@
/* FIXME: What do these mean? Why is 32 a good size (e.g., is it because
32*32 = 1024 if these are bits in a 4-byte int? In that case, should
these be related to a maximum processor count or an OS-defined fd limit? */
-#if !defined(MPIDU_SOCK_SET_DEFAULT_SIZE)
-#define MPIDU_SOCK_SET_DEFAULT_SIZE 32
+#if !defined(MPIDI_CH3I_SOCK_SET_DEFAULT_SIZE)
+#define MPIDI_CH3I_SOCK_SET_DEFAULT_SIZE 32
#endif
-#if !defined(MPIDU_SOCK_EVENTQ_POOL_SIZE)
-#define MPIDU_SOCK_EVENTQ_POOL_SIZE 32
+#if !defined(MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE)
+#define MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE 32
#endif
-enum MPIDU_Socki_state
+enum MPIDI_CH3I_Socki_state
{
- MPIDU_SOCKI_STATE_FIRST = 0,
- MPIDU_SOCKI_STATE_CONNECTING,
- MPIDU_SOCKI_STATE_CONNECTED_RW,
- MPIDU_SOCKI_STATE_CONNECTED_RO,
- MPIDU_SOCKI_STATE_DISCONNECTED,
- MPIDU_SOCKI_STATE_CLOSING,
- MPIDU_SOCKI_STATE_LAST
+ MPIDI_CH3I_SOCKI_STATE_FIRST = 0,
+ MPIDI_CH3I_SOCKI_STATE_CONNECTING,
+ MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW,
+ MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO,
+ MPIDI_CH3I_SOCKI_STATE_DISCONNECTED,
+ MPIDI_CH3I_SOCKI_STATE_CLOSING,
+ MPIDI_CH3I_SOCKI_STATE_LAST
};
-enum MPIDU_Socki_type
+enum MPIDI_CH3I_Socki_type
{
- MPIDU_SOCKI_TYPE_FIRST = 0,
- MPIDU_SOCKI_TYPE_COMMUNICATION,
- MPIDU_SOCKI_TYPE_LISTENER,
- MPIDU_SOCKI_TYPE_INTERRUPTER,
- MPIDU_SOCKI_TYPE_LAST
+ MPIDI_CH3I_SOCKI_TYPE_FIRST = 0,
+ MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION,
+ MPIDI_CH3I_SOCKI_TYPE_LISTENER,
+ MPIDI_CH3I_SOCKI_TYPE_INTERRUPTER,
+ MPIDI_CH3I_SOCKI_TYPE_LAST
};
/*
@@ -89,13 +89,13 @@ enum MPIDU_Socki_type
struct pollinfo
{
int sock_id;
- struct MPIDU_Sock_set * sock_set;
+ struct MPIDI_CH3I_Sock_set * sock_set;
int elem;
- struct MPIDU_Sock * sock;
+ struct MPIDI_CH3I_Sock * sock;
int fd;
void * user_ptr;
- enum MPIDU_Socki_type type;
- enum MPIDU_Socki_state state;
+ enum MPIDI_CH3I_Socki_type type;
+ enum MPIDI_CH3I_Socki_state state;
int os_errno;
# ifdef MPICH_IS_THREADED
int pollfd_events;
@@ -117,7 +117,7 @@ struct pollinfo
} read;
int read_iov_flag;
size_t read_nb;
- MPIDU_Sock_progress_update_func_t read_progress_update_fn;
+ MPIDI_CH3I_Sock_progress_update_func_t read_progress_update_fn;
union
{
struct
@@ -135,17 +135,17 @@ struct pollinfo
} write;
int write_iov_flag;
size_t write_nb;
- MPIDU_Sock_progress_update_func_t write_progress_update_fn;
+ MPIDI_CH3I_Sock_progress_update_func_t write_progress_update_fn;
};
-struct MPIDU_Socki_eventq_elem
+struct MPIDI_CH3I_Socki_eventq_elem
{
- struct MPIDU_Sock_event event;
+ struct MPIDI_CH3I_Sock_event event;
int set_elem;
- struct MPIDU_Socki_eventq_elem * next;
+ struct MPIDI_CH3I_Socki_eventq_elem * next;
};
-struct MPIDU_Sock_set
+struct MPIDI_CH3I_Sock_set
{
int id;
@@ -163,8 +163,8 @@ struct MPIDU_Sock_set
struct pollinfo * pollinfos;
/* head and tail pointers for the event queue */
- struct MPIDU_Socki_eventq_elem * eventq_head;
- struct MPIDU_Socki_eventq_elem * eventq_tail;
+ struct MPIDI_CH3I_Socki_eventq_elem * eventq_head;
+ struct MPIDI_CH3I_Socki_eventq_elem * eventq_tail;
# ifdef MPICH_IS_THREADED
/* pointer to the pollfds array being actively used by a blocking poll();
@@ -180,86 +180,86 @@ struct MPIDU_Sock_set
int wakeup_posted;
/* sock and fds for the interrpter pipe */
- struct MPIDU_Sock * intr_sock;
+ struct MPIDI_CH3I_Sock * intr_sock;
int intr_fds[2];
# endif
};
-struct MPIDU_Sock
+struct MPIDI_CH3I_Sock
{
- struct MPIDU_Sock_set * sock_set;
+ struct MPIDI_CH3I_Sock_set * sock_set;
int elem;
};
/* FIXME: Why aren't these static */
-int MPIDU_Socki_initialized = 0;
+int MPIDI_CH3I_Socki_initialized = 0;
-static struct MPIDU_Socki_eventq_elem * MPIDU_Socki_eventq_pool = NULL;
+static struct MPIDI_CH3I_Socki_eventq_elem * MPIDI_CH3I_Socki_eventq_pool = NULL;
/* MT: needs to be atomically incremented */
-static int MPIDU_Socki_set_next_id = 0;
+static int MPIDI_CH3I_Socki_set_next_id = 0;
/* Prototypes for functions used only within the socket code. */
/* Set the buffer size on the socket fd from the environment variable
or other option; if "firm" is true, fail if the buffer size is not
successfully set */
-int MPIDU_Sock_SetSockBufferSize( int fd, int firm );
+int MPIDI_CH3I_Sock_SetSockBufferSize( int fd, int firm );
/* Get a string version of the address in ifaddr*/
-int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen );
+int MPIDI_CH3I_Sock_AddrToStr( MPIDI_CH3I_Sock_ifaddr_t *ifaddr, char *str, int maxlen );
/*********** socki_util.i ***********/
#ifdef MPICH_IS_THREADED
-static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set);
-int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *, int );
+static int MPIDI_CH3I_Socki_wakeup(struct MPIDI_CH3I_Sock_set * sock_set);
+int MPIDI_Sock_update_sock_set( struct MPIDI_CH3I_Sock_set *, int );
#endif
-static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo,
+static int MPIDI_CH3I_Socki_os_to_mpi_errno(struct pollinfo * pollinfo,
int os_errno, const char * fcname, int line, int * conn_failed);
-static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov,
+static int MPIDI_CH3I_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov,
const int count, int * const offsetp);
-static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set,
- struct MPIDU_Sock ** sockp);
-static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock);
+static int MPIDI_CH3I_Socki_sock_alloc(struct MPIDI_CH3I_Sock_set * sock_set,
+ struct MPIDI_CH3I_Sock ** sockp);
+static void MPIDI_CH3I_Socki_sock_free(struct MPIDI_CH3I_Sock * sock);
-static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo,
- enum MPIDU_Sock_op op,
+static int MPIDI_CH3I_Socki_event_enqueue(struct pollinfo * pollinfo,
+ enum MPIDI_CH3I_Sock_op op,
size_t num_bytes,
void * user_ptr, int error);
-static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set,
+static inline int MPIDI_CH3I_Socki_event_dequeue(struct MPIDI_CH3I_Sock_set * sock_set,
int * set_elem,
- struct MPIDU_Sock_event * eventp);
+ struct MPIDI_CH3I_Sock_event * eventp);
-static void MPIDU_Socki_free_eventq_mem(void);
+static void MPIDI_CH3I_Socki_free_eventq_mem(void);
-struct MPIDU_Socki_eventq_table
+struct MPIDI_CH3I_Socki_eventq_table
{
- struct MPIDU_Socki_eventq_elem elems[MPIDU_SOCK_EVENTQ_POOL_SIZE];
- struct MPIDU_Socki_eventq_table * next;
+ struct MPIDI_CH3I_Socki_eventq_elem elems[MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE];
+ struct MPIDI_CH3I_Socki_eventq_table * next;
};
-static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
+static struct MPIDI_CH3I_Socki_eventq_table *MPIDI_CH3I_Socki_eventq_table_head=NULL;
-#define MPIDU_Socki_sock_get_pollfd(sock_) (&(sock_)->sock_set->pollfds[(sock_)->elem])
-#define MPIDU_Socki_sock_get_pollinfo(sock_) (&(sock_)->sock_set->pollinfos[(sock_)->elem])
-#define MPIDU_Socki_pollinfo_get_pollfd(pollinfo_) (&(pollinfo_)->sock_set->pollfds[(pollinfo_)->elem])
+#define MPIDI_CH3I_Socki_sock_get_pollfd(sock_) (&(sock_)->sock_set->pollfds[(sock_)->elem])
+#define MPIDI_CH3I_Socki_sock_get_pollinfo(sock_) (&(sock_)->sock_set->pollinfos[(sock_)->elem])
+#define MPIDI_CH3I_Socki_pollinfo_get_pollfd(pollinfo_) (&(pollinfo_)->sock_set->pollfds[(pollinfo_)->elem])
/* Enqueue a new event. If the enqueue fails, generate an error and jump to
the fail_label_ */
-#define MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo_, op_, nb_, user_ptr_, event_mpi_errno_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo_, op_, nb_, user_ptr_, event_mpi_errno_, mpi_errno_, fail_label_) \
{ \
- mpi_errno_ = MPIDU_Socki_event_enqueue((pollinfo_), (op_), (nb_), (user_ptr_), (event_mpi_errno_)); \
+ mpi_errno_ = MPIDI_CH3I_Socki_event_enqueue((pollinfo_), (op_), (nb_), (user_ptr_), (event_mpi_errno_)); \
if (mpi_errno_ != MPI_SUCCESS) \
{ \
- mpi_errno_ = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, \
+ mpi_errno_ = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, \
"**sock|poll|eqfail", "**sock|poll|eqfail %d %d %d", \
pollinfo->sock_set->id, pollinfo->sock_id, (op_)); \
goto fail_label_; \
@@ -274,12 +274,12 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
runtime control of the thread level */
#ifndef MPICH_IS_THREADED
-# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
+# define MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
{ \
(pollfd_)->events |= (op_); \
(pollfd_)->fd = (pollinfo_)->fd; \
}
-# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
+# define MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
{ \
(pollfd_)->events &= ~(op_); \
(pollfd_)->revents &= ~(op_); \
@@ -290,7 +290,7 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
#else /* MPICH_IS_THREADED */
/* FIXME: Does this need a runtime check on whether threads are in use? */
-# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
+# define MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
{ \
(pollinfo_)->pollfd_events |= (op_); \
if ((pollinfo_)->sock_set->pollfds_active == NULL) \
@@ -301,10 +301,10 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
else \
{ \
(pollinfo_)->sock_set->pollfds_updated = TRUE; \
- MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
+ MPIDI_CH3I_Socki_wakeup((pollinfo_)->sock_set); \
} \
}
-# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
+# define MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
{ \
(pollinfo_)->pollfd_events &= ~(op_); \
if ((pollinfo_)->sock_set->pollfds_active == NULL) \
@@ -319,16 +319,16 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
else \
{ \
(pollinfo_)->sock_set->pollfds_updated = TRUE; \
- MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
+ MPIDI_CH3I_Socki_wakeup((pollinfo_)->sock_set); \
} \
}
#endif
-#define MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd_, pollinfo_, op_) ((pollfd_)->events & (op_))
+#define MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd_, pollinfo_, op_) ((pollfd_)->events & (op_))
/* FIXME: Low usage operations like this should be a function for
better readability, modularity, and code size */
-#define MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo_, os_errno_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_GET_SOCKET_ERROR(pollinfo_, os_errno_, mpi_errno_, fail_label_) \
{ \
int rc__; \
socklen_t sz__; \
@@ -340,13 +340,13 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
if (errno == ENOMEM || errno == ENOBUFS) \
{ \
mpi_errno_ = MPIR_Err_create_code( \
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**sock|osnomem", \
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM, "**sock|osnomem", \
"**sock|osnomem %s %d %d", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id); \
} \
else \
{ \
mpi_errno = MPIR_Err_create_code( \
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|oserror", \
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|oserror", \
"**sock|poll|oserror %s %d %d %d %s", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id, \
(os_errno_), MPIR_Strerror(os_errno_)); \
} \
@@ -362,91 +362,91 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
/* FIXME: Are these really optional? Based on their definitions, it looks
like they should only be used when debugging the code. */
#ifdef USE_SOCK_VERIFY
-#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno_, fail_label_) \
{ \
- if (MPIDU_Socki_initialized <= 0) \
+ if (MPIDI_CH3I_Socki_initialized <= 0) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_INIT, \
"**sock|uninit", NULL); \
goto fail_label_; \
} \
}
-#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_, mpi_errno_, fail_label_)
+#define MPIDI_CH3I_SOCKI_VALIDATE_SOCK_SET(sock_set_, mpi_errno_, fail_label_)
-#define MPIDU_SOCKI_VALIDATE_SOCK(sock_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock_, mpi_errno_, fail_label_) \
{ \
struct pollinfo * pollinfo__; \
\
if ((sock_) == NULL || (sock_)->sock_set == NULL || (sock_)->elem < 0 || \
(sock_)->elem >= (sock_)->sock_set->poll_array_elems) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|badsock", NULL); \
goto fail_label_; \
} \
\
- pollinfo__ = MPIDU_Socki_sock_get_pollinfo(sock_); \
+ pollinfo__ = MPIDI_CH3I_Socki_sock_get_pollinfo(sock_); \
\
- if (pollinfo__->type <= MPIDU_SOCKI_TYPE_FIRST || pollinfo__->type >= MPIDU_SOCKI_TYPE_INTERRUPTER || \
- pollinfo__->state <= MPIDU_SOCKI_STATE_FIRST || pollinfo__->state >= MPIDU_SOCKI_STATE_LAST) \
+ if (pollinfo__->type <= MPIDI_CH3I_SOCKI_TYPE_FIRST || pollinfo__->type >= MPIDI_CH3I_SOCKI_TYPE_INTERRUPTER || \
+ pollinfo__->state <= MPIDI_CH3I_SOCKI_STATE_FIRST || pollinfo__->state >= MPIDI_CH3I_SOCKI_STATE_LAST) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|badsock", NULL); \
goto fail_label_; \
} \
}
-#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_, mpi_errno_, fail_label_) \
{ \
- if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
+ if ((pollinfo_)->type == MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION) \
{ \
- if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
+ if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING) \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|notconnected", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, "**sock|notconnected", \
"**sock|notconnected %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
goto fail_label_; \
} \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED) \
+ else if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_DISCONNECTED) \
{ \
if ((pollinfo_)->os_errno == 0) \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
"**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
} \
else \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
"**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
(pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
} \
goto fail_label_; \
} \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
+ else if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_CLOSING) \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, "**sock|closing", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_INPROGRESS, "**sock|closing", \
"**sock|closing %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
\
goto fail_label_; \
} \
- else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW && (pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RO) \
+ else if ((pollinfo_)->state != MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW && (pollinfo_)->state != MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|badsock", NULL); \
goto fail_label_; \
} \
} \
- else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
+ else if ((pollinfo_)->type == MPIDI_CH3I_SOCKI_TYPE_LISTENER) \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|listener_read", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, "**sock|listener_read", \
"**sock|listener_read %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
\
goto fail_label_; \
@@ -454,52 +454,52 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
-#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_, mpi_errno_, fail_label_) \
{ \
- if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
+ if ((pollinfo_)->type == MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION) \
{ \
- if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
+ if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|notconnected", "**sock|notconnected %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
goto fail_label_; \
} \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED || (pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTED_RO) \
+ else if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_DISCONNECTED || (pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO) \
{ \
if ((pollinfo_)->os_errno == 0) \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
"**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
} \
else \
{ \
(mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
"**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
(pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
} \
goto fail_label_; \
} \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
+ else if ((pollinfo_)->state == MPIDI_CH3I_SOCKI_STATE_CLOSING) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_INPROGRESS, \
"**sock|closing", "**sock|closing %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
\
goto fail_label_; \
} \
- else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW) \
+ else if ((pollinfo_)->state != MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|badsock", NULL); \
goto fail_label_; \
} \
} \
- else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
+ else if ((pollinfo_)->type == MPIDI_CH3I_SOCKI_TYPE_LISTENER) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|listener_write", "**sock|listener_write %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
\
@@ -508,11 +508,11 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
-#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo_, mpi_errno_, fail_label_) \
{ \
if ((pollinfo_)->fd < 0) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, \
"**sock|badhandle", "**sock|poll|badhandle %d %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id, (pollinfo_)->fd); \
goto fail_label_; \
@@ -520,11 +520,11 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
{ \
- if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLIN)) \
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLIN)) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_INPROGRESS, \
"**sock|reads", "**sock|reads %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
goto fail_label_; \
@@ -532,11 +532,11 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
+#define MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
{ \
- if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLOUT)) \
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLOUT)) \
{ \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_INPROGRESS, \
"**sock|writes", "**sock|writes %d %d", \
(pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
goto fail_label_; \
@@ -544,14 +544,14 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
}
#else
/* Use minimal to no checking */
-#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_SOCK(sock_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_,pollinfo_,mpi_errno,fail_label_)
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_,pollinfo_,mpi_errno,fail_label_)
+#define MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VALIDATE_SOCK_SET(sock_set_,mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock_,mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd_,pollinfo_,mpi_errno,fail_label_)
+#define MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_,pollinfo_,mpi_errno,fail_label_)
#endif
@@ -559,13 +559,13 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
#ifdef MPICH_IS_THREADED
/*
- * MPIDU_Socki_wakeup()
+ * MPIDI_CH3I_Socki_wakeup()
*/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_wakeup
+#define FUNCNAME MPIDI_CH3I_Socki_wakeup
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set)
+static int MPIDI_CH3I_Socki_wakeup(struct MPIDI_CH3I_Sock_set * sock_set)
{
MPIR_THREAD_CHECK_BEGIN;
if (sock_set->wakeup_posted == FALSE)
@@ -587,15 +587,15 @@ static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set)
sock_set->wakeup_posted = TRUE;
}
MPIR_THREAD_CHECK_END;
- return MPIDU_SOCK_SUCCESS;
+ return MPIDI_CH3I_SOCK_SUCCESS;
}
-/* end MPIDU_Socki_wakeup() */
+/* end MPIDI_CH3I_Socki_wakeup() */
#undef FUNCNAME
#define FUNCNAME MPIDI_Sock_update_sock_set
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
+int MPIDI_Sock_update_sock_set( struct MPIDI_CH3I_Sock_set *sock_set,
int pollfds_active_elems )
{
int mpi_errno = MPI_SUCCESS;
@@ -641,44 +641,44 @@ int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
/*
- * MPIDU_Socki_os_to_mpi_errno()
+ * MPIDI_CH3I_Socki_os_to_mpi_errno()
*
* This routine assumes that no thread can change the state between state check before the nonblocking OS operation and the call
* to this routine.
*/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_os_to_mpi_errno
+#define FUNCNAME MPIDI_CH3I_Socki_os_to_mpi_errno
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
/* --BEGIN ERROR HANDLING-- */
-static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno, const char * fcname, int line, int * disconnected)
+static int MPIDI_CH3I_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno, const char * fcname, int line, int * disconnected)
{
int mpi_errno;
if (os_errno == ENOMEM || os_errno == ENOBUFS)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|osnomem", "**sock|poll|osnomem %d %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = FALSE;
}
else if (os_errno == EFAULT || os_errno == EINVAL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_BAD_BUF,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDI_CH3I_SOCK_ERR_BAD_BUF,
"**sock|badbuf", "**sock|poll|badbuf %d %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = FALSE;
}
else if (os_errno == EPIPE)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_CLOSED,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDI_CH3I_SOCK_ERR_CONN_CLOSED,
"**sock|connclosed", "**sock|poll|connclosed %d %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = TRUE;
}
else if (os_errno == ECONNRESET || os_errno == ENOTCONN || os_errno == ETIMEDOUT)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDI_CH3I_SOCK_ERR_CONN_FAILED,
"**sock|connfailed", "**sock|poll|connfailed %d %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
pollinfo->os_errno = os_errno;
@@ -696,7 +696,7 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
* longer valid and should not be modified. We indicate this by
* returning a fatal error.
*/
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_BAD_SOCK,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDI_CH3I_SOCK_ERR_BAD_SOCK,
"**sock|badsock", NULL);
*disconnected = FALSE;
}
@@ -710,7 +710,7 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
* we print an immediate message asking the user to report the errno
* so that we can plug the hole?
*/
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDI_CH3I_SOCK_ERR_CONN_FAILED,
"**sock|oserror", "**sock|poll|oserror %d %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
pollinfo->os_errno = os_errno;
@@ -720,11 +720,11 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
return mpi_errno;
}
/* --END ERROR HANDLING-- */
-/* end MPIDU_Socki_os_to_mpi_errno() */
+/* end MPIDI_CH3I_Socki_os_to_mpi_errno() */
/*
- * MPIDU_Socki_adjust_iov()
+ * MPIDI_CH3I_Socki_adjust_iov()
*
* Use the specified number of bytes (nb) to adjust the iovec and associated
* values. If the iovec has been consumed, return
@@ -737,10 +737,10 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
* consumed.
*/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_adjust_iov
+#define FUNCNAME MPIDI_CH3I_Socki_adjust_iov
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov, const int count, int * const offsetp)
+static int MPIDI_CH3I_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov, const int count, int * const offsetp)
{
int offset = *offsetp;
@@ -763,16 +763,16 @@ static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov, const int cou
*offsetp = offset;
return TRUE;
}
-/* end MPIDU_Socki_adjust_iov() */
+/* end MPIDI_CH3I_Socki_adjust_iov() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_sock_alloc
+#define FUNCNAME MPIDI_CH3I_Socki_sock_alloc
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU_Sock ** sockp)
+static int MPIDI_CH3I_Socki_sock_alloc(struct MPIDI_CH3I_Sock_set * sock_set, struct MPIDI_CH3I_Sock ** sockp)
{
- struct MPIDU_Sock * sock = NULL;
+ struct MPIDI_CH3I_Sock * sock = NULL;
int avail_elem;
struct pollfd * pollfds = NULL;
struct pollinfo * pollinfos = NULL;
@@ -782,11 +782,11 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC);
/* FIXME: Should this use the CHKPMEM macros (perm malloc)? */
- sock = MPL_malloc(sizeof(struct MPIDU_Sock));
+ sock = MPL_malloc(sizeof(struct MPIDI_CH3I_Sock));
/* --BEGIN ERROR HANDLING-- */
if (sock == NULL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM, "**nomem", 0);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -815,20 +815,20 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
{
int elem;
- pollfds = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollfd));
+ pollfds = MPL_malloc((sock_set->poll_array_sz + MPIDI_CH3I_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollfd));
/* --BEGIN ERROR HANDLING-- */
if (pollfds == NULL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**nomem", 0);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
- pollinfos = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollinfo));
+ pollinfos = MPL_malloc((sock_set->poll_array_sz + MPIDI_CH3I_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollinfo));
/* --BEGIN ERROR HANDLING-- */
if (pollinfos == NULL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**nomem", 0);
goto fn_fail;
}
@@ -868,7 +868,7 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
}
sock_set->poll_array_elems = avail_elem + 1;
- sock_set->poll_array_sz += MPIDU_SOCK_SET_DEFAULT_SIZE;
+ sock_set->poll_array_sz += MPIDI_CH3I_SOCK_SET_DEFAULT_SIZE;
sock_set->pollfds = pollfds;
sock_set->pollinfos = pollinfos;
@@ -888,8 +888,8 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
pollinfos[elem].elem = elem;
pollinfos[elem].sock = NULL;
pollinfos[elem].sock_id = -1;
- pollinfos[elem].type = MPIDU_SOCKI_TYPE_FIRST;
- pollinfos[elem].state = MPIDU_SOCKI_STATE_FIRST;
+ pollinfos[elem].type = MPIDI_CH3I_SOCKI_TYPE_FIRST;
+ pollinfos[elem].state = MPIDI_CH3I_SOCKI_STATE_FIRST;
# ifdef MPICH_IS_THREADED
{
pollinfos[elem].pollfd_events = 0;
@@ -906,8 +906,8 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
MPIR_Assert(sock_set->pollinfos[avail_elem].fd == -1);
MPIR_Assert(sock_set->pollinfos[avail_elem].sock == NULL);
MPIR_Assert(sock_set->pollinfos[avail_elem].sock_id == -1);
- MPIR_Assert(sock_set->pollinfos[avail_elem].type == MPIDU_SOCKI_TYPE_FIRST);
- MPIR_Assert(sock_set->pollinfos[avail_elem].state == MPIDU_SOCKI_STATE_FIRST);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].type == MPIDI_CH3I_SOCKI_TYPE_FIRST);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].state == MPIDI_CH3I_SOCKI_STATE_FIRST);
# ifdef MPICH_IS_THREADED
{
MPIR_Assert(sock_set->pollinfos[avail_elem].pollfd_events == 0);
@@ -963,18 +963,18 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
goto fn_exit;
/* --END ERROR HANDLING-- */
}
-/* end MPIDU_Socki_sock_alloc() */
+/* end MPIDI_CH3I_Socki_sock_alloc() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_sock_free
+#define FUNCNAME MPIDI_CH3I_Socki_sock_free
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
+static void MPIDI_CH3I_Socki_sock_free(struct MPIDI_CH3I_Sock * sock)
{
- struct pollfd * pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- struct pollinfo * pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
- struct MPIDU_Sock_set * sock_set = sock->sock_set;
+ struct pollfd * pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ struct pollinfo * pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
+ struct MPIDI_CH3I_Sock_set * sock_set = sock->sock_set;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
@@ -1009,8 +1009,8 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
pollinfo->fd = -1;
pollinfo->sock = NULL;
pollinfo->sock_id = -1;
- pollinfo->type = MPIDU_SOCKI_TYPE_FIRST;
- pollinfo->state = MPIDU_SOCKI_STATE_FIRST;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_FIRST;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_FIRST;
# ifdef MPICH_IS_THREADED
{
pollinfo->pollfd_events = 0;
@@ -1031,34 +1031,34 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
}
-/* end MPIDU_Socki_sock_free() */
+/* end MPIDI_CH3I_Socki_sock_free() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_event_enqueue
+#define FUNCNAME MPIDI_CH3I_Socki_event_enqueue
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t op, size_t num_bytes,
+static int MPIDI_CH3I_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDI_CH3I_Sock_op_t op, size_t num_bytes,
void * user_ptr, int error)
{
- struct MPIDU_Sock_set * sock_set = pollinfo->sock_set;
- struct MPIDU_Socki_eventq_elem * eventq_elem;
+ struct MPIDI_CH3I_Sock_set * sock_set = pollinfo->sock_set;
+ struct MPIDI_CH3I_Socki_eventq_elem * eventq_elem;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
- if (MPIDU_Socki_eventq_pool != NULL)
+ if (MPIDI_CH3I_Socki_eventq_pool != NULL)
{
- eventq_elem = MPIDU_Socki_eventq_pool;
- MPIDU_Socki_eventq_pool = MPIDU_Socki_eventq_pool->next;
+ eventq_elem = MPIDI_CH3I_Socki_eventq_pool;
+ MPIDI_CH3I_Socki_eventq_pool = MPIDI_CH3I_Socki_eventq_pool->next;
}
else
{
int i;
- struct MPIDU_Socki_eventq_table *eventq_table;
+ struct MPIDI_CH3I_Socki_eventq_table *eventq_table;
- eventq_table = MPL_malloc(sizeof(struct MPIDU_Socki_eventq_table));
+ eventq_table = MPL_malloc(sizeof(struct MPIDI_CH3I_Socki_eventq_table));
/* --BEGIN ERROR HANDLING-- */
if (eventq_table == NULL)
{
@@ -1070,17 +1070,17 @@ static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t
eventq_elem = eventq_table->elems;
- eventq_table->next = MPIDU_Socki_eventq_table_head;
- MPIDU_Socki_eventq_table_head = eventq_table;
+ eventq_table->next = MPIDI_CH3I_Socki_eventq_table_head;
+ MPIDI_CH3I_Socki_eventq_table_head = eventq_table;
- if (MPIDU_SOCK_EVENTQ_POOL_SIZE > 1)
+ if (MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE > 1)
{
- MPIDU_Socki_eventq_pool = &eventq_elem[1];
- for (i = 0; i < MPIDU_SOCK_EVENTQ_POOL_SIZE - 2; i++)
+ MPIDI_CH3I_Socki_eventq_pool = &eventq_elem[1];
+ for (i = 0; i < MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE - 2; i++)
{
- MPIDU_Socki_eventq_pool[i].next = &MPIDU_Socki_eventq_pool[i+1];
+ MPIDI_CH3I_Socki_eventq_pool[i].next = &MPIDI_CH3I_Socki_eventq_pool[i+1];
}
- MPIDU_Socki_eventq_pool[MPIDU_SOCK_EVENTQ_POOL_SIZE - 2].next = NULL;
+ MPIDI_CH3I_Socki_eventq_pool[MPIDI_CH3I_SOCK_EVENTQ_POOL_SIZE - 2].next = NULL;
}
}
@@ -1104,16 +1104,16 @@ fn_exit:
MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
return mpi_errno;
}
-/* end MPIDU_Socki_event_enqueue() */
+/* end MPIDI_CH3I_Socki_event_enqueue() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_event_dequeue
+#define FUNCNAME MPIDI_CH3I_Socki_event_dequeue
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, int * set_elem, struct MPIDU_Sock_event * eventp)
+static inline int MPIDI_CH3I_Socki_event_dequeue(struct MPIDI_CH3I_Sock_set * sock_set, int * set_elem, struct MPIDI_CH3I_Sock_event * eventp)
{
- struct MPIDU_Socki_eventq_elem * eventq_elem;
+ struct MPIDI_CH3I_Socki_eventq_elem * eventq_elem;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE);
@@ -1132,43 +1132,43 @@ static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, in
*eventp = eventq_elem->event;
*set_elem = eventq_elem->set_elem;
- eventq_elem->next = MPIDU_Socki_eventq_pool;
- MPIDU_Socki_eventq_pool = eventq_elem;
+ eventq_elem->next = MPIDI_CH3I_Socki_eventq_pool;
+ MPIDI_CH3I_Socki_eventq_pool = eventq_elem;
}
/* --BEGIN ERROR HANDLING-- */
else
{
/* FIXME: Shouldn't this be an mpi error code? */
- mpi_errno = MPIDU_SOCK_ERR_FAIL;
+ mpi_errno = MPIDI_CH3I_SOCK_ERR_FAIL;
}
/* --END ERROR HANDLING-- */
MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE);
return mpi_errno;
}
-/* end MPIDU_Socki_event_dequeue() */
+/* end MPIDI_CH3I_Socki_event_dequeue() */
/* FIXME: Who allocates eventq tables? Should there be a check that these
tables are empty first? */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_free_eventq_mem
+#define FUNCNAME MPIDI_CH3I_Socki_free_eventq_mem
#undef FCNAME
-#define FCNAME "MPIDU_Socki_free_eventq_mem"
-static void MPIDU_Socki_free_eventq_mem(void)
+#define FCNAME "MPIDI_CH3I_Socki_free_eventq_mem"
+static void MPIDI_CH3I_Socki_free_eventq_mem(void)
{
- struct MPIDU_Socki_eventq_table *eventq_table, *eventq_table_next;
+ struct MPIDI_CH3I_Socki_eventq_table *eventq_table, *eventq_table_next;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
- eventq_table = MPIDU_Socki_eventq_table_head;
+ eventq_table = MPIDI_CH3I_Socki_eventq_table_head;
while (eventq_table) {
eventq_table_next = eventq_table->next;
MPL_free(eventq_table);
eventq_table = eventq_table_next;
}
- MPIDU_Socki_eventq_table_head = NULL;
+ MPIDI_CH3I_Socki_eventq_table_head = NULL;
MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
}
@@ -1181,7 +1181,7 @@ static int sockBufSize = -1;
/* Set the socket buffer sizes on fd to the standard values (this is controlled
by the parameter MPICH_SOCK_BUFSIZE). If "firm" is true, require that the
sockets actually accept that buffer size. */
-int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
+int MPIDI_CH3I_Sock_SetSockBufferSize( int fd, int firm )
{
int mpi_errno = MPI_SUCCESS;
int rc;
@@ -1194,7 +1194,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
if (rc <= 0) {
sockBufSize = 0;
}
- MPL_DBG_MSG_D(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Sock buf size = %d",sockBufSize);
+ MPL_DBG_MSG_D(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,"Sock buf size = %d",sockBufSize);
}
if (sockBufSize > 0) {
@@ -1205,7 +1205,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
bufsz_len = sizeof(bufsz);
rc = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, bufsz_len);
if (rc == -1) {
- MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|setsndbufsz",
"**sock|poll|setsndbufsz %d %d %s",
bufsz, errno, MPIR_Strerror(errno));
@@ -1214,7 +1214,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
bufsz_len = sizeof(bufsz);
rc = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, bufsz_len);
if (rc == -1) {
- MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|setrcvbufsz",
"**sock|poll|setrcvbufsz %d %d %s",
bufsz, errno, MPIR_Strerror(errno));
@@ -1249,7 +1249,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
}
/* This routine provides a string version of the address. */
-int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen )
+int MPIDI_CH3I_Sock_AddrToStr( MPIDI_CH3I_Sock_ifaddr_t *ifaddr, char *str, int maxlen )
{
int i;
unsigned char *p = ifaddr->ifaddr;
@@ -1269,56 +1269,56 @@ int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen )
/*********** sock_init.i *****************/
#if defined (MPL_USE_DBG_LOGGING)
-MPL_dbg_class MPIDU_DBG_SOCK_CONNECT;
+MPL_dbg_class MPIDI_CH3I_DBG_SOCK_CONNECT;
#endif /* MPL_USE_DBG_LOGGING */
/* FIXME: The usual missing documentation (what are these routines for?
preconditions? who calls? post conditions? */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_init
+#define FUNCNAME MPIDI_CH3I_Sock_init
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_init(void)
+int MPIDI_CH3I_Sock_init(void)
{
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_INIT);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_INIT);
#if defined (MPL_USE_DBG_LOGGING)
- MPIDU_DBG_SOCK_CONNECT = MPL_dbg_class_alloc("SOCK_CONNECT", "sock_connect");
+ MPIDI_CH3I_DBG_SOCK_CONNECT = MPL_dbg_class_alloc("SOCK_CONNECT", "sock_connect");
#endif
- MPIDU_Socki_initialized++;
+ MPIDI_CH3I_Socki_initialized++;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_INIT);
return MPI_SUCCESS;
}
/* FIXME: Who calls? When? Should this be a finalize handler instead? */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_finalize
+#define FUNCNAME MPIDI_CH3I_Sock_finalize
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_finalize(void)
+int MPIDI_CH3I_Sock_finalize(void)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_FINALIZE);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_FINALIZE);
- MPIDU_Socki_initialized--;
+ MPIDI_CH3I_Socki_initialized--;
- if (MPIDU_Socki_initialized == 0)
+ if (MPIDI_CH3I_Socki_initialized == 0)
{
- MPIDU_Socki_free_eventq_mem();
+ MPIDI_CH3I_Socki_free_eventq_mem();
}
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_FINALIZE);
return mpi_errno;
}
@@ -1327,33 +1327,33 @@ int MPIDU_Sock_finalize(void)
/*********** sock_set.i *****************/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_create_set
+#define FUNCNAME MPIDI_CH3I_Sock_create_set
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
+int MPIDI_CH3I_Sock_create_set(struct MPIDI_CH3I_Sock_set ** sock_setp)
{
- struct MPIDU_Sock_set * sock_set = NULL;
+ struct MPIDI_CH3I_Sock_set * sock_set = NULL;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_CREATE_SET);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_CREATE_SET);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/*
* Allocate and initialized a new sock set structure
*/
- sock_set = MPL_malloc(sizeof(struct MPIDU_Sock_set));
+ sock_set = MPL_malloc(sizeof(struct MPIDI_CH3I_Sock_set));
/* --BEGIN ERROR HANDLING-- */
if (sock_set == NULL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|setalloc", 0);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
- sock_set->id = MPIDU_Socki_set_next_id++;
+ sock_set->id = MPIDI_CH3I_Socki_set_next_id++;
sock_set->poll_array_sz = 0;
sock_set->poll_array_elems = 0;
sock_set->starting_elem = 0;
@@ -1378,7 +1378,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
# ifdef MPICH_IS_THREADED
MPIR_THREAD_CHECK_BEGIN;
{
- struct MPIDU_Sock * sock = NULL;
+ struct MPIDI_CH3I_Sock * sock = NULL;
struct pollfd * pollfd;
struct pollinfo * pollinfo;
long flags;
@@ -1393,14 +1393,14 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
* succeed or the system will lock up. Should the blocking descriptor
* prove to be a problem, then (1) copy the above
* code, applying it to the write descriptor, and (2) update
- * MPIDU_Socki_wakeup() so that it loops while write returns 0,
+ * MPIDI_CH3I_Socki_wakeup() so that it loops while write returns 0,
* performing a thread yield between iterations.
*/
rc = pipe(sock_set->intr_fds);
/* --BEGIN ERROR HANDLING-- */
if (rc != 0)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|pipe", "**sock|poll|pipe %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1410,7 +1410,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
/* --BEGIN ERROR HANDLING-- */
if (flags == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
errno, MPIR_Strerror(errno));
goto fn_fail;
@@ -1421,7 +1421,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
errno, MPIR_Strerror(errno));
goto fn_fail;
@@ -1431,11 +1431,11 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
/*
* Allocate and initialize a sock structure for the interrupter pipe
*/
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ mpi_errno = MPIDI_CH3I_Socki_sock_alloc(sock_set, &sock);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|sockalloc", NULL);
goto fn_fail;
}
@@ -1443,17 +1443,17 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
sock_set->intr_sock = sock;
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
pollfd->fd = sock_set->intr_fds[0];
pollinfo->fd = sock_set->intr_fds[0];
pollinfo->user_ptr = NULL;
- pollinfo->type = MPIDU_SOCKI_TYPE_INTERRUPTER;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_INTERRUPTER;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
pollinfo->os_errno = 0;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
}
MPIR_THREAD_CHECK_END;
# endif
@@ -1461,7 +1461,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
*sock_setp = sock_set;
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_CREATE_SET);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -1492,26 +1492,26 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_close_open_sockets
+#define FUNCNAME MPIDI_CH3I_Sock_close_open_sockets
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_ptr ){
+int MPIDI_CH3I_Sock_close_open_sockets(struct MPIDI_CH3I_Sock_set * sock_set, void** user_ptr ){
int i;
int mpi_errno = MPI_SUCCESS;
struct pollinfo * pollinfos = NULL;
pollinfos = sock_set->pollinfos;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_CLOSE_OPEN_SOCKETS);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_CLOSE_OPEN_SOCKETS);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* wakeup waiting socket if mullti-threades */
*user_ptr = NULL;
for (i = 0; i < sock_set->poll_array_elems; i++) {
- if(pollinfos[i].sock != NULL && pollinfos[i].type != MPIDU_SOCKI_TYPE_INTERRUPTER){
+ if(pollinfos[i].sock != NULL && pollinfos[i].type != MPIDI_CH3I_SOCKI_TYPE_INTERRUPTER){
close(pollinfos[i].fd);
- MPIDU_Socki_sock_free(pollinfos[i].sock);
+ MPIDI_CH3I_Socki_sock_free(pollinfos[i].sock);
*user_ptr = pollinfos[i].user_ptr;
break;
}
@@ -1519,25 +1519,25 @@ int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_CLOSE_OPEN_SOCKETS);
return mpi_errno;
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_destroy_set
+#define FUNCNAME MPIDI_CH3I_Sock_destroy_set
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
+int MPIDI_CH3I_Sock_destroy_set(struct MPIDI_CH3I_Sock_set * sock_set)
{
int elem;
- struct MPIDU_Sock_event event;
+ struct MPIDI_CH3I_Sock_event event;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_DESTROY_SET);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_DESTROY_SET);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/*
* FIXME: check for open socks and return an error if any are found
@@ -1556,7 +1556,7 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
{
close(sock_set->intr_fds[1]);
close(sock_set->intr_fds[0]);
- MPIDU_Socki_sock_free(sock_set->intr_sock);
+ MPIDI_CH3I_Socki_sock_free(sock_set->intr_sock);
sock_set->pollfds_updated = FALSE;
sock_set->pollfds_active = NULL;
@@ -1571,7 +1571,7 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
/*
* Clear the event queue to eliminate memory leaks
*/
- while (MPIDU_Socki_event_dequeue(sock_set, &elem, &event) == MPI_SUCCESS);
+ while (MPIDI_CH3I_Socki_event_dequeue(sock_set, &elem, &event) == MPI_SUCCESS);
/*
* Free structures used by the sock set
@@ -1599,7 +1599,7 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_DESTROY_SET);
return mpi_errno;
}
@@ -1608,7 +1608,7 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
/*********** sock_post.i *****************/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_connect_ifaddr
+#define FUNCNAME MPIDI_CH3I_Sock_post_connect_ifaddr
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
/*
@@ -1621,20 +1621,20 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
a four-byte field, it is currently restricted to ipv4. This routine should
evolve to support ipv4 and ipv6 addresses.
- This routine was constructed from MPIDU_Sock_post_connect by removing the
+ This routine was constructed from MPIDI_CH3I_Sock_post_connect by removing the
poorly placed use of gethostname within the middle of that routine and
simply using the ifaddr field that is passed to this routine.
- MPIDU_Sock_post_connect simply uses the hostname field to get the canonical
+ MPIDI_CH3I_Sock_post_connect simply uses the hostname field to get the canonical
IP address. The original routine and its API was retained to allow backwards
compatibility until it is determined that we can always use explicit addrs
needed in setting up the socket instead of character strings.
*/
-int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
+int MPIDI_CH3I_Sock_post_connect_ifaddr( struct MPIDI_CH3I_Sock_set * sock_set,
void * user_ptr,
- MPIDU_Sock_ifaddr_t *ifaddr, int port,
- struct MPIDU_Sock ** sockp)
+ MPIDI_CH3I_Sock_ifaddr_t *ifaddr, int port,
+ struct MPIDI_CH3I_Sock ** sockp)
{
- struct MPIDU_Sock * sock = NULL;
+ struct MPIDI_CH3I_Sock * sock = NULL;
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int fd = -1;
@@ -1643,11 +1643,11 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
int nodelay;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_CONNECT_IFADDR);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_CONNECT_IFADDR);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/*
* Create a non-blocking socket with Nagle's algorithm disabled
@@ -1658,20 +1658,20 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
clue for system error messages (e.g., %dSE; in the recommended
revision for error reporting (that is, value (errno) is an int,
but should be interpreted as an System Error string) */
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|socket",
"**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
}
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1) {
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock",
"**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
}
rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
if (rc == -1) {
- MPIR_ERR_SETANDJUMP2( mpi_errno, MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP2( mpi_errno, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock",
"**sock|poll|nonblock %d %s",
errno, MPIR_Strerror(errno));
@@ -1680,7 +1680,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
nodelay = 1;
rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
if (rc != 0) {
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nodelay",
"**sock|poll|nodelay %d %s",
errno, MPIR_Strerror(errno));
@@ -1695,19 +1695,19 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
* repetitive POLLHUP events when the connection is closed by
* the remote process.
*/
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ mpi_errno = MPIDI_CH3I_Socki_sock_alloc(sock_set, &sock);
if (mpi_errno != MPI_SUCCESS) {
- MPIR_ERR_SETANDJUMP(mpi_errno,MPIDU_SOCK_ERR_NOMEM,
+ MPIR_ERR_SETANDJUMP(mpi_errno,MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|sockalloc");
}
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
pollinfo->fd = fd;
pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW;
pollinfo->os_errno = 0;
memset(&addr, 0, sizeof(addr));
@@ -1719,16 +1719,16 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
/*
* Set and verify the socket buffer size
*/
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ mpi_errno = MPIDI_CH3I_Sock_SetSockBufferSize( fd, 1 );
if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
/*
* Attempt to establish the connection
*/
- MPL_DBG_STMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,{
+ MPL_DBG_STMT(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,{
char addrString[64];
- MPIDU_Sock_AddrToStr( ifaddr, addrString, sizeof(addrString) );
- MPL_DBG_MSG_FMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,(MPL_DBG_FDEST,
+ MPIDI_CH3I_Sock_AddrToStr( ifaddr, addrString, sizeof(addrString) );
+ MPL_DBG_MSG_FMT(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,(MPL_DBG_FDEST,
"Connecting to %s:%d", addrString, port ));
})
@@ -1741,35 +1741,35 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
if (rc == 0)
{
/* connection succeeded */
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTED_RW for sock %p",sock);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPI_SUCCESS, mpi_errno, fn_fail);
+ MPL_DBG_MSG_P(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTED_RW for sock %p",sock);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW;
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CONNECT, 0, user_ptr, MPI_SUCCESS, mpi_errno, fn_fail);
}
/* --BEGIN ERROR HANDLING-- */
else if (errno == EINPROGRESS)
{
/* connection pending */
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTING for sock %p",sock);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTING;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+ MPL_DBG_MSG_P(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTING for sock %p",sock);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTING;
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
}
else
{
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_DISCONNECTED (failure in connect) for sock %p",sock);
+ MPL_DBG_MSG_P(MPIDI_CH3I_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_DISCONNECTED (failure in connect) for sock %p",sock);
pollinfo->os_errno = errno;
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
if (errno == ECONNREFUSED)
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_FAILED,
"**sock|connrefused", "**sock|poll|connrefused %d %d %s",
pollinfo->sock_set->id, pollinfo->sock_id, ""), mpi_errno, fn_fail);
}
else
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_FAILED,
"**sock|oserror", "**sock|poll|oserror %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, errno,
MPIR_Strerror(errno)), mpi_errno, fn_fail);
}
@@ -1779,7 +1779,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
*sockp = sock;
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_CONNECT_IFADDR);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -1791,7 +1791,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
if (sock != NULL)
{
- MPIDU_Socki_sock_free(sock);
+ MPIDI_CH3I_Socki_sock_free(sock);
}
goto fn_exit;
@@ -1801,15 +1801,15 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
/* FIXME: What does this routine do? Why does it take a host description
instead of an interface name or address? */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_connect
+#define FUNCNAME MPIDI_CH3I_Sock_post_connect
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_connect(struct MPIDU_Sock_set * sock_set, void * user_ptr,
+int MPIDI_CH3I_Sock_post_connect(struct MPIDI_CH3I_Sock_set * sock_set, void * user_ptr,
char * host_description, int port,
- struct MPIDU_Sock ** sockp)
+ struct MPIDI_CH3I_Sock ** sockp)
{
int mpi_errno = MPI_SUCCESS;
- MPIDU_Sock_ifaddr_t ifaddr;
+ MPIDI_CH3I_Sock_ifaddr_t ifaddr;
struct hostent * hostent;
/*
@@ -1835,25 +1835,25 @@ int MPIDU_Sock_post_connect(struct MPIDU_Sock_set * sock_set, void * user_ptr,
memcpy( ifaddr.ifaddr, (unsigned char *)hostent->h_addr_list[0], 4 );
ifaddr.len = 4;
ifaddr.type = AF_INET;
- mpi_errno = MPIDU_Sock_post_connect_ifaddr( sock_set, user_ptr,
+ mpi_errno = MPIDI_CH3I_Sock_post_connect_ifaddr( sock_set, user_ptr,
&ifaddr, port, sockp );
fn_exit:
return mpi_errno;
}
-/* end MPIDU_Sock_post_connect() */
+/* end MPIDI_CH3I_Sock_post_connect() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_listen
+#define FUNCNAME MPIDI_CH3I_Sock_listen
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
#ifndef USHRT_MAX
#define USHRT_MAX 65535 /* 2^16-1 */
#endif
-int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
- int * port, struct MPIDU_Sock ** sockp)
+int MPIDI_CH3I_Sock_listen(struct MPIDI_CH3I_Sock_set * sock_set, void * user_ptr,
+ int * port, struct MPIDI_CH3I_Sock ** sockp)
{
- struct MPIDU_Sock * sock;
+ struct MPIDI_CH3I_Sock * sock;
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int fd = -1;
@@ -1863,15 +1863,15 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
socklen_t addr_len;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_LISTEN);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_LISTEN);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (*port < 0 || *port > USHRT_MAX)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_PORT,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_PORT,
"**sock|badport", "**sock|badport %d", *port);
goto fn_exit;
}
@@ -1884,7 +1884,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (fd == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|socket", "**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1898,7 +1898,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|reuseaddr", "**sock|poll|reuseaddr %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1910,7 +1910,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (flags == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1919,7 +1919,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1963,7 +1963,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|bind", "**sock|poll|bind %d %d %s", *port, errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1972,7 +1972,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/*
* Set and verify the socket buffer size
*/
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ mpi_errno = MPIDI_CH3I_Sock_SetSockBufferSize( fd, 1 );
if (mpi_errno) { MPIR_ERR_POP( mpi_errno ); }
/*
@@ -1982,7 +1982,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|listen", "**sock|poll|listen %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -1997,7 +1997,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|getport", "**sock|poll|getport %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -2009,30 +2009,30 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
* blocking in poll(), that thread must be woke up
* long enough to pick up the addition of the listener socket.
*/
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ mpi_errno = MPIDI_CH3I_Socki_sock_alloc(sock_set, &sock);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|sockalloc", NULL);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
pollinfo->fd = fd;
pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_LISTENER;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_LISTENER;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
*sockp = sock;
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_LISTEN);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -2045,38 +2045,38 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
goto fn_exit;
/* --END ERROR HANDLING-- */
}
-/* end MPIDU_Sock_listen() */
+/* end MPIDI_CH3I_Sock_listen() */
/* FIXME: What does this function do? */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_read
+#define FUNCNAME MPIDI_CH3I_Sock_post_read
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
- MPIDU_Sock_progress_update_func_t fn)
+int MPIDI_CH3I_Sock_post_read(struct MPIDI_CH3I_Sock * sock, void * buf, size_t minlen, size_t maxlen,
+ MPIDI_CH3I_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_READ);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_READ);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (minlen < 1 || minlen > maxlen)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_LEN,
"**sock|badlen", "**sock|badlen %d %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
goto fn_exit;
@@ -2090,42 +2090,42 @@ int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, size_t minlen, si
pollinfo->read_nb = 0;
pollinfo->read_progress_update_fn = fn;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_READ);
return mpi_errno;
}
-/* end MPIDU_Sock_post_read() */
+/* end MPIDI_CH3I_Sock_post_read() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_readv
+#define FUNCNAME MPIDI_CH3I_Sock_post_readv
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
+int MPIDI_CH3I_Sock_post_readv(struct MPIDI_CH3I_Sock * sock, MPL_IOV * iov, int iov_n, MPIDI_CH3I_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_READV);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_READV);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_LEN,
"**sock|badiovn", "**sock|badiovn %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
goto fn_exit;
@@ -2139,43 +2139,43 @@ int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MP
pollinfo->read_nb = 0;
pollinfo->read_progress_update_fn = fn;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_READV);
return mpi_errno;
}
-/* end MPIDU_Sock_post_readv() */
+/* end MPIDI_CH3I_Sock_post_readv() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_write
+#define FUNCNAME MPIDI_CH3I_Sock_post_write
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
- MPIDU_Sock_progress_update_func_t fn)
+int MPIDI_CH3I_Sock_post_write(struct MPIDI_CH3I_Sock * sock, void * buf, size_t minlen, size_t maxlen,
+ MPIDI_CH3I_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITE);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITE);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (minlen < 1 || minlen > maxlen)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_LEN,
"**sock|badlen", "**sock|badlen %d %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
goto fn_exit;
@@ -2189,42 +2189,42 @@ int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, size_t minlen, s
pollinfo->write_nb = 0;
pollinfo->write_progress_update_fn = fn;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITE);
return mpi_errno;
}
-/* end MPIDU_Sock_post_write() */
+/* end MPIDI_CH3I_Sock_post_write() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_writev
+#define FUNCNAME MPIDI_CH3I_Sock_post_writev
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
+int MPIDI_CH3I_Sock_post_writev(struct MPIDI_CH3I_Sock * sock, MPL_IOV * iov, int iov_n, MPIDI_CH3I_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITEV);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITEV);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_LEN,
"**sock|badiovn", "**sock|badiovn %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
goto fn_exit;
@@ -2238,91 +2238,91 @@ int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, M
pollinfo->write_nb = 0;
pollinfo->write_progress_update_fn = fn;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_WRITEV);
return mpi_errno;
}
-/* end MPIDU_Sock_post_writev() */
+/* end MPIDI_CH3I_Sock_post_writev() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_close
+#define FUNCNAME MPIDI_CH3I_Sock_post_close
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
+int MPIDI_CH3I_Sock_post_close(struct MPIDI_CH3I_Sock * sock)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_POST_CLOSE);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_POST_CLOSE);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
- if (pollinfo->state == MPIDU_SOCKI_STATE_CLOSING)
+ if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CLOSING)
{
mpi_errno = MPIR_Err_create_code(
- mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|closing_already",
+ mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK, "**sock|closing_already",
"**sock|closing_already %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ if (pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION)
{
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN | POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN | POLLOUT))
{
/* --BEGIN ERROR HANDLING-- */
int event_mpi_errno;
event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_SOCK_CLOSED, "**sock|close_cancel",
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED, "**sock|close_cancel",
"**sock|close_cancel %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN))
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
MPI_SUCCESS, mpi_errno, fn_exit);
}
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
MPI_SUCCESS, mpi_errno, fn_exit);
}
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
/* --END ERROR HANDLING-- */
}
}
- else /* if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER) */
+ else /* if (pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_LISTENER) */
{
/*
* The event queue may contain an accept event which means that
- * MPIDU_Sock_accept() may be legally called after
- * MPIDU_Sock_post_close(). However, MPIDU_Sock_accept() must be
+ * MPIDI_CH3I_Sock_accept() may be legally called after
+ * MPIDI_CH3I_Sock_post_close(). However, MPIDI_CH3I_Sock_accept() must be
* called before the close event is return by
- * MPIDU_Sock_wait().
+ * MPIDI_CH3I_Sock_wait().
*/
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
}
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CLOSE, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_CLOSING;
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CLOSE, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CLOSING;
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_POST_CLOSE);
return mpi_errno;
}
@@ -2339,14 +2339,14 @@ int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
/* FIXME: What does this function do? What are its arguments?
It appears to execute a nonblocking accept call */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_accept
+#define FUNCNAME MPIDI_CH3I_Sock_accept
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
- struct MPIDU_Sock_set * sock_set, void * user_ptr,
- struct MPIDU_Sock ** sockp)
+int MPIDI_CH3I_Sock_accept(struct MPIDI_CH3I_Sock * listener,
+ struct MPIDI_CH3I_Sock_set * sock_set, void * user_ptr,
+ struct MPIDI_CH3I_Sock ** sockp)
{
- struct MPIDU_Sock * sock;
+ struct MPIDI_CH3I_Sock * sock;
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int fd = -1;
@@ -2356,32 +2356,32 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
int nodelay;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_ACCEPT);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_ACCEPT);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(listener, mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(listener, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(listener);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(listener);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(listener);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(listener);
/* --BEGIN ERROR HANDLING-- */
- if (pollinfo->type != MPIDU_SOCKI_TYPE_LISTENER)
+ if (pollinfo->type != MPIDI_CH3I_SOCKI_TYPE_LISTENER)
{
mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK,
"**sock|listener_bad_sock", "**sock|listener_bad_sock %d %d",
pollinfo->sock_set->id, pollinfo->sock_id);
goto fn_exit;
}
- if (pollinfo->state != MPIDU_SOCKI_STATE_CONNECTED_RO &&
- pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
+ if (pollinfo->state != MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO &&
+ pollinfo->state != MPIDI_CH3I_SOCKI_STATE_CLOSING)
{
mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK,
"**sock|listener_bad_state", "**sock|listener_bad_state %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->state);
goto fn_exit;
@@ -2398,13 +2398,13 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
test for EINTR */
fd = accept(pollinfo->fd, (struct sockaddr *) &addr, &addr_len);
- if (pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
+ if (pollinfo->state != MPIDI_CH3I_SOCKI_STATE_CLOSING)
{
/*
* Unless the listener sock is being closed, add it back into the
* poll list so that new connections will be detected.
*/
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
}
/* --BEGIN ERROR HANDLING-- */
@@ -2413,19 +2413,19 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
if (errno == EAGAIN || errno == EWOULDBLOCK)
{
mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NO_NEW_SOCK,
"**sock|nosock", NULL);
}
else if (errno == ENOBUFS || errno == ENOMEM)
{
mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|osnomem", NULL);
}
else if (errno == EBADF || errno == ENOTSOCK || errno == EOPNOTSUPP)
{
mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK,
"**sock|badhandle", "**sock|poll|badhandle %d %d %d",
pollinfo->sock_set->id, pollinfo->sock_id,
pollinfo->fd);
@@ -2433,7 +2433,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
else
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NO_NEW_SOCK,
"**sock|poll|accept", "**sock|poll|accept %d %s",
errno, MPIR_Strerror(errno));
}
@@ -2448,7 +2448,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
if (flags == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
errno, MPIR_Strerror(errno));
goto fn_fail;
@@ -2459,7 +2459,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
errno, MPIR_Strerror(errno));
goto fn_fail;
@@ -2472,7 +2472,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
if (rc != 0)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nodelay", "**sock|poll|nodelay %d %s",
errno, MPIR_Strerror(errno));
goto fn_fail;
@@ -2485,10 +2485,10 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
/* FIXME: Who sets the socket buffer size? Why isn't the test
made at that time? */
#if 1
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ mpi_errno = MPIDI_CH3I_Sock_SetSockBufferSize( fd, 1 );
if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
#else
- if (MPIDU_Socki_socket_bufsz > 0)
+ if (MPIDI_CH3I_Socki_socket_bufsz > 0)
{
int bufsz;
socklen_t bufsz_len;
@@ -2501,11 +2501,11 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
/* --BEGIN ERROR HANDLING-- */
if (rc == 0)
{
- if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
- bufsz < MPIDU_Socki_socket_bufsz * 1.0)
+ if (bufsz < MPIDI_CH3I_Socki_socket_bufsz * 0.9 ||
+ bufsz < MPIDI_CH3I_Socki_socket_bufsz * 1.0)
{
MPL_msg_printf("WARNING: send socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- MPIDU_Socki_socket_bufsz, bufsz);
+ MPIDI_CH3I_Socki_socket_bufsz, bufsz);
}
}
/* --END ERROR HANDLING-- */
@@ -2521,11 +2521,11 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
/* --BEGIN ERROR HANDLING-- */
if (rc == 0)
{
- if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
- bufsz < MPIDU_Socki_socket_bufsz * 1.0)
+ if (bufsz < MPIDI_CH3I_Socki_socket_bufsz * 0.9 ||
+ bufsz < MPIDI_CH3I_Socki_socket_bufsz * 1.0)
{
MPL_msg_printf("WARNING: receive socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- MPIDU_Socki_socket_bufsz, bufsz);
+ MPIDI_CH3I_Socki_socket_bufsz, bufsz);
}
}
/* --END ERROR HANDLING-- */
@@ -2540,29 +2540,29 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
* repetitive POLLHUP events when the connection is closed by
* the remote process.
*/
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ mpi_errno = MPIDI_CH3I_Socki_sock_alloc(sock_set, &sock);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|sockalloc", NULL);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
pollinfo->fd = fd;
pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW;
pollinfo->os_errno = 0;
*sockp = sock;
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_ACCEPT);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -2575,14 +2575,14 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
goto fn_exit;
/* --END ERROR HANDLING-- */
}
-/* end MPIDU_Sock_accept() */
+/* end MPIDI_CH3I_Sock_accept() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_read
+#define FUNCNAME MPIDI_CH3I_Sock_read
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
+int MPIDI_CH3I_Sock_read(MPIDI_CH3I_Sock_t sock, void * buf, size_t len,
size_t * num_read)
{
struct pollfd * pollfd;
@@ -2590,19 +2590,19 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
size_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_READ);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_READ);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
/* FIXME: multiple passes should be made if
len > SSIZE_MAX and nb == SSIZE_MAX */
@@ -2635,21 +2635,21 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
mpi_errno = MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
- MPIDU_SOCK_ERR_CONN_CLOSED,
+ MPIDI_CH3I_SOCK_ERR_CONN_CLOSED,
"**sock|connclosed", "**sock|connclosed %d %d",
pollinfo->sock_set->id, pollinfo->sock_id);
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
/* A write is posted on this connection. Enqueue an event for
the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE,
pollinfo->write_nb, pollinfo->user_ptr,
mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
else if (errno == EAGAIN || errno == EWOULDBLOCK)
{
@@ -2661,7 +2661,7 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
*num_read = 0;
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno,
+ mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno,
FCNAME, __LINE__, &disconnected);
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -2675,33 +2675,33 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
if (disconnected)
{
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
/* A write is posted on this connection. Enqueue an event
for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE,
pollinfo->write_nb, pollinfo->user_ptr,
mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_READ);
return mpi_errno;
}
-/* end MPIDU_Sock_read() */
+/* end MPIDI_CH3I_Sock_read() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_readv
+#define FUNCNAME MPIDI_CH3I_Sock_readv
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
+int MPIDI_CH3I_Sock_readv(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n,
size_t * num_read)
{
struct pollfd * pollfd;
@@ -2709,19 +2709,19 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_READV);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_READV);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
/*
* FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
@@ -2748,22 +2748,22 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
mpi_errno = MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
- MPIDU_SOCK_ERR_CONN_CLOSED,
+ MPIDI_CH3I_SOCK_ERR_CONN_CLOSED,
"**sock|connclosed", "**sock|connclosed %d %d",
pollinfo->sock_set->id, pollinfo->sock_id);
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
/* A write is posted on this connection. Enqueue an event
for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE,
pollinfo->write_nb, pollinfo->user_ptr,
mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
else if (errno == EAGAIN || errno == EWOULDBLOCK)
{
@@ -2775,7 +2775,7 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
*num_read = 0;
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
__LINE__, &disconnected);
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -2789,33 +2789,33 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
if (disconnected)
{
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
/* A write is posted on this connection. Enqueue an event
for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE,
pollinfo->write_nb, pollinfo->user_ptr,
mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_READV);
return mpi_errno;
}
-/* end MPIDU_Sock_readv() */
+/* end MPIDI_CH3I_Sock_readv() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_write
+#define FUNCNAME MPIDI_CH3I_Sock_write
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
+int MPIDI_CH3I_Sock_write(MPIDI_CH3I_Sock_t sock, void * buf, size_t len,
size_t * num_written)
{
struct pollfd * pollfd;
@@ -2823,19 +2823,19 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_WRITE);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_WRITE);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
/* FIXME: multiple passes should be made if len > SSIZE_MAX and nb == SSIZE_MAX */
if (len > SSIZE_MAX)
@@ -2866,7 +2866,7 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
*num_written = 0;
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
__LINE__, &disconnected);
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -2883,44 +2883,44 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
/*
* The connection is dead but data may still be in the socket
* buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
+ * MPIDI_CH3I_Sock_wait() clean things up.
*/
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
}
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_WRITE);
return mpi_errno;
}
-/* end MPIDU_Sock_write() */
+/* end MPIDI_CH3I_Sock_write() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_writev
+#define FUNCNAME MPIDI_CH3I_Sock_writev
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written)
+int MPIDI_CH3I_Sock_writev(MPIDI_CH3I_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_WRITEV);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_WRITEV);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
/*
* FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
@@ -2951,7 +2951,7 @@ int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_
*num_written = 0;
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
__LINE__, &disconnected);
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -2968,33 +2968,33 @@ int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_
/*
* The connection is dead but data may still be in the socket
* buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
+ * MPIDI_CH3I_Sock_wait() clean things up.
*/
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
}
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_WRITEV);
return mpi_errno;
}
-/* end MPIDU_Sock_writev() */
+/* end MPIDI_CH3I_Sock_writev() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wakeup
+#define FUNCNAME MPIDI_CH3I_Sock_wakeup
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
+int MPIDI_CH3I_Sock_wakeup(struct MPIDI_CH3I_Sock_set * sock_set)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_WAKEUP);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_WAKEUP);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
/* FIXME: We need (1) a standardized test for including multithreaded
code and (2) include support for user requests for a lower-level
@@ -3006,10 +3006,10 @@ int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
{
struct pollinfo * pollinfo;
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock_set->intr_sock);
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WAKEUP, 0, NULL,
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock_set->intr_sock);
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WAKEUP, 0, NULL,
mpi_errno, mpi_errno, fn_exit);
- MPIDU_Socki_wakeup(sock_set);
+ MPIDI_CH3I_Socki_wakeup(sock_set);
}
MPIR_THREAD_CHECK_END;
# endif
@@ -3017,10 +3017,10 @@ int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
#ifdef MPICH_IS_THREADED
fn_exit:
#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_WAKEUP);
return mpi_errno;
}
-/* end MPIDU_Sock_wakeup() */
+/* end MPIDI_CH3I_Sock_wakeup() */
/*********** end of sock_immed.i *****************/
@@ -3032,25 +3032,25 @@ int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
this picks one but even in the current code can pick a different
interface if a particular environment variable is set) . */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_host_description
+#define FUNCNAME MPIDI_CH3I_Sock_get_host_description
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_host_description(int myRank,
+int MPIDI_CH3I_Sock_get_host_description(int myRank,
char * host_description, int len)
{
char * env_hostname;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_GET_HOST_DESCRIPTION);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_GET_HOST_DESCRIPTION);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
if (len < 0)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_LEN,
"**sock|badhdmax", NULL);
goto fn_exit;
}
@@ -3078,7 +3078,7 @@ int MPIDU_Sock_get_host_description(int myRank,
/* --BEGIN ERROR HANDLING-- */
if (rc != 0)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_HOST,
"**sock|badhdlen", NULL);
}
/* --END ERROR HANDLING-- */
@@ -3090,17 +3090,17 @@ int MPIDU_Sock_get_host_description(int myRank,
{
if (errno == EINVAL)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_HOST,
"**sock|badhdlen", NULL);
}
else if (errno == EFAULT)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_HOST,
"**sock|badhdbuf", NULL);
}
else
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
}
}
@@ -3108,19 +3108,19 @@ int MPIDU_Sock_get_host_description(int myRank,
}
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_GET_HOST_DESCRIPTION);
return mpi_errno;
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_native_to_sock
+#define FUNCNAME MPIDI_CH3I_Sock_native_to_sock
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIVE_FD fd, void *user_ptr,
- struct MPIDU_Sock ** sockp)
+int MPIDI_CH3I_Sock_native_to_sock(struct MPIDI_CH3I_Sock_set * sock_set, MPIDI_CH3I_SOCK_NATIVE_FD fd, void *user_ptr,
+ struct MPIDI_CH3I_Sock ** sockp)
{
- struct MPIDU_Sock * sock = NULL;
+ struct MPIDI_CH3I_Sock * sock = NULL;
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int rc;
@@ -3130,28 +3130,28 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* allocate sock and poll structures */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ mpi_errno = MPIDI_CH3I_Socki_sock_alloc(sock_set, &sock);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|sockalloc", NULL);
goto fn_fail;
}
/* --END ERROR HANDLING-- */
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ pollfd = MPIDI_CH3I_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDI_CH3I_Socki_sock_get_pollinfo(sock);
/* set file descriptor to non-blocking */
flags = fcntl(fd, F_GETFL, 0);
/* --BEGIN ERROR HANDLING-- */
if (flags == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -3160,7 +3160,7 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
/* --BEGIN ERROR HANDLING-- */
if (rc == -1)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
@@ -3173,8 +3173,8 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
pollinfo->fd = fd;
pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ pollinfo->type = MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW;
*sockp = sock;
@@ -3186,7 +3186,7 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
fn_fail:
if (sock != NULL)
{
- MPIDU_Socki_sock_free(sock);
+ MPIDI_CH3I_Socki_sock_free(sock);
}
goto fn_exit;
@@ -3195,27 +3195,27 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_set_user_ptr
+#define FUNCNAME MPIDI_CH3I_Sock_set_user_ptr
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
+int MPIDI_CH3I_Sock_set_user_ptr(struct MPIDI_CH3I_Sock * sock, void * user_ptr)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_SET_USER_PTR);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_SET_USER_PTR);
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- if (sock != MPIDU_SOCK_INVALID_SOCK &&
- sock->sock_set != MPIDU_SOCK_INVALID_SET)
+ if (sock != MPIDI_CH3I_SOCK_INVALID_SOCK &&
+ sock->sock_set != MPIDI_CH3I_SOCK_INVALID_SET)
{
- MPIDU_Socki_sock_get_pollinfo(sock)->user_ptr = user_ptr;
+ MPIDI_CH3I_Socki_sock_get_pollinfo(sock)->user_ptr = user_ptr;
}
/* --BEGIN ERROR HANDLING-- */
else
{
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_BAD_SOCK,
"**sock|badsock", NULL);
}
/* --END ERROR HANDLING-- */
@@ -3223,27 +3223,27 @@ int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_SET_USER_PTR);
return mpi_errno;
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_id
+#define FUNCNAME MPIDI_CH3I_Sock_get_sock_id
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
+int MPIDI_CH3I_Sock_get_sock_id(struct MPIDI_CH3I_Sock * sock)
{
int id;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_ID);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_ID);
- if (sock != MPIDU_SOCK_INVALID_SOCK)
+ if (sock != MPIDI_CH3I_SOCK_INVALID_SOCK)
{
- if (sock->sock_set != MPIDU_SOCK_INVALID_SET)
+ if (sock->sock_set != MPIDI_CH3I_SOCK_INVALID_SET)
{
- id = MPIDU_Socki_sock_get_pollinfo(sock)->sock_id;
+ id = MPIDI_CH3I_Socki_sock_get_pollinfo(sock)->sock_id;
}
else
{
@@ -3255,22 +3255,22 @@ int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
id = -1;
}
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_ID);
return id;
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_set_id
+#define FUNCNAME MPIDI_CH3I_Sock_get_sock_set_id
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
+int MPIDI_CH3I_Sock_get_sock_set_id(struct MPIDI_CH3I_Sock_set * sock_set)
{
int id;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_SET_ID);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_SET_ID);
- if (sock_set != MPIDU_SOCK_INVALID_SET)
+ if (sock_set != MPIDI_CH3I_SOCK_INVALID_SET)
{
id = sock_set->id;
}
@@ -3279,7 +3279,7 @@ int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
id = -1;
}
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_GET_SOCK_SET_ID);
return id;
}
@@ -3293,73 +3293,73 @@ int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
existing MPI-2 features to extend MPI error classes and code, of to export
messages to non-MPI application */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_error_class_string
+#define FUNCNAME MPIDI_CH3I_Sock_get_error_class_string
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
/* --BEGIN ERROR HANDLING-- */
-int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length)
+int MPIDI_CH3I_Sock_get_error_class_string(int error, char *error_string, size_t length)
{
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_GET_ERROR_CLASS_STRING);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_GET_ERROR_CLASS_STRING);
switch (MPIR_ERR_GET_CLASS(error))
{
- case MPIDU_SOCK_ERR_FAIL:
+ case MPIDI_CH3I_SOCK_ERR_FAIL:
MPL_strncpy(error_string, "generic socket failure", length);
break;
- case MPIDU_SOCK_ERR_INIT:
+ case MPIDI_CH3I_SOCK_ERR_INIT:
MPL_strncpy(error_string, "socket module not initialized", length);
break;
- case MPIDU_SOCK_ERR_NOMEM:
+ case MPIDI_CH3I_SOCK_ERR_NOMEM:
MPL_strncpy(error_string, "not enough memory to complete the socket operation", length);
break;
- case MPIDU_SOCK_ERR_BAD_SET:
+ case MPIDI_CH3I_SOCK_ERR_BAD_SET:
MPL_strncpy(error_string, "invalid socket set", length);
break;
- case MPIDU_SOCK_ERR_BAD_SOCK:
+ case MPIDI_CH3I_SOCK_ERR_BAD_SOCK:
MPL_strncpy(error_string, "invalid socket", length);
break;
- case MPIDU_SOCK_ERR_BAD_HOST:
+ case MPIDI_CH3I_SOCK_ERR_BAD_HOST:
MPL_strncpy(error_string, "host description buffer not large enough", length);
break;
- case MPIDU_SOCK_ERR_BAD_HOSTNAME:
+ case MPIDI_CH3I_SOCK_ERR_BAD_HOSTNAME:
MPL_strncpy(error_string, "invalid host name", length);
break;
- case MPIDU_SOCK_ERR_BAD_PORT:
+ case MPIDI_CH3I_SOCK_ERR_BAD_PORT:
MPL_strncpy(error_string, "invalid port", length);
break;
- case MPIDU_SOCK_ERR_BAD_BUF:
+ case MPIDI_CH3I_SOCK_ERR_BAD_BUF:
MPL_strncpy(error_string, "invalid buffer", length);
break;
- case MPIDU_SOCK_ERR_BAD_LEN:
+ case MPIDI_CH3I_SOCK_ERR_BAD_LEN:
MPL_strncpy(error_string, "invalid length", length);
break;
- case MPIDU_SOCK_ERR_SOCK_CLOSED:
+ case MPIDI_CH3I_SOCK_ERR_SOCK_CLOSED:
MPL_strncpy(error_string, "socket closed", length);
break;
- case MPIDU_SOCK_ERR_CONN_CLOSED:
+ case MPIDI_CH3I_SOCK_ERR_CONN_CLOSED:
MPL_strncpy(error_string, "socket connection closed", length);
break;
- case MPIDU_SOCK_ERR_CONN_FAILED:
+ case MPIDI_CH3I_SOCK_ERR_CONN_FAILED:
MPL_strncpy(error_string, "socket connection failed", length);
break;
- case MPIDU_SOCK_ERR_INPROGRESS:
+ case MPIDI_CH3I_SOCK_ERR_INPROGRESS:
MPL_strncpy(error_string, "socket operation in progress", length);
break;
- case MPIDU_SOCK_ERR_TIMEOUT:
+ case MPIDI_CH3I_SOCK_ERR_TIMEOUT:
MPL_strncpy(error_string, "socket operation timed out", length);
break;
- case MPIDU_SOCK_ERR_INTR:
+ case MPIDI_CH3I_SOCK_ERR_INTR:
MPL_strncpy(error_string, "socket operation interrupted", length);
break;
- case MPIDU_SOCK_ERR_NO_NEW_SOCK:
+ case MPIDI_CH3I_SOCK_ERR_NO_NEW_SOCK:
MPL_strncpy(error_string, "no new connection available", length);
break;
default:
MPL_snprintf(error_string, length, "unknown socket error %d", error);
break;
}
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_GET_ERROR_CLASS_STRING);
return MPI_SUCCESS;
}
/* --END ERROR HANDLING-- */
@@ -3376,19 +3376,19 @@ int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t leng
#endif
-static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd,
+static int MPIDI_CH3I_Socki_handle_pollhup(struct pollfd * const pollfd,
struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd,
+static int MPIDI_CH3I_Socki_handle_pollerr(struct pollfd * const pollfd,
struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_read(struct pollfd * const pollfd,
+static int MPIDI_CH3I_Socki_handle_read(struct pollfd * const pollfd,
struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_write(struct pollfd * const pollfd,
+static int MPIDI_CH3I_Socki_handle_write(struct pollfd * const pollfd,
struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd,
+static int MPIDI_CH3I_Socki_handle_connect(struct pollfd * const pollfd,
struct pollinfo * const pollinfo);
/*
- * MPIDU_Sock_wait()
+ * MPIDI_CH3I_Sock_wait()
*
* NOTES:
*
@@ -3403,17 +3403,17 @@ static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd,
* coarse-grain critical section.
*/
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wait
+#define FUNCNAME MPIDI_CH3I_Sock_wait
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
- struct MPIDU_Sock_event * eventp)
+int MPIDI_CH3I_Sock_wait(struct MPIDI_CH3I_Sock_set * sock_set, int millisecond_timeout,
+ struct MPIDI_CH3I_Sock_event * eventp)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_WAIT);
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_POLL);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_WAIT);
for (;;)
{
@@ -3422,12 +3422,12 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
int n_elems;
int found_active_elem = FALSE;
- mpi_errno = MPIDU_Socki_event_dequeue(sock_set, &elem, eventp);
+ mpi_errno = MPIDI_CH3I_Socki_event_dequeue(sock_set, &elem, eventp);
if (mpi_errno == MPI_SUCCESS) {
struct pollinfo * pollinfo;
int flags;
- if (eventp->op_type != MPIDU_SOCK_OP_CLOSE)
+ if (eventp->op_type != MPIDI_CH3I_SOCK_OP_CLOSE)
{
break;
}
@@ -3439,7 +3439,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
* any data in the socket send buffer from being
* discarded. Instead close() will block until the buffer is
* flushed or the connection timeouts and is considered
- * lost. Theoretically, this could cause the MPIDU_Sock_wait() to
+ * lost. Theoretically, this could cause the MPIDI_CH3I_Sock_wait() to
* hang indefinitely; however, the calling code
* should ensure this will not happen by going through a shutdown
* protocol before posting a close operation.
@@ -3460,7 +3460,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
instead of the error specified in the event? */
close(pollinfo->fd);
- MPIDU_Socki_sock_free(pollinfo->sock);
+ MPIDI_CH3I_Socki_sock_free(pollinfo->sock);
break;
}
@@ -3557,14 +3557,14 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
}
else if (n_fds == 0)
{
- mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
+ mpi_errno = MPIDI_CH3I_SOCK_ERR_TIMEOUT;
goto fn_exit;
}
else if (errno == EINTR)
{
- if (millisecond_timeout != MPIDU_SOCK_INFINITE_TIME)
+ if (millisecond_timeout != MPIDI_CH3I_SOCK_INFINITE_TIME)
{
- mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
+ mpi_errno = MPIDI_CH3I_SOCK_ERR_TIMEOUT;
goto fn_exit;
}
@@ -3573,13 +3573,13 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
/* --BEGIN ERROR HANDLING-- */
else if (errno == ENOMEM || errno == EAGAIN)
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_NOMEM,
"**sock|osnomem", NULL);
goto fn_exit;
}
else
{
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL,
"**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
goto fn_exit;
}
@@ -3619,7 +3619,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
if (pollfd->revents & POLLNVAL)
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|badhandle",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|badhandle",
"**sock|poll|badhandle %d %d %d %d", pollinfo->sock_set->id, pollinfo->sock_id, pollfd->fd, pollinfo->fd);
goto fn_exit;
}
@@ -3627,7 +3627,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
/* --BEGIN ERROR HANDLING-- */
if (pollfd->revents & POLLHUP)
{
- mpi_errno = MPIDU_Socki_handle_pollhup(pollfd, pollinfo);
+ mpi_errno = MPIDI_CH3I_Socki_handle_pollhup(pollfd, pollinfo);
if (MPIR_Err_is_fatal(mpi_errno))
{
goto fn_exit;
@@ -3638,7 +3638,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
(POLLIN) and some are reported with POLLERR. */
if (pollfd->revents & POLLERR)
{
- mpi_errno = MPIDU_Socki_handle_pollerr(pollfd, pollinfo);
+ mpi_errno = MPIDI_CH3I_Socki_handle_pollerr(pollfd, pollinfo);
if (MPIR_Err_is_fatal(mpi_errno))
{
goto fn_exit;
@@ -3648,12 +3648,12 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
if (pollfd->revents & POLLIN)
{
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ if (pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION)
{
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW ||
- pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW ||
+ pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO)
{
- mpi_errno = MPIDU_Socki_handle_read(pollfd, pollinfo);
+ mpi_errno = MPIDI_CH3I_Socki_handle_read(pollfd, pollinfo);
/* --BEGIN ERROR HANDLING-- */
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -3665,20 +3665,20 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
"**sock|poll|unhandledstate %d", pollinfo->state);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
}
- else if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER)
+ else if (pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_LISTENER)
{
pollfd->events &= ~POLLIN;
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_ACCEPT, 0, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_ACCEPT, 0, pollinfo->user_ptr,
MPI_SUCCESS, mpi_errno, fn_exit);
}
- else if ((MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE) && pollinfo->type == MPIDU_SOCKI_TYPE_INTERRUPTER)
+ else if ((MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE) && pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_INTERRUPTER)
{
char c[16];
ssize_t nb;
@@ -3693,7 +3693,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
"**sock|poll|unhandledtype %d", pollinfo->type);
goto fn_exit;
}
@@ -3702,11 +3702,11 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
if (pollfd->revents & POLLOUT)
{
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ if (pollinfo->type == MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION)
{
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW)
{
- mpi_errno = MPIDU_Socki_handle_write(pollfd, pollinfo);
+ mpi_errno = MPIDI_CH3I_Socki_handle_write(pollfd, pollinfo);
/* --BEGIN ERROR HANDLING-- */
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -3714,9 +3714,9 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
}
/* --END ERROR HANDLING-- */
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING)
{
- mpi_errno = MPIDU_Socki_handle_connect(pollfd, pollinfo);
+ mpi_errno = MPIDI_CH3I_Socki_handle_connect(pollfd, pollinfo);
/* --BEGIN ERROR HANDLING-- */
if (MPIR_Err_is_fatal(mpi_errno))
{
@@ -3728,7 +3728,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
"**sock|poll|unhandledstate %d", pollinfo->state);
goto fn_exit;
}
@@ -3738,7 +3738,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
"**sock|poll|unhandledtype %d", pollinfo->type);
goto fn_exit;
}
@@ -3752,22 +3752,22 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
}
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_WAIT);
return mpi_errno;
}
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_pollhup
+#define FUNCNAME MPIDI_CH3I_Socki_handle_pollhup
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+static int MPIDI_CH3I_Socki_handle_pollhup(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLHUP);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLHUP);
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW)
{
/*
* If a write was posted then cancel it and generate an connection closed event. If a read is posted, it will be handled
@@ -3779,16 +3779,16 @@ static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct polli
int event_mpi_errno;
event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED,
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_CLOSED,
"**sock|connclosed", "**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
}
/* --END ERROR HANDLING-- */
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO)
{
/*
* If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
@@ -3798,62 +3798,62 @@ static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct polli
* data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
* list.
*/
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ MPIR_Assert(pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_DISCONNECTED)
{
/*
* We should never reach this state because pollfd->fd should be set to -1 if we are in the disconnected state.
*/
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
+ MPIR_Assert(pollinfo->state == MPIDI_CH3I_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING)
{
/*
* The process we were connecting to died. Let the POLLOUT handler deal with the error.
*/
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ MPIR_Assert(pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
pollfd->revents = POLLOUT;
}
/* --BEGIN ERROR HANDLING-- */
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
"**sock|poll|unhandledstate %d", pollinfo->state);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLHUP);
return mpi_errno;
}
-/* end MPIDU_Socki_handle_pollhup() */
+/* end MPIDI_CH3I_Socki_handle_pollhup() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_pollerr
+#define FUNCNAME MPIDI_CH3I_Socki_handle_pollerr
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+static int MPIDI_CH3I_Socki_handle_pollerr(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLERR);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLERR);
/* --BEGIN ERROR HANDLING-- */
- if (pollinfo->type != MPIDU_SOCKI_TYPE_COMMUNICATION)
+ if (pollinfo->type != MPIDI_CH3I_SOCKI_TYPE_COMMUNICATION)
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
"**sock|poll|unhandledtype %d", pollinfo->type);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW)
{
/*
* Stevens suggests that some older version of UNIX did not properly reset so_error, which could allow POLLERR to be
@@ -3869,9 +3869,9 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
int os_errno;
int event_mpi_errno;
- MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, os_errno, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_GET_SOCKET_ERROR(pollinfo, os_errno, mpi_errno, fn_exit);
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, os_errno, FCNAME, __LINE__, &disconnected);
+ event_mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, os_errno, FCNAME, __LINE__, &disconnected);
/* --BEGIN ERROR HANDLING-- */
if (MPIR_Err_is_fatal(event_mpi_errno))
{
@@ -3880,13 +3880,13 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
}
/* --END ERROR HANDLING-- */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
}
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO)
{
/*
* If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
@@ -3896,17 +3896,17 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
* data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
* list.
*/
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ MPIR_Assert(pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING)
{
/*
* The process we were connecting to died. Let the POLLOUT handler deal with the error.
*/
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ MPIR_Assert(pollinfo->state == MPIDI_CH3I_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
pollfd->revents = POLLOUT;
}
- else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
+ else if (pollinfo->state == MPIDI_CH3I_SOCKI_STATE_DISCONNECTED)
{
/* We are already disconnected! Why are we handling an error? */
MPIR_Assert(pollfd->fd == -1);
@@ -3915,32 +3915,32 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
else
{
mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
"**sock|poll|unhandledstate %d", pollinfo->state);
goto fn_exit;
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_POLLERR);
return mpi_errno;
}
-/* end MPIDU_Socki_handle_pollerr() */
+/* end MPIDI_CH3I_Socki_handle_pollerr() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_read
+#define FUNCNAME MPIDI_CH3I_Socki_handle_read
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+static int MPIDI_CH3I_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_READ);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_READ);
do
{
@@ -3968,14 +3968,14 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
pollinfo->read_nb += nb;
done = pollinfo->read_iov_flag ?
- MPIDU_Socki_adjust_iov(nb, pollinfo->read.iov.ptr, pollinfo->read.iov.count, &pollinfo->read.iov.offset) :
+ MPIDI_CH3I_Socki_adjust_iov(nb, pollinfo->read.iov.ptr, pollinfo->read.iov.count, &pollinfo->read.iov.offset) :
(pollinfo->read_nb >= pollinfo->read.buf.min);
if (done)
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
MPI_SUCCESS, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
}
}
/* --BEGIN ERROR HANDLING-- */
@@ -3984,18 +3984,18 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
int event_mpi_errno;
event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed",
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_CLOSED, "**sock|connclosed",
"**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
}
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
/* --END ERROR HANDLING-- */
@@ -4010,7 +4010,7 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
int disconnected;
int event_mpi_errno;
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
+ event_mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
if (MPIR_Err_is_fatal(event_mpi_errno))
{
/*
@@ -4024,42 +4024,42 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
if (disconnected)
{
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ if (MPIDI_CH3I_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_READ);
return mpi_errno;
}
-/* end MPIDU_Socki_handle_read() */
+/* end MPIDI_CH3I_Socki_handle_read() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_write
+#define FUNCNAME MPIDI_CH3I_Socki_handle_write
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+static int MPIDI_CH3I_Socki_handle_write(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_WRITE);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_WRITE);
do
{
@@ -4087,14 +4087,14 @@ static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinf
pollinfo->write_nb += nb;
done = pollinfo->write_iov_flag ?
- MPIDU_Socki_adjust_iov(nb, pollinfo->write.iov.ptr, pollinfo->write.iov.count, &pollinfo->write.iov.offset) :
+ MPIDI_CH3I_Socki_adjust_iov(nb, pollinfo->write.iov.ptr, pollinfo->write.iov.count, &pollinfo->write.iov.offset) :
(pollinfo->write_nb >= pollinfo->write.buf.min);
if (done)
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
MPI_SUCCESS, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
}
}
else if (errno == EAGAIN || errno == EWOULDBLOCK)
@@ -4108,7 +4108,7 @@ static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinf
int disconnected;
int event_mpi_errno;
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
+ event_mpi_errno = MPIDI_CH3I_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
if (MPIR_Err_is_fatal(event_mpi_errno))
{
/*
@@ -4119,69 +4119,69 @@ static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinf
goto fn_exit;
}
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
if (disconnected)
{
/*
* The connection is dead but data may still be in the socket buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
+ * MPIDI_CH3I_Sock_wait() clean things up.
*/
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RO;
}
}
/* --END ERROR HANDLING-- */
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_WRITE);
return mpi_errno;
}
-/* end MPIDU_Socki_handle_write() */
+/* end MPIDI_CH3I_Socki_handle_write() */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_connect
+#define FUNCNAME MPIDI_CH3I_Socki_handle_connect
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+static int MPIDI_CH3I_Socki_handle_connect(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
struct sockaddr_in addr;
socklen_t addr_len;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_CONNECT);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_CONNECT);
addr_len = sizeof(struct sockaddr_in);
rc = getpeername(pollfd->fd, (struct sockaddr *) &addr, &addr_len);
if (rc == 0)
{
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_CONNECTED_RW;
}
/* --BEGIN ERROR HANDLING-- */
else
{
int event_mpi_errno;
- MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, pollinfo->os_errno, mpi_errno, fn_exit);
+ MPIDI_CH3I_SOCKI_GET_SOCKET_ERROR(pollinfo, pollinfo->os_errno, mpi_errno, fn_exit);
event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed",
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDI_CH3I_SOCK_ERR_CONN_FAILED, "**sock|connfailed",
"**sock|poll|connfailed %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->os_errno,
MPIR_Strerror(pollinfo->os_errno));
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, event_mpi_errno, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ MPIDI_CH3I_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDI_CH3I_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, event_mpi_errno, mpi_errno, fn_exit);
+ pollinfo->state = MPIDI_CH3I_SOCKI_STATE_DISCONNECTED;
}
/* --END ERROR HANDLING-- */
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ MPIDI_CH3I_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_HANDLE_CONNECT);
return mpi_errno;
}
-/* end MPIDU_Socki_handle_connect() */
+/* end MPIDI_CH3I_Socki_handle_connect() */
/*********** end of sock_wait.i *****************/
diff --git a/src/mpid/ch3/util/sock/ch3u_connect_sock.c b/src/mpid/ch3/util/sock/ch3u_connect_sock.c
index 8feaf3b..7da3c86 100644
--- a/src/mpid/ch3/util/sock/ch3u_connect_sock.c
+++ b/src/mpid/ch3/util/sock/ch3u_connect_sock.c
@@ -88,16 +88,16 @@ static int MPIDI_CH3I_listener_port = 0;
static MPIDI_CH3I_Connection_t * MPIDI_CH3I_listener_conn = NULL;
/* Required for (socket version) upcall to Connect_to_root (see FIXME) */
-extern MPIDU_Sock_set_t MPIDI_CH3I_sock_set;
+extern MPIDI_CH3I_Sock_set_t MPIDI_CH3I_sock_set;
#undef FUNCNAME
#define FUNCNAME MPIDU_CH3I_SetupListener
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_CH3I_SetupListener( MPIDU_Sock_set_t sock_set )
+int MPIDU_CH3I_SetupListener( MPIDI_CH3I_Sock_set_t sock_set )
{
int mpi_errno = MPI_SUCCESS;
- MPIDU_Sock_t sock;
+ MPIDI_CH3I_Sock_t sock;
mpi_errno = MPIDI_CH3I_Connection_alloc(&MPIDI_CH3I_listener_conn);
if (mpi_errno != MPI_SUCCESS) {
@@ -112,7 +112,7 @@ int MPIDU_CH3I_SetupListener( MPIDU_Sock_set_t sock_set )
MPIDI_CH3I_listener_conn->send_active = NULL;
MPIDI_CH3I_listener_conn->recv_active = NULL;
- mpi_errno = MPIDU_Sock_listen(sock_set, MPIDI_CH3I_listener_conn,
+ mpi_errno = MPIDI_CH3I_Sock_listen(sock_set, MPIDI_CH3I_listener_conn,
&MPIDI_CH3I_listener_port, &sock);
if (mpi_errno) return mpi_errno;
@@ -134,7 +134,7 @@ int MPIDU_CH3I_ShutdownListener( void )
MPID_Progress_state progress_state;
MPL_DBG_MSG(MPIDI_CH3_DBG_DISCONNECT,TYPICAL,"Closing listener sock (Post_close)");
- mpi_errno = MPIDU_Sock_post_close(MPIDI_CH3I_listener_conn->sock);
+ mpi_errno = MPIDI_CH3I_Sock_post_close(MPIDI_CH3I_listener_conn->sock);
if (mpi_errno != MPI_SUCCESS) {
return mpi_errno;
}
@@ -214,7 +214,7 @@ int MPIDI_CH3I_Connect_to_root_sock(const char * port_name,
MPIR_CHKPMEM_DECL(1);
char host_description[MAX_HOST_DESCRIPTION_LEN];
int port, port_name_tag;
- MPIDU_Sock_ifaddr_t ifaddr;
+ MPIDI_CH3I_Sock_ifaddr_t ifaddr;
int hasIfaddr = 0;
MPIDI_CH3I_Connection_t * conn;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_CONNECT_TO_ROOT_SOCK);
@@ -236,7 +236,7 @@ int MPIDI_CH3I_Connect_to_root_sock(const char * port_name,
MPL_DBG_MSG_S(MPIDI_CH3_DBG_CONNECT,VERBOSE,"Connect to root with portstring %s",
port_name );
- mpi_errno = MPIDU_Sock_get_conninfo_from_bc( port_name, host_description,
+ mpi_errno = MPIDI_CH3I_Sock_get_conninfo_from_bc( port_name, host_description,
sizeof(host_description),
&port, &ifaddr, &hasIfaddr );
if (mpi_errno) {
@@ -264,7 +264,7 @@ int MPIDI_CH3I_Connect_to_root_sock(const char * port_name,
is the socket utility functions. */
MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CONNECT,VERBOSE,(MPL_DBG_FDEST,
"posting connect to host %s, port %d", host_description, port ));
- mpi_errno = MPIDU_Sock_post_connect(MPIDI_CH3I_sock_set, conn,
+ mpi_errno = MPIDI_CH3I_Sock_post_connect(MPIDI_CH3I_sock_set, conn,
host_description, port, &conn->sock);
if (mpi_errno == MPI_SUCCESS)
{
@@ -287,13 +287,13 @@ int MPIDI_CH3I_Connect_to_root_sock(const char * port_name,
/* --BEGIN ERROR HANDLING-- */
else
{
- if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDU_SOCK_ERR_BAD_HOST)
+ if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDI_CH3I_SOCK_ERR_BAD_HOST)
{
mpi_errno = MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**ch3|sock|badhost",
"**ch3|sock|badhost %s %d %s", conn->pg_id, conn->vc->pg_rank, port_name);
}
- else if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDU_SOCK_ERR_CONN_FAILED)
+ else if (MPIR_ERR_GET_CLASS(mpi_errno) == MPIDI_CH3I_SOCK_ERR_CONN_FAILED)
{
mpi_errno = MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**ch3|sock|connrefused",
@@ -329,12 +329,12 @@ int MPIDI_CH3I_Connect_to_root_sock(const char * port_name,
/* The host_description should be of length MAX_HOST_DESCRIPTION_LEN */
#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_conninfo_from_bc
+#define FUNCNAME MPIDI_CH3I_Sock_get_conninfo_from_bc
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_conninfo_from_bc( const char *bc,
+int MPIDI_CH3I_Sock_get_conninfo_from_bc( const char *bc,
char *host_description, int maxlen,
- int *port, MPIDU_Sock_ifaddr_t *ifaddr,
+ int *port, MPIDI_CH3I_Sock_ifaddr_t *ifaddr,
int *hasIfaddr )
{
int mpi_errno = MPI_SUCCESS;
@@ -342,9 +342,9 @@ int MPIDU_Sock_get_conninfo_from_bc( const char *bc,
#if !defined(HAVE_WINDOWS_H) && defined(HAVE_INET_PTON)
char ifname[256];
#endif
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_CONNINFO_FROM_BC);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCK_GET_CONNINFO_FROM_BC);
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_CONNINFO_FROM_BC);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCK_GET_CONNINFO_FROM_BC);
str_errno = MPL_str_get_string_arg(bc, MPIDI_CH3I_HOST_DESCRIPTION_KEY,
host_description, maxlen);
@@ -406,7 +406,7 @@ int MPIDU_Sock_get_conninfo_from_bc( const char *bc,
#endif
fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_CONNINFO_FROM_BC);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCK_GET_CONNINFO_FROM_BC);
return mpi_errno;
fn_fail:
goto fn_exit;
@@ -433,7 +433,7 @@ int MPIDI_CH3U_Get_business_card_sock(int myRank,
{
int mpi_errno = MPI_SUCCESS;
int str_errno = MPL_STR_SUCCESS;
- MPIDU_Sock_ifaddr_t ifaddr;
+ MPIDI_CH3I_Sock_ifaddr_t ifaddr;
char ifnamestr[MAX_HOST_DESCRIPTION_LEN];
char *bc_orig = *bc_val_p;
MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3U_GET_BUSINESS_CARD_SOCK);
@@ -462,7 +462,7 @@ int MPIDI_CH3U_Get_business_card_sock(int myRank,
/* FIXME: We don't make use of the ifname in Windows in order to
provide backward compatibility with the (undocumented) host
description string used by the socket connection routine
- MPIDU_Sock_post_connect. We need to change to an interface-address
+ MPIDI_CH3I_Sock_post_connect. We need to change to an interface-address
(already resolved) based description for better scalability and
to eliminate reliance on fragile DNS services. Note that this is
also more scalable, since the DNS server may serialize address
@@ -534,7 +534,7 @@ static int connection_post_send_pkt_and_pgid(MPIDI_CH3I_Connection_t * conn);
static int connection_post_sendq_req(MPIDI_CH3I_Connection_t * conn);
static void connection_destroy(MPIDI_CH3I_Connection_t * conn);
-/* This routine is called in response to an MPIDU_SOCK_OP_ACCEPT event
+/* This routine is called in response to an MPIDI_CH3I_SOCK_OP_ACCEPT event
in ch3_progress */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Sockconn_handle_accept_event
@@ -552,7 +552,7 @@ int MPIDI_CH3_Sockconn_handle_accept_event( void )
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
- mpi_errno = MPIDU_Sock_accept(MPIDI_CH3I_listener_conn->sock,
+ mpi_errno = MPIDI_CH3I_Sock_accept(MPIDI_CH3I_listener_conn->sock,
MPIDI_CH3I_sock_set, conn, &conn->sock);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**ch3|sock|accept");
@@ -663,7 +663,7 @@ int MPIDI_CH3_Sockconn_handle_close_event( MPIDI_CH3I_Connection_t * conn )
if (conn->vc != NULL) {
MPIDI_CH3I_VC *vcch = &conn->vc->ch;
- conn->sock = MPIDU_SOCK_INVALID_SOCK;
+ conn->sock = MPIDI_CH3I_SOCK_INVALID_SOCK;
MPL_DBG_CONNSTATECHANGE(conn->vc,conn,CONN_STATE_CLOSED);
conn->state = CONN_STATE_CLOSED;
@@ -672,7 +672,7 @@ int MPIDI_CH3_Sockconn_handle_close_event( MPIDI_CH3I_Connection_t * conn )
if (vcch && vcch->conn == conn) {
MPL_DBG_VCCHSTATECHANGE(conn->vc,VC_STATE_UNCONNECTED);
vcch->state = MPIDI_CH3I_VC_STATE_UNCONNECTED;
- vcch->sock = MPIDU_SOCK_INVALID_SOCK;
+ vcch->sock = MPIDI_CH3I_SOCK_INVALID_SOCK;
/* This step is important; without this, test
disconnect_reconnect fails because the vc->ch.conn
@@ -694,7 +694,7 @@ int MPIDI_CH3_Sockconn_handle_close_event( MPIDI_CH3I_Connection_t * conn )
/* post close, so the socket is closed and memmory leaks are avoided */
MPL_DBG_MSG(MPIDI_CH3_DBG_DISCONNECT,TYPICAL,"CLosing sock (Post_close)");
conn->state = CONN_STATE_CLOSING;
- mpi_errno = MPIDU_Sock_post_close(conn->sock);
+ mpi_errno = MPIDI_CH3I_Sock_post_close(conn->sock);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -741,7 +741,7 @@ int MPIDI_CH3_Sockconn_handle_conn_event( MPIDI_CH3I_Connection_t * conn )
MPIR_Assert( conn->state == CONN_STATE_OPEN_LRECV_PKT);
MPL_DBG_CONNSTATECHANGE(conn->vc,conn,CONN_STATE_OPEN_LRECV_DATA);
conn->state = CONN_STATE_OPEN_LRECV_DATA;
- mpi_errno = MPIDU_Sock_post_read(conn->sock, conn->pg_id,
+ mpi_errno = MPIDI_CH3I_Sock_post_read(conn->sock, conn->pg_id,
openpkt->pg_id_len,
openpkt->pg_id_len, NULL);
if (mpi_errno != MPI_SUCCESS) {
@@ -848,7 +848,7 @@ int MPIDI_CH3_Sockconn_handle_conn_event( MPIDI_CH3I_Connection_t * conn )
close command. This also caused that the socket is removed from the
socket set, so no more polling on this socket*/
MPL_DBG_MSG(MPIDI_CH3_DBG_DISCONNECT,TYPICAL,"CLosing sock (Post_close)");
- mpi_errno = MPIDU_Sock_post_close(conn->sock);
+ mpi_errno = MPIDI_CH3I_Sock_post_close(conn->sock);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -1064,7 +1064,7 @@ int MPIDI_CH3_Sockconn_handle_connwrite( MPIDI_CH3I_Connection_t * conn )
conn->vc = NULL;
MPL_DBG_MSG(MPIDI_CH3_DBG_DISCONNECT,TYPICAL,"Closing sock2 (Post_close)");
- mpi_errno = MPIDU_Sock_post_close(conn->sock);
+ mpi_errno = MPIDI_CH3I_Sock_post_close(conn->sock);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,
"**sock_post_close");
@@ -1158,7 +1158,7 @@ int MPIDI_CH3I_VC_post_sockconnect(MPIDI_VC_t * vc)
int MPIDI_CH3I_Sock_connect( MPIDI_VC_t *vc, const char val[], int vallen )
{
char host_description[MAX_HOST_DESCRIPTION_LEN];
- MPIDU_Sock_ifaddr_t ifaddr;
+ MPIDI_CH3I_Sock_ifaddr_t ifaddr;
int hasIfaddr = 0, port;
MPIDI_CH3I_Connection_t * conn = 0;
int mpi_errno = MPI_SUCCESS;
@@ -1188,7 +1188,7 @@ int MPIDI_CH3I_Sock_connect( MPIDI_VC_t *vc, const char val[], int vallen )
goto fn_exit;
}
- mpi_errno = MPIDU_Sock_get_conninfo_from_bc( val, host_description,
+ mpi_errno = MPIDI_CH3I_Sock_get_conninfo_from_bc( val, host_description,
sizeof(host_description),
&port, &ifaddr, &hasIfaddr );
if (mpi_errno) {
@@ -1205,14 +1205,14 @@ int MPIDI_CH3I_Sock_connect( MPIDI_VC_t *vc, const char val[], int vallen )
address. */
#ifndef HAVE_WINDOWS_H
if (hasIfaddr) {
- mpi_errno = MPIDU_Sock_post_connect_ifaddr(MPIDI_CH3I_sock_set,
+ mpi_errno = MPIDI_CH3I_Sock_post_connect_ifaddr(MPIDI_CH3I_sock_set,
conn, &ifaddr, port,
&conn->sock);
}
else
#endif
{
- mpi_errno = MPIDU_Sock_post_connect(MPIDI_CH3I_sock_set, conn,
+ mpi_errno = MPIDI_CH3I_Sock_post_connect(MPIDI_CH3I_sock_set, conn,
host_description, port,
&conn->sock);
}
@@ -1269,7 +1269,7 @@ static int connection_post_recv_pkt(MPIDI_CH3I_Connection_t * conn)
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_CONNECTION_POST_RECV_PKT);
- mpi_errno = MPIDU_Sock_post_read(conn->sock, &conn->pkt, sizeof(conn->pkt),
+ mpi_errno = MPIDI_CH3I_Sock_post_read(conn->sock, &conn->pkt, sizeof(conn->pkt),
sizeof(conn->pkt), NULL);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
@@ -1293,7 +1293,7 @@ static int connection_post_send_pkt(MPIDI_CH3I_Connection_t * conn)
MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_CONNECTION_POST_SEND_PKT);
MPL_DBG_PKT(conn,&conn->pkt,"connect");
- mpi_errno = MPIDU_Sock_post_write(conn->sock, &conn->pkt, sizeof(conn->pkt),
+ mpi_errno = MPIDI_CH3I_Sock_post_write(conn->sock, &conn->pkt, sizeof(conn->pkt),
sizeof(conn->pkt), NULL);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
@@ -1322,7 +1322,7 @@ static int connection_post_send_pkt_and_pgid(MPIDI_CH3I_Connection_t * conn)
conn->iov[1].MPL_IOV_LEN = (int) strlen(MPIDI_Process.my_pg->id) + 1;
MPL_DBG_PKT(conn,&conn->pkt,"connect-pgid");
- mpi_errno = MPIDU_Sock_post_writev(conn->sock, conn->iov, 2, NULL);
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(conn->sock, conn->iov, 2, NULL);
if (mpi_errno != MPI_SUCCESS) {
MPIR_ERR_POP(mpi_errno);
}
@@ -1350,7 +1350,7 @@ static int connection_post_sendq_req(MPIDI_CH3I_Connection_t * conn)
if (conn->send_active != NULL)
{
MPL_DBG_MSG_P(MPIDI_CH3_DBG_CONNECT,TYPICAL,"conn=%p: Posting message from connection send queue", conn );
- mpi_errno = MPIDU_Sock_post_writev(conn->sock,
+ mpi_errno = MPIDI_CH3I_Sock_post_writev(conn->sock,
conn->send_active->dev.iov,
conn->send_active->dev.iov_count,
NULL);
diff --git a/src/mpid/ch3/util/sock/ch3u_getinterfaces.c b/src/mpid/ch3/util/sock/ch3u_getinterfaces.c
index 0eb833f..35fad86 100644
--- a/src/mpid/ch3/util/sock/ch3u_getinterfaces.c
+++ b/src/mpid/ch3/util/sock/ch3u_getinterfaces.c
@@ -36,7 +36,7 @@
*/
static int dbg_ifname = -1;
-static int MPIDI_CH3U_GetIPInterface( MPIDU_Sock_ifaddr_t *, int * );
+static int MPIDI_CH3U_GetIPInterface( MPIDI_CH3I_Sock_ifaddr_t *, int * );
/*
* Get a description of the network interface to use for socket communication
@@ -64,7 +64,7 @@ static int MPIDI_CH3U_GetIPInterface( MPIDU_Sock_ifaddr_t *, int * );
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
int MPIDU_CH3U_GetSockInterfaceAddr( int myRank, char *ifname, int maxIfname,
- MPIDU_Sock_ifaddr_t *ifaddr )
+ MPIDI_CH3I_Sock_ifaddr_t *ifaddr )
{
char *ifname_string;
int mpi_errno = MPI_SUCCESS;
@@ -181,12 +181,12 @@ fn_fail:
#define NUM_IFREQS 10
-static int MPIDI_CH3U_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
+static int MPIDI_CH3U_GetIPInterface( MPIDI_CH3I_Sock_ifaddr_t *ifaddr, int *found )
{
char *buf_ptr, *ptr;
int buf_len, buf_len_prev;
int fd;
- MPIDU_Sock_ifaddr_t myifaddr;
+ MPIDI_CH3I_Sock_ifaddr_t myifaddr;
int nfound = 0, foundLocalhost = 0;
/* We predefine the LSB and MSB localhost addresses */
unsigned int localhost = 0x0100007f;
@@ -350,7 +350,7 @@ static int MPIDI_CH3U_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
#else /* things needed to find the interfaces */
/* In this case, just return false for interfaces found */
-static int MPIDI_CH3U_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found )
+static int MPIDI_CH3U_GetIPInterface( MPIDI_CH3I_Sock_ifaddr_t *ifaddr, int *found )
{
*found = 0;
return 0;
diff --git a/src/mpid/ch3/util/sock/ch3u_init_sock.c b/src/mpid/ch3/util/sock/ch3u_init_sock.c
index 9dccecf..13dad8e 100644
--- a/src/mpid/ch3/util/sock/ch3u_init_sock.c
+++ b/src/mpid/ch3/util/sock/ch3u_init_sock.c
@@ -65,7 +65,7 @@ int MPIDI_CH3U_Init_sock(int has_parent, MPIDI_PG_t *pg_p, int pg_rank,
vcch->sendq_head = NULL;
vcch->sendq_tail = NULL;
vcch->state = MPIDI_CH3I_VC_STATE_UNCONNECTED;
- vcch->sock = MPIDU_SOCK_INVALID_SOCK;
+ vcch->sock = MPIDI_CH3I_SOCK_INVALID_SOCK;
vcch->conn = NULL;
}
@@ -96,7 +96,7 @@ int MPIDI_CH3U_Init_sock(int has_parent, MPIDI_PG_t *pg_p, int pg_rank,
int MPIDI_VC_InitSock( MPIDI_VC_t *vc )
{
MPIDI_CH3I_VC *vcch = &vc->ch;
- vcch->sock = MPIDU_SOCK_INVALID_SOCK;
+ vcch->sock = MPIDI_CH3I_SOCK_INVALID_SOCK;
vcch->conn = NULL;
return 0;
}
diff --git a/src/mpid/ch3/util/sock/ch3usock.h b/src/mpid/ch3/util/sock/ch3usock.h
index aebfdf3..34fd867 100644
--- a/src/mpid/ch3/util/sock/ch3usock.h
+++ b/src/mpid/ch3/util/sock/ch3usock.h
@@ -7,7 +7,7 @@
#ifndef CH3USOCK_H_INCLUDED
#define CH3USOCK_H_INCLUDED
-#ifndef MPIDU_SOCK_H_INCLUDED
+#ifndef MPIDI_CH3I_SOCK_H_INCLUDED
#include "mpidu_sock.h"
#endif
@@ -32,7 +32,7 @@ typedef enum MPIDI_CH3I_Conn_state
typedef struct MPIDI_CH3I_Connection
{
MPIDI_VC_t * vc;
- MPIDU_Sock_t sock;
+ MPIDI_CH3I_Sock_t sock;
MPIDI_CH3I_Conn_state state;
struct MPIR_Request * send_active;
struct MPIR_Request * recv_active;
@@ -58,7 +58,7 @@ int MPIDI_CH3I_Connection_alloc(MPIDI_CH3I_Connection_t **);
void MPIDI_CH3I_Connection_free(MPIDI_CH3I_Connection_t *);
/* Routines to get the socket address */
-int MPIDU_CH3U_GetSockInterfaceAddr( int, char *, int, MPIDU_Sock_ifaddr_t * );
+int MPIDU_CH3U_GetSockInterfaceAddr( int, char *, int, MPIDI_CH3I_Sock_ifaddr_t * );
/* Return a string for the connection state */
#ifdef MPL_USE_DBG_LOGGING
@@ -66,14 +66,14 @@ const char * MPIDI_Conn_GetStateString(int);
const char * MPIDI_CH3_VC_GetStateString( struct MPIDI_VC * );
#endif
-int MPIDU_Sock_get_conninfo_from_bc( const char *bc,
+int MPIDI_CH3I_Sock_get_conninfo_from_bc( const char *bc,
char *host_description, int maxlen,
- int *port, MPIDU_Sock_ifaddr_t *ifaddr,
+ int *port, MPIDI_CH3I_Sock_ifaddr_t *ifaddr,
int *hasIfaddr );
/* These two routines from util/sock initialize and shutdown the
socket used to establish connections. */
-int MPIDU_CH3I_SetupListener( MPIDU_Sock_set_t );
+int MPIDU_CH3I_SetupListener( MPIDI_CH3I_Sock_set_t );
int MPIDU_CH3I_ShutdownListener( void );
#endif
diff --git a/src/mpid/ch3/util/sock/errnames.txt b/src/mpid/ch3/util/sock/errnames.txt
index d7488fb..1d1eb5e 100644
--- a/src/mpid/ch3/util/sock/errnames.txt
+++ b/src/mpid/ch3/util/sock/errnames.txt
@@ -29,4 +29,4 @@
**ch3|sock|badhost %s %d %s:[ch3:sock] invalid host description, %s:%d (%s)
**pglookup:unable to find the process group structure
**pglookup %s:unable to find the process group structure with id <%s>
-**ch3|sock|handle_sock_event:an error occurred while handling an event returned by MPIDU_Sock_Wait()
+**ch3|sock|handle_sock_event:an error occurred while handling an event returned by MPIDI_CH3I_Sock_Wait()
http://git.mpich.org/mpich.git/commitdiff/802c218a6bb2c15d0765672379d63ab56ba3e581
commit 802c218a6bb2c15d0765672379d63ab56ba3e581
Author: Pavan Balaji <balaji at anl.gov>
Date: Tue Feb 2 16:42:59 2016 -0600
sock: move utils to sock channel.
These utils are not used anywhere and will not be used anywhere in the
future, at least in the CH3 device. It's highly unlikely they will be
used in CH4, but if they are, we'll probably need to rewrite them to be
closer to what we have with nemesis.
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/src/mpid/common/sock/mpidu_sock.h b/src/mpid/ch3/channels/sock/include/mpidu_sock.h
similarity index 100%
rename from src/mpid/common/sock/mpidu_sock.h
rename to src/mpid/ch3/channels/sock/include/mpidu_sock.h
diff --git a/src/mpid/common/sock/mpidu_socki.h b/src/mpid/ch3/channels/sock/include/mpidu_socki.h
similarity index 94%
rename from src/mpid/common/sock/mpidu_socki.h
rename to src/mpid/ch3/channels/sock/include/mpidu_socki.h
index 8f862fb..a50d8fc 100644
--- a/src/mpid/common/sock/mpidu_socki.h
+++ b/src/mpid/ch3/channels/sock/include/mpidu_socki.h
@@ -44,8 +44,8 @@ typedef size_t MPIDU_Sock_size_t;
#define MPIDU_SOCKI_STATE_LIST \
MPID_STATE_MPIDU_SOCKI_READ, \
MPID_STATE_MPIDU_SOCKI_WRITE, \
-MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC, \
-MPID_STATE_MPIDU_SOCKI_SOCK_FREE, \
+MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC, \
+MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE, \
MPID_STATE_MPIDU_SOCKI_EVENT_ENQUEUE, \
MPID_STATE_MPIDU_SOCKI_EVENT_DEQUEUE, \
MPID_STATE_MPIDU_SOCKI_ADJUST_IOV, \
diff --git a/src/mpid/ch3/channels/sock/src/Makefile.mk b/src/mpid/ch3/channels/sock/src/Makefile.mk
index 8885bbb..331642b 100644
--- a/src/mpid/ch3/channels/sock/src/Makefile.mk
+++ b/src/mpid/ch3/channels/sock/src/Makefile.mk
@@ -12,6 +12,7 @@ errnames_txt_files += src/mpid/ch3/channels/sock/src/errnames.txt
if BUILD_CH3_SOCK
mpi_core_sources += \
+ src/mpid/ch3/channels/sock/src/sock.c \
src/mpid/ch3/channels/sock/src/ch3_finalize.c \
src/mpid/ch3/channels/sock/src/ch3_init.c \
src/mpid/ch3/channels/sock/src/ch3_isend.c \
@@ -21,5 +22,9 @@ mpi_core_sources += \
src/mpid/ch3/channels/sock/src/ch3_progress.c \
src/mpid/ch3/channels/sock/src/ch3_win_fns.c
+noinst_HEADERS += \
+ src/mpid/ch3/channels/sock/include/mpidu_sock.h \
+ src/mpid/ch3/channels/sock/include/mpidu_socki.h
+
endif BUILD_CH3_SOCK
diff --git a/src/mpid/ch3/channels/sock/src/errnames.txt b/src/mpid/ch3/channels/sock/src/errnames.txt
index c5c8ec4..1c08ad3 100644
--- a/src/mpid/ch3/channels/sock/src/errnames.txt
+++ b/src/mpid/ch3/channels/sock/src/errnames.txt
@@ -1,3 +1,89 @@
**ch3|sock|connectionfailed:Connection failed for virtual channel
**ch3|sock|writefailed:Write to socket failed
**ch3|sock|writefailed %d:Write to socket failed with code %d
+
+**sock|setalloc:unable to allocate a new sock set object
+**sock|sockalloc:unable to allocate a new sock object
+**sock|badbuf:the supplied buffer contains invalid memory
+**sock|badhandle:sock contains an invalid handle
+**sock|badhdbuf:a memory fault occurred while accessing the host description string
+**sock|badhdmax:the length of the host description string must be non-negative
+**sock|badhdlen:host description string to small to store description
+**sock|badiovn:size of iov is invalid
+**sock|badiovn %d %d %d:size of iov is invalid (set=%d,sock=%d,iov_n=%d)
+**sock|badlen:bad length parameter(s)
+**sock|badlen %d %d %d %d:bad length parameter(s) (set=%d,sock=%d,min=%d,max=%d)
+**sock|badport:port number is out of range
+**sock|badport %d:port number is out of range (sock=%d)
+**sock|badsock:supplied sock is corrupt
+**sock|connclosed:connection closed by peer
+**sock|connclosed %d %d:connection closed by peer (set=%d,sock=%d)
+**sock|connfailed:connection failure
+**sock|connrefused:connection refused
+**sock|close_cancel:operation cancelled because sock was closed locally
+**sock|close_cancel %d %d:operation cancelled because sock was closed locally (set=%d,sock=%d)
+**sock|closing:sock is in the process of being closed locally
+**sock|closing %d %d:sock is in the process of being closed locally (set=%d,sock=%d)
+**sock|closing_already:a close operation is already posted
+**sock|closing_already %d %d:a close operation is already post (set=%d,sock=%d)
+**sock|getport:failed to obtain port number of the listener
+**sock|listener_bad_sock:supplied sock is not a listener
+**sock|listener_bad_sock %d %d:supplied sock is not a listener (set=%d,sock=%d)
+**sock|listener_bad_state:supplied listener sock is in a bad state
+**sock|listener_bad_state %d %d %d:supplied listener sock is in a bad state (set=%d,sock=%d,state=%d)
+**sock|listener_read:read operation not allowed on a listener
+**sock|listener_read %d %d:read operation not allowed on a listener (set=%d,sock=%d)
+**sock|listener_write:write operation not allowed on a listener
+**sock|listener_write %d %d:write operation not allowed on a listener (set=%d,sock=%d)
+**sock|notconnected:sock is not connected
+**sock|notconnected %d %d:sock is not connected (set=%d,sock=%d)
+**sock|nosock:no new sock was available to accept
+**sock|oserror:unexpected operating system error
+**sock|osnomem:operating system routine failed due to lack of memory
+**sock|osnomem %s %d %d:operating system routine %s failed due to lack of memory (set=%d,sock=%d)
+**sock|reads:attempt to perform multiple simultaneous reads
+**sock|reads %d %d:attempt to perform multiple simultaneous reads (set=%d,sock=%d)
+**sock|uninit:Sock library has not been initialized
+**sock|writes:attempt to perform multiple simultaneous writes
+**sock|writes %d %d:attempt to perform multiple simultaneous writes (set=%d,sock=%d)
+
+**sock|poll|accept:accept failed to acquire a new socket
+**sock|poll|accept %d %s:accept failed to acquire a new socket (errno=%d:%s)
+**sock|poll|badbuf %d %d %d %s:the supplied buffer contains invalid memory (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|badhandle %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d)
+**sock|poll|badhandle %d %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d:%d)
+**sock|poll|bind:unable to bind socket to port
+**sock|poll|bind %d %d %s:unable to bind socket to port (port=%d,errno=%d:%s)
+**sock|poll|connclosed %d %d %d %s:connection closed by peer (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|connfailed %d %d %d %s:connection failure (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|connrefused %d %d %s:connection refused (set=%d,sock=%d,host=%s)
+**sock|poll|eqmalloc:MPL_malloc failed to allocate memory for an event queue structure
+**sock|poll|eqfail:fatal error: failed to enqueue an event; event was lost
+**sock|poll|eqfail %d %d %d:fatal error: failed to enqueue an event; event was lost (set=%d,sock=%d,op=%d)
+**sock|poll|getport %d %s:failed to obtain port number of listener (errno=%d:%s)
+**sock|poll|listen:listen() failed
+**sock|poll|listen %d %s:listen() failed (errno=%d:%s)
+**sock|poll|nodelay:unable to set TCP no delay attribute on socket
+**sock|poll|nodelay %d %s:unable to set TCP no delay attribute on socket (errno=%d:%s)
+**sock|poll|nonblock:unable to set socket to nonblocking
+**sock|poll|nonblock %d %s:unable to set socket to nonblocking (errno=%d:%s)
+**sock|poll|oserror %d %s:unexpected operating system error (errno=%d:%s)
+**sock|poll|oserror %d %d %d %s:unexpected operating system error (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|oserror %s %d %d %d %s:unpected operating system error from %s (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|osnomem %d %d %d %s:operating system routine failed due to lack of memory (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|pipe:unable to allocate pipe to wakeup a blocking poll()
+**sock|poll|pipe %d %s:unable to allocate pipe to wakeup a blocking poll() (errno=%d:%s)
+**sock|poll|pipenonblock:unable to set wakeup pipe to nonblocking
+**sock|poll|pipenonblock %d %s:unable to set wakeup pipe to nonblocking (errno=%d:%s)
+**sock|poll|reuseaddr:unable to set reuseaddr attribute on socket
+**sock|poll|reuseaddr %d %s:unable to set reuseaddr attribute on socket (errno=%d:%s)
+**sock|poll|setrcvbufsz: unable to set the receive socket buffer size
+**sock|poll|setrcvbufsz %d %d %s: unable to set the receive socket buffer size (size=%d,errno=%d:%s)
+**sock|poll|setsndbufsz: unable to set the send socket buffer size
+**sock|poll|setsndbufsz %d %d %s: unable to set the send socket buffer size (size=%d,errno=%d:%s)
+**sock|poll|socket:unable to obtain new socket
+**sock|poll|socket %d %s:unable to obtain new socket (errno=%d:%s)
+**sock|poll|unhandledstate:encountered an unexpected state
+**sock|poll|unhandledstate %d:encountered an unexpected state (%d)
+**sock|poll|unhandledtype:encountered an unexpected sock type
+**sock|poll|unhandledtype %d:encountered an unexpected sock type (%d)
diff --git a/src/mpid/common/sock/sock.c b/src/mpid/ch3/channels/sock/src/sock.c
similarity index 91%
rename from src/mpid/common/sock/sock.c
rename to src/mpid/ch3/channels/sock/src/sock.c
index 729cae0..c287ee6 100644
--- a/src/mpid/common/sock/sock.c
+++ b/src/mpid/ch3/channels/sock/src/sock.c
@@ -229,7 +229,7 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock);
static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo,
enum MPIDU_Sock_op op,
- MPIU_Size_t num_bytes,
+ size_t num_bytes,
void * user_ptr, int error);
static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set,
int * set_elem,
@@ -348,7 +348,7 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
mpi_errno = MPIR_Err_create_code( \
MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|oserror", \
"**sock|poll|oserror %s %d %d %d %s", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id, \
- (os_errno_), MPIU_Strerror(os_errno_)); \
+ (os_errno_), MPIR_Strerror(os_errno_)); \
} \
\
goto fail_label_; \
@@ -424,7 +424,7 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
(mpi_errno_) = MPIR_Err_create_code( \
(mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
"**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
- (pollinfo_)->os_errno, MPIU_Strerror((pollinfo_)->os_errno)); \
+ (pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
} \
goto fail_label_; \
} \
@@ -478,7 +478,7 @@ static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
(mpi_errno_) = MPIR_Err_create_code( \
(mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
"**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
- (pollinfo_)->os_errno, MPIU_Strerror((pollinfo_)->os_errno)); \
+ (pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
} \
goto fail_label_; \
} \
@@ -581,7 +581,7 @@ static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set)
break;
}
- MPIU_Assertp(nb == 0 || errno == EINTR);
+ MPIR_Assertp(nb == 0 || errno == EINTR);
}
sock_set->wakeup_posted = TRUE;
@@ -600,9 +600,9 @@ int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
{
int mpi_errno = MPI_SUCCESS;
int elem;
- MPIDI_STATE_DECL(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
for (elem = 0; elem < sock_set->poll_array_elems; elem++) {
sock_set->pollfds[elem].events = sock_set->pollinfos[elem].pollfd_events;
if ((sock_set->pollfds[elem].events & (POLLIN | POLLOUT)) != 0) {
@@ -632,7 +632,7 @@ int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
sock_set->pollfds_updated = FALSE;
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
return mpi_errno;
}
@@ -659,28 +659,28 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_NOMEM,
"**sock|osnomem", "**sock|poll|osnomem %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = FALSE;
}
else if (os_errno == EFAULT || os_errno == EINVAL)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_BAD_BUF,
"**sock|badbuf", "**sock|poll|badbuf %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = FALSE;
}
else if (os_errno == EPIPE)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_CLOSED,
"**sock|connclosed", "**sock|poll|connclosed %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
*disconnected = TRUE;
}
else if (os_errno == ECONNRESET || os_errno == ENOTCONN || os_errno == ETIMEDOUT)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
"**sock|connfailed", "**sock|poll|connfailed %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
pollinfo->os_errno = os_errno;
*disconnected = TRUE;
}
@@ -712,7 +712,7 @@ static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno,
*/
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
"**sock|oserror", "**sock|poll|oserror %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
pollinfo->os_errno = os_errno;
*disconnected = TRUE;
}
@@ -777,9 +777,9 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
struct pollfd * pollfds = NULL;
struct pollinfo * pollinfos = NULL;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC);
/* FIXME: Should this use the CHKPMEM macros (perm malloc)? */
sock = MPL_malloc(sizeof(struct MPIDU_Sock));
@@ -901,16 +901,16 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
/*
* Verify that memory hasn't been messed up.
*/
- MPIU_Assert(sock_set->pollinfos[avail_elem].sock_set == sock_set);
- MPIU_Assert(sock_set->pollinfos[avail_elem].elem == avail_elem);
- MPIU_Assert(sock_set->pollinfos[avail_elem].fd == -1);
- MPIU_Assert(sock_set->pollinfos[avail_elem].sock == NULL);
- MPIU_Assert(sock_set->pollinfos[avail_elem].sock_id == -1);
- MPIU_Assert(sock_set->pollinfos[avail_elem].type == MPIDU_SOCKI_TYPE_FIRST);
- MPIU_Assert(sock_set->pollinfos[avail_elem].state == MPIDU_SOCKI_STATE_FIRST);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].sock_set == sock_set);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].elem == avail_elem);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].fd == -1);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].sock == NULL);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].sock_id == -1);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].type == MPIDU_SOCKI_TYPE_FIRST);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].state == MPIDU_SOCKI_STATE_FIRST);
# ifdef MPICH_IS_THREADED
{
- MPIU_Assert(sock_set->pollinfos[avail_elem].pollfd_events == 0);
+ MPIR_Assert(sock_set->pollinfos[avail_elem].pollfd_events == 0);
}
# endif
@@ -940,7 +940,7 @@ static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU
*sockp = sock;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_ALLOC);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -975,9 +975,9 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
struct pollfd * pollfd = MPIDU_Socki_sock_get_pollfd(sock);
struct pollinfo * pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
struct MPIDU_Sock_set * sock_set = sock->sock_set;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
/* FIXME: We need an abstraction for the thread sync operations */
# ifdef MPICH_IS_THREADED
@@ -985,7 +985,7 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
/*
* Freeing a sock while Sock_wait() is blocked in poll() is not supported
*/
- MPIU_Assert(sock_set->pollfds_active == NULL);
+ MPIR_Assert(sock_set->pollfds_active == NULL);
}
# endif
@@ -1029,7 +1029,7 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
MPL_free(sock);
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_SOCK_FREE);
}
/* end MPIDU_Socki_sock_free() */
@@ -1038,15 +1038,15 @@ static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
#define FUNCNAME MPIDU_Socki_event_enqueue
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t op, MPIU_Size_t num_bytes,
+static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t op, size_t num_bytes,
void * user_ptr, int error)
{
struct MPIDU_Sock_set * sock_set = pollinfo->sock_set;
struct MPIDU_Socki_eventq_elem * eventq_elem;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
- MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
if (MPIDU_Socki_eventq_pool != NULL)
{
@@ -1101,7 +1101,7 @@ static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t
}
sock_set->eventq_tail = eventq_elem;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_ENQUEUE);
return mpi_errno;
}
/* end MPIDU_Socki_event_enqueue() */
@@ -1115,9 +1115,9 @@ static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, in
{
struct MPIDU_Socki_eventq_elem * eventq_elem;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE);
- MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE);
if (sock_set->eventq_head != NULL)
{
@@ -1143,7 +1143,7 @@ static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, in
}
/* --END ERROR HANDLING-- */
- MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_SOCKI_EVENT_DEQUEUE);
return mpi_errno;
}
/* end MPIDU_Socki_event_dequeue() */
@@ -1158,9 +1158,9 @@ static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, in
static void MPIDU_Socki_free_eventq_mem(void)
{
struct MPIDU_Socki_eventq_table *eventq_table, *eventq_table_next;
- MPIDI_STATE_DECL(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
- MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
eventq_table = MPIDU_Socki_eventq_table_head;
while (eventq_table) {
@@ -1170,7 +1170,7 @@ static void MPIDU_Socki_free_eventq_mem(void)
}
MPIDU_Socki_eventq_table_head = NULL;
- MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
}
/* Provide a standard mechanism for setting the socket buffer size.
@@ -1208,7 +1208,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
"**sock|poll|setsndbufsz",
"**sock|poll|setsndbufsz %d %d %s",
- bufsz, errno, MPIU_Strerror(errno));
+ bufsz, errno, MPIR_Strerror(errno));
}
bufsz = sockBufSize;
bufsz_len = sizeof(bufsz);
@@ -1217,7 +1217,7 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
"**sock|poll|setrcvbufsz",
"**sock|poll|setrcvbufsz %d %d %s",
- bufsz, errno, MPIU_Strerror(errno));
+ bufsz, errno, MPIR_Strerror(errno));
}
bufsz_len = sizeof(bufsz);
@@ -1280,9 +1280,9 @@ MPL_dbg_class MPIDU_DBG_SOCK_CONNECT;
#define FCNAME MPL_QUOTE(FUNCNAME)
int MPIDU_Sock_init(void)
{
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
#if defined (MPL_USE_DBG_LOGGING)
MPIDU_DBG_SOCK_CONNECT = MPL_dbg_class_alloc("SOCK_CONNECT", "sock_connect");
@@ -1290,7 +1290,7 @@ int MPIDU_Sock_init(void)
MPIDU_Socki_initialized++;
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
return MPI_SUCCESS;
}
@@ -1302,11 +1302,11 @@ int MPIDU_Sock_init(void)
int MPIDU_Sock_finalize(void)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
MPIDU_Socki_initialized--;
@@ -1318,7 +1318,7 @@ int MPIDU_Sock_finalize(void)
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
return mpi_errno;
}
@@ -1334,9 +1334,9 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
{
struct MPIDU_Sock_set * sock_set = NULL;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
@@ -1401,7 +1401,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
if (rc != 0)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|pipe", "**sock|poll|pipe %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|pipe", "**sock|poll|pipe %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1412,7 +1412,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1423,7 +1423,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1461,7 +1461,7 @@ int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
*sock_setp = sock_set;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -1501,9 +1501,9 @@ int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_
int mpi_errno = MPI_SUCCESS;
struct pollinfo * pollinfos = NULL;
pollinfos = sock_set->pollinfos;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* wakeup waiting socket if mullti-threades */
@@ -1519,7 +1519,7 @@ int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
return mpi_errno;
}
@@ -1533,9 +1533,9 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
int elem;
struct MPIDU_Sock_event event;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
@@ -1599,7 +1599,7 @@ int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
return mpi_errno;
}
@@ -1643,9 +1643,9 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
int nodelay;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
@@ -1660,21 +1660,21 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
but should be interpreted as an System Error string) */
MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
"**sock|poll|socket",
- "**sock|poll|socket %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
}
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1) {
MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nonblock",
- "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
}
rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
if (rc == -1) {
MPIR_ERR_SETANDJUMP2( mpi_errno, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nonblock",
"**sock|poll|nonblock %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
}
nodelay = 1;
@@ -1683,7 +1683,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nodelay",
"**sock|poll|nodelay %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
}
/*
@@ -1771,7 +1771,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
"**sock|oserror", "**sock|poll|oserror %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, errno,
- MPIU_Strerror(errno)), mpi_errno, fn_fail);
+ MPIR_Strerror(errno)), mpi_errno, fn_fail);
}
}
/* --END ERROR HANDLING-- */
@@ -1779,7 +1779,7 @@ int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
*sockp = sock;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -1863,9 +1863,9 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
socklen_t addr_len;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
@@ -1885,7 +1885,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (fd == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|socket", "**sock|poll|socket %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|socket", "**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1899,7 +1899,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|reuseaddr", "**sock|poll|reuseaddr %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|reuseaddr", "**sock|poll|reuseaddr %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1911,7 +1911,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (flags == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1920,7 +1920,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1964,7 +1964,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|bind", "**sock|poll|bind %d %d %s", *port, errno, MPIU_Strerror(errno));
+ "**sock|poll|bind", "**sock|poll|bind %d %d %s", *port, errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1983,7 +1983,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|listen", "**sock|poll|listen %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|listen", "**sock|poll|listen %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -1998,7 +1998,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|getport", "**sock|poll|getport %d %s", errno, MPIU_Strerror(errno));
+ "**sock|getport", "**sock|poll|getport %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -2032,7 +2032,7 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
*sockp = sock;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -2053,15 +2053,15 @@ int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
#define FUNCNAME MPIDU_Sock_post_read
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minlen, MPIU_Size_t maxlen,
+int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
MPIDU_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2093,7 +2093,7 @@ int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minle
MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
return mpi_errno;
}
/* end MPIDU_Sock_post_read() */
@@ -2108,9 +2108,9 @@ int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MP
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2142,7 +2142,7 @@ int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MP
MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
return mpi_errno;
}
/* end MPIDU_Sock_post_readv() */
@@ -2152,15 +2152,15 @@ int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MP
#define FUNCNAME MPIDU_Sock_post_write
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minlen, MPIU_Size_t maxlen,
+int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
MPIDU_Sock_progress_update_func_t fn)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2192,7 +2192,7 @@ int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minl
MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
return mpi_errno;
}
/* end MPIDU_Sock_post_write() */
@@ -2207,9 +2207,9 @@ int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, M
struct pollfd * pollfd;
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2241,7 +2241,7 @@ int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, M
MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
return mpi_errno;
}
/* end MPIDU_Sock_post_writev() */
@@ -2257,9 +2257,9 @@ int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
struct pollinfo * pollinfo;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2322,7 +2322,7 @@ int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
pollinfo->state = MPIDU_SOCKI_STATE_CLOSING;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
return mpi_errno;
}
@@ -2356,9 +2356,9 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
int nodelay;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(listener, mpi_errno, fn_exit);
@@ -2435,7 +2435,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
"**sock|poll|accept", "**sock|poll|accept %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
}
goto fn_fail;
@@ -2450,7 +2450,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -2461,7 +2461,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -2474,7 +2474,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
"**sock|poll|nodelay", "**sock|poll|nodelay %d %s",
- errno, MPIU_Strerror(errno));
+ errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -2562,7 +2562,7 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
*sockp = sock;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -2582,17 +2582,17 @@ int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
#define FUNCNAME MPIDU_Sock_read
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
- MPIU_Size_t * num_read)
+int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
+ size_t * num_read)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
size_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_READ);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READ);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2618,15 +2618,15 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
do
{
- MPIDI_FUNC_ENTER(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READ);
nb = read(pollinfo->fd, buf, len);
- MPIDI_FUNC_EXIT(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READ);
}
while (nb == -1 && errno == EINTR);
if (nb > 0)
{
- *num_read = (MPIU_Size_t) nb;
+ *num_read = (size_t) nb;
}
/* --BEGIN ERROR HANDLING-- */
else if (nb == 0)
@@ -2691,7 +2691,7 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READ);
return mpi_errno;
}
/* end MPIDU_Sock_read() */
@@ -2702,16 +2702,16 @@ int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
- MPIU_Size_t * num_read)
+ size_t * num_read)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_READV);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READV);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2731,15 +2731,15 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
*/
do
{
- MPIDI_FUNC_ENTER(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READV);
nb = MPL_large_readv(pollinfo->fd, iov, iov_n);
- MPIDI_FUNC_EXIT(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READV);
}
while (nb == -1 && errno == EINTR);
if (nb > 0)
{
- *num_read = (MPIU_Size_t) nb;
+ *num_read = (size_t) nb;
}
/* --BEGIN ERROR HANDLING-- */
else if (nb == 0)
@@ -2805,7 +2805,7 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READV);
return mpi_errno;
}
/* end MPIDU_Sock_readv() */
@@ -2815,17 +2815,17 @@ int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
#define FUNCNAME MPIDU_Sock_write
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
- MPIU_Size_t * num_written)
+int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
+ size_t * num_written)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_WRITE);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2845,9 +2845,9 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
do
{
- MPIDI_FUNC_ENTER(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITE);
nb = write(pollinfo->fd, buf, len);
- MPIDI_FUNC_EXIT(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITE);
}
while (nb == -1 && errno == EINTR);
@@ -2891,7 +2891,7 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
return mpi_errno;
}
/* end MPIDU_Sock_write() */
@@ -2901,16 +2901,16 @@ int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
#define FUNCNAME MPIDU_Sock_writev
#undef FCNAME
#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIU_Size_t * num_written)
+int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written)
{
struct pollfd * pollfd;
struct pollinfo * pollinfo;
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_WRITEV);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
@@ -2930,15 +2930,15 @@ int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIU_Size_t *
*/
do
{
- MPIDI_FUNC_ENTER(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITEV);
nb = MPL_large_writev(pollinfo->fd, iov, iov_n);
- MPIDI_FUNC_EXIT(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITEV);
}
while (nb == -1 && errno == EINTR);
if (nb >= 0)
{
- *num_written = (MPIU_Size_t) nb;
+ *num_written = (size_t) nb;
}
/* --BEGIN ERROR HANDLING-- */
else if (errno == EAGAIN || errno == EWOULDBLOCK)
@@ -2976,7 +2976,7 @@ int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIU_Size_t *
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
return mpi_errno;
}
/* end MPIDU_Sock_writev() */
@@ -2989,9 +2989,9 @@ int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIU_Size_t *
int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAKEUP);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAKEUP);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
@@ -3017,7 +3017,7 @@ int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
#ifdef MPICH_IS_THREADED
fn_exit:
#endif
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAKEUP);
return mpi_errno;
}
/* end MPIDU_Sock_wakeup() */
@@ -3041,9 +3041,9 @@ int MPIDU_Sock_get_host_description(int myRank,
char * env_hostname;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
/* --BEGIN ERROR HANDLING-- */
@@ -3101,14 +3101,14 @@ int MPIDU_Sock_get_host_description(int myRank,
else
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIU_Strerror(errno));
+ "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
}
}
/* --END ERROR HANDLING-- */
}
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
return mpi_errno;
}
@@ -3126,9 +3126,9 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
int rc;
long flags;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCK_NATIVE_TO_SOCK);
- MPIDI_FUNC_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
@@ -3152,7 +3152,7 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
if (flags == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -3161,7 +3161,7 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
if (rc == -1)
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
goto fn_fail;
}
/* --END ERROR HANDLING-- */
@@ -3179,7 +3179,7 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
*sockp = sock;
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCK_NATIVE_TO_SOCK);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
@@ -3201,9 +3201,9 @@ int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIV
int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
@@ -3223,7 +3223,7 @@ int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
#ifdef USE_SOCK_VERIFY
fn_exit:
#endif
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
return mpi_errno;
}
@@ -3235,9 +3235,9 @@ int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
{
int id;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
if (sock != MPIDU_SOCK_INVALID_SOCK)
{
@@ -3255,7 +3255,7 @@ int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
id = -1;
}
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
return id;
}
@@ -3266,9 +3266,9 @@ int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
{
int id;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
if (sock_set != MPIDU_SOCK_INVALID_SET)
{
@@ -3279,7 +3279,7 @@ int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
id = -1;
}
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
return id;
}
@@ -3299,9 +3299,9 @@ int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
/* --BEGIN ERROR HANDLING-- */
int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length)
{
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
switch (MPIR_ERR_GET_CLASS(error))
{
case MPIDU_SOCK_ERR_FAIL:
@@ -3359,7 +3359,7 @@ int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t leng
MPL_snprintf(error_string, length, "unknown socket error %d", error);
break;
}
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
return MPI_SUCCESS;
}
/* --END ERROR HANDLING-- */
@@ -3370,7 +3370,7 @@ int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t leng
/* Make sure that we can properly ensure atomic access to the poll routine */
#ifdef MPICH_IS_THREADED
-#if !(MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY_GLOBAL)
+#if !(MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL)
#error selected multi-threaded implementation is not supported
#endif
#endif
@@ -3410,10 +3410,10 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
struct MPIDU_Sock_event * eventp)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
- MPIDI_STATE_DECL(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_POLL);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
for (;;)
{
@@ -3469,10 +3469,10 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
{
# ifndef MPICH_IS_THREADED
{
- MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
millisecond_timeout);
- MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
}
# else /* MPICH_IS_THREADED */
{
@@ -3482,10 +3482,10 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
multithreaded code (and we don't then need the
MPIR_THREAD_CHECK_BEGIN/END macros) */
if (!MPIR_ThreadInfo.isThreaded) {
- MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
millisecond_timeout);
- MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
}
else
{
@@ -3494,9 +3494,9 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
* progress can be made. This avoids the lock manipulation
* overhead.
*/
- MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems, 0);
- MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
if (n_fds == 0 && millisecond_timeout != 0)
{
@@ -3523,10 +3523,10 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); */
MPID_Thread_mutex_unlock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
- MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
n_fds = poll(sock_set->pollfds_active,
pollfds_active_elems, millisecond_timeout);
- MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
/* Reaquire the lock before processing any of the
information returned from poll */
@@ -3580,7 +3580,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
else
{
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIU_Strerror(errno));
+ "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
goto fn_exit;
}
/* --END ERROR HANDLING-- */
@@ -3599,8 +3599,8 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
struct pollfd * const pollfd = &sock_set->pollfds[elem];
struct pollinfo * const pollinfo = &sock_set->pollinfos[elem];
- MPIU_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
- MPIU_Assert(pollfd->fd >= 0 || pollfd->fd == -1);
+ MPIR_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
+ MPIR_Assert(pollfd->fd >= 0 || pollfd->fd == -1);
if (pollfd->fd < 0 || pollfd->revents == 0)
{
@@ -3752,7 +3752,7 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
}
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
return mpi_errno;
}
@@ -3763,9 +3763,9 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
{
@@ -3798,21 +3798,21 @@ static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct polli
* data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
* list.
*/
- MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
}
else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
{
/*
* We should never reach this state because pollfd->fd should be set to -1 if we are in the disconnected state.
*/
- MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
+ MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
}
else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
{
/*
* The process we were connecting to died. Let the POLLOUT handler deal with the error.
*/
- MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
pollfd->revents = POLLOUT;
}
/* --BEGIN ERROR HANDLING-- */
@@ -3826,7 +3826,7 @@ static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct polli
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
return mpi_errno;
}
/* end MPIDU_Socki_handle_pollhup() */
@@ -3839,9 +3839,9 @@ static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct polli
static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
{
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
/* --BEGIN ERROR HANDLING-- */
if (pollinfo->type != MPIDU_SOCKI_TYPE_COMMUNICATION)
@@ -3860,7 +3860,7 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
* continuously triggered. We remove the socket from the poll list (pollfd->fd = 1) in order to prevent this issue.
* Here, we simple check that things are as we expect them to be.
*/
- MPIU_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
+ MPIR_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
/* If a write was posted then cancel it and generate an write completion event */
if (pollfd->events & POLLOUT)
@@ -3896,20 +3896,20 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
* data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
* list.
*/
- MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
}
else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
{
/*
* The process we were connecting to died. Let the POLLOUT handler deal with the error.
*/
- MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
pollfd->revents = POLLOUT;
}
else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
{
/* We are already disconnected! Why are we handling an error? */
- MPIU_Assert(pollfd->fd == -1);
+ MPIR_Assert(pollfd->fd == -1);
}
/* --BEGIN ERROR HANDLING-- */
else
@@ -3922,7 +3922,7 @@ static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct polli
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
return mpi_errno;
}
/* end MPIDU_Socki_handle_pollerr() */
@@ -3936,27 +3936,27 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
{
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_READ);
- MPIDI_STATE_DECL(MPID_STATE_READV);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
do
{
if (pollinfo->read_iov_flag)
{
- MPIDI_FUNC_ENTER(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READV);
nb = MPL_large_readv(pollinfo->fd, pollinfo->read.iov.ptr + pollinfo->read.iov.offset,
pollinfo->read.iov.count - pollinfo->read.iov.offset);
- MPIDI_FUNC_EXIT(MPID_STATE_READV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READV);
}
else
{
- MPIDI_FUNC_ENTER(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READ);
nb = read(pollinfo->fd, pollinfo->read.buf.ptr + pollinfo->read_nb,
pollinfo->read.buf.max - pollinfo->read_nb);
- MPIDI_FUNC_EXIT(MPID_STATE_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READ);
}
}
while (nb < 0 && errno == EINTR);
@@ -4041,7 +4041,7 @@ static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
return mpi_errno;
}
/* end MPIDU_Socki_handle_read() */
@@ -4055,27 +4055,27 @@ static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinf
{
ssize_t nb;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_WRITE);
- MPIDI_STATE_DECL(MPID_STATE_WRITEV);
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
do
{
if (pollinfo->write_iov_flag)
{
- MPIDI_FUNC_ENTER(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITEV);
nb = MPL_large_writev(pollinfo->fd, pollinfo->write.iov.ptr + pollinfo->write.iov.offset,
pollinfo->write.iov.count - pollinfo->write.iov.offset);
- MPIDI_FUNC_EXIT(MPID_STATE_WRITEV);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITEV);
}
else
{
- MPIDI_FUNC_ENTER(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITE);
nb = write(pollinfo->fd, pollinfo->write.buf.ptr + pollinfo->write_nb,
pollinfo->write.buf.max - pollinfo->write_nb);
- MPIDI_FUNC_EXIT(MPID_STATE_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITE);
}
}
while (nb < 0 && errno == EINTR);
@@ -4134,7 +4134,7 @@ static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinf
/* --END ERROR HANDLING-- */
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
return mpi_errno;
}
/* end MPIDU_Socki_handle_write() */
@@ -4150,9 +4150,9 @@ static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct polli
socklen_t addr_len;
int rc;
int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
- MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
addr_len = sizeof(struct sockaddr_in);
rc = getpeername(pollfd->fd, (struct sockaddr *) &addr, &addr_len);
@@ -4170,7 +4170,7 @@ static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct polli
event_mpi_errno = MPIR_Err_create_code(
MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed",
"**sock|poll|connfailed %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->os_errno,
- MPIU_Strerror(pollinfo->os_errno));
+ MPIR_Strerror(pollinfo->os_errno));
MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, event_mpi_errno, mpi_errno, fn_exit);
pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
}
@@ -4179,7 +4179,7 @@ static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct polli
MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
fn_exit:
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
return mpi_errno;
}
/* end MPIDU_Socki_handle_connect() */
diff --git a/src/mpid/ch3/channels/sock/subconfigure.m4 b/src/mpid/ch3/channels/sock/subconfigure.m4
index b95f9cb..91bfab1 100644
--- a/src/mpid/ch3/channels/sock/subconfigure.m4
+++ b/src/mpid/ch3/channels/sock/subconfigure.m4
@@ -8,7 +8,6 @@ AC_DEFUN([PAC_SUBCFG_PREREQ_]PAC_SUBCFG_AUTO_SUFFIX,[
AM_COND_IF([BUILD_CH3_SOCK],[
AC_MSG_NOTICE([RUNNING PREREQ FOR ch3:sock])
# this channel depends on the sock utilities
- build_mpid_common_sock=yes
build_ch3u_sock=yes
MPID_MAX_THREAD_LEVEL=MPI_THREAD_MULTIPLE
@@ -55,6 +54,134 @@ AC_DEFUN([PAC_SUBCFG_PREREQ_]PAC_SUBCFG_AUTO_SUFFIX,[
##for path in $pathlist ; do
## CPPFLAGS="$CPPFLAGS -I${master_top_builddir}/${path} -I${master_top_srcdir}/${path}"
##done
+
+# Adding this prevents the pesky "(strerror() not found)" problem, which can be
+# very frustrating in the sock code, the most likely to receive an error code
+# from the system. [goodell@ 2008-01-10]
+AC_CHECK_FUNCS([strerror])
+
+AC_ARG_ENABLE([sock-debug],
+ [--enable-sock-debug - Turn on tests of the socket data structures],
+ [],
+ [enable_sock_debug=no])
+
+if test "$enable_sock_debug" = yes ; then
+ AC_DEFINE(USE_SOCK_VERIFY,1,[Define it the socket verify macros should be enabled])
+fi
+
+AC_CHECK_FUNC([poll],[pac_cv_have_func_poll=yes],[pac_cv_have_func_poll=no])
+if test "X$pac_cv_have_func_poll" = "Xno" ; then
+ if test -f /sw/include/sys/poll.h ; then
+ dnl This is for Mac OSX (Darwin) which doesn't have a poll function is
+ dnl the standard libraries. Instead we use a contributed library found
+ dnl off in la la land (/sw).
+ dnl
+ dnl I don't think the above comment is true for modern Darwin (goodell@ 2010-06-01)
+ CFLAGS="$CFLAGS -I/sw/include"
+ LIBS="$LIBS -L/sw/lib -lpoll"
+ else
+ AC_MSG_ERROR([This device requires the poll function])
+ fi
+fi
+
+AC_CHECK_HEADERS([assert.h errno.h fcntl.h limits.h netdb.h netinet/in.h netinet/tcp.h])
+AC_CHECK_HEADERS([poll.h stdlib.h sys/param.h sys/poll.h sys/types.h sys/uio.h unistd.h])
+
+AC_MSG_CHECKING([if struct poll is defined]);
+AC_TRY_COMPILE([
+#if defined(HAVE_POLL_H)
+#include <poll.h>
+#endif
+#if defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+],[
+struct pollfd pollfd;
+pollfd.fd = -1;
+],[
+AC_MSG_RESULT([yes])
+],[
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([This device requires the poll function])
+])
+
+AC_MSG_CHECKING([if a simple program using poll() can be compiled]);
+AC_TRY_COMPILE([
+#if defined(HAVE_POLL_H)
+#include <poll.h>
+#endif
+#if defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+],[
+struct pollfd pollfds[2];
+int n_fds;
+pollfds[0].fd = -1;
+pollfds[1].fd = -1;
+n_fds = poll(pollfds, 2, -1);
+],[
+AC_MSG_RESULT([yes])
+],[
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([This device requires the poll function])
+])
+
+dnl
+dnl needed on AIX
+dnl
+AC_MSG_CHECKING([whether bit fields work in ip.h]);
+AC_TRY_COMPILE([
+#include <netinet/tcp.h>
+],[
+int i;
+],[
+AC_MSG_RESULT([yes])
+bit_fields=yes
+],[
+AC_MSG_RESULT([no])
+bit_fields=no
+])
+if test "$bit_fields" = "no" ; then
+ AC_MSG_RESULT([Adding -D_NO_BITFIELDS to CFLAGS])
+ CFLAGS="$CFLAGS -D_NO_BITFIELDS"
+fi
+
+
+AC_CHECK_FUNCS([gethostname])
+if test "$ac_cv_func_gethostname" = "yes" ; then
+ # Do we need to declare gethostname?
+ PAC_FUNC_NEEDS_DECL([#include <unistd.h>],gethostname)
+fi
+
+AC_SEARCH_LIBS([socket],[socket])
+AC_SEARCH_LIBS([gethostbyname],[nsl])
+
+# Check first for sys/socket.h . We check not only for existence but whether
+# it can be compiled (!), as we have seen some problems with this.
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+],[int a;],ac_cv_header_sys_socket_h=yes,ac_cv_header_sys_socket_h=no)
+if test "$ac_cv_header_sys_socket_h" = yes ; then
+ AC_DEFINE(HAVE_SYS_SOCKET_H,1,[Define if you have the <sys/socket.h> header file.])
+fi
+# Check for socklen_t . If undefined, define it as int
+# (note the conditional inclusion of sys/socket.h)
+AC_CACHE_CHECK([whether socklen_t is defined (in sys/socket.h if present)],
+pac_cv_have_socklen_t,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+typedef struct { double a; int b; } socklen_t;],
+[socklen_t a;a.a=1.0;],
+[pac_cv_have_socklen_t=no],
+[pac_cv_have_socklen_t=yes])])
+if test "X$pac_cv_have_socklen_t" = Xno ; then
+ AC_DEFINE([socklen_t],[int],[Define if socklen_t is not defined])
+fi
+
])
])dnl
dnl
diff --git a/src/mpid/common/Makefile.mk b/src/mpid/common/Makefile.mk
index c607619..1e1a92b 100644
--- a/src/mpid/common/Makefile.mk
+++ b/src/mpid/common/Makefile.mk
@@ -8,7 +8,6 @@
include $(top_srcdir)/src/mpid/common/datatype/Makefile.mk
include $(top_srcdir)/src/mpid/common/sched/Makefile.mk
-include $(top_srcdir)/src/mpid/common/sock/Makefile.mk
include $(top_srcdir)/src/mpid/common/thread/Makefile.mk
include $(top_srcdir)/src/mpid/common/hcoll/Makefile.mk
include $(top_srcdir)/src/mpid/common/timers/Makefile.mk
diff --git a/src/mpid/common/sock/Makefile.mk b/src/mpid/common/sock/Makefile.mk
deleted file mode 100644
index 7e3cfea..0000000
--- a/src/mpid/common/sock/Makefile.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-## -*- Mode: Makefile; -*-
-## vim: set ft=automake :
-##
-## (C) 2011 by Argonne National Laboratory.
-## See COPYRIGHT in top-level directory.
-##
-
-errnames_txt_files += src/mpid/common/sock/errnames.txt
-
-if BUILD_MPID_COMMON_SOCK
-
-# FIXME is top_builddir the right way to handle VPATH builds?
-AM_CPPFLAGS += \
- -I${top_srcdir}/src/mpid/common/sock \
- -I${top_builddir}/src/mpid/common/sock
-
-noinst_HEADERS += src/mpid/common/sock/mpidu_sock.h
-
-mpi_core_sources += \
- src/mpid/common/sock/sock.c
-
-# FIXME these ".i" files are awful and should be fixed somehow. They are
-# cobbled together via "#include" into sock.c. They are not idempotent ".h"
-# files, but rather a giant ".c" file that has been split into several files
-# that should be compiled only once, and only together.
-noinst_HEADERS += \
- src/mpid/common/sock/mpidu_socki.h
-
-# FIXME is top_builddir the right way to handle VPATH builds?
-AM_CPPFLAGS += \
- -I${top_srcdir}/src/mpid/common/sock \
- -I${top_builddir}/src/mpid/common/sock
-
-endif BUILD_MPID_COMMON_SOCK
-
diff --git a/src/mpid/common/sock/errnames.txt b/src/mpid/common/sock/errnames.txt
deleted file mode 100644
index 2a1323b..0000000
--- a/src/mpid/common/sock/errnames.txt
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Sock
-#
-**sock|setalloc:unable to allocate a new sock set object
-**sock|sockalloc:unable to allocate a new sock object
-**sock|badbuf:the supplied buffer contains invalid memory
-**sock|badhandle:sock contains an invalid handle
-**sock|badhdbuf:a memory fault occurred while accessing the host description string
-**sock|badhdmax:the length of the host description string must be non-negative
-**sock|badhdlen:host description string to small to store description
-**sock|badiovn:size of iov is invalid
-**sock|badiovn %d %d %d:size of iov is invalid (set=%d,sock=%d,iov_n=%d)
-**sock|badlen:bad length parameter(s)
-**sock|badlen %d %d %d %d:bad length parameter(s) (set=%d,sock=%d,min=%d,max=%d)
-**sock|badport:port number is out of range
-**sock|badport %d:port number is out of range (sock=%d)
-**sock|badsock:supplied sock is corrupt
-**sock|connclosed:connection closed by peer
-**sock|connclosed %d %d:connection closed by peer (set=%d,sock=%d)
-**sock|connfailed:connection failure
-**sock|connrefused:connection refused
-**sock|close_cancel:operation cancelled because sock was closed locally
-**sock|close_cancel %d %d:operation cancelled because sock was closed locally (set=%d,sock=%d)
-**sock|closing:sock is in the process of being closed locally
-**sock|closing %d %d:sock is in the process of being closed locally (set=%d,sock=%d)
-**sock|closing_already:a close operation is already posted
-**sock|closing_already %d %d:a close operation is already post (set=%d,sock=%d)
-**sock|getport:failed to obtain port number of the listener
-**sock|listener_bad_sock:supplied sock is not a listener
-**sock|listener_bad_sock %d %d:supplied sock is not a listener (set=%d,sock=%d)
-**sock|listener_bad_state:supplied listener sock is in a bad state
-**sock|listener_bad_state %d %d %d:supplied listener sock is in a bad state (set=%d,sock=%d,state=%d)
-**sock|listener_read:read operation not allowed on a listener
-**sock|listener_read %d %d:read operation not allowed on a listener (set=%d,sock=%d)
-**sock|listener_write:write operation not allowed on a listener
-**sock|listener_write %d %d:write operation not allowed on a listener (set=%d,sock=%d)
-**sock|notconnected:sock is not connected
-**sock|notconnected %d %d:sock is not connected (set=%d,sock=%d)
-**sock|nosock:no new sock was available to accept
-**sock|oserror:unexpected operating system error
-**sock|osnomem:operating system routine failed due to lack of memory
-**sock|osnomem %s %d %d:operating system routine %s failed due to lack of memory (set=%d,sock=%d)
-**sock|reads:attempt to perform multiple simultaneous reads
-**sock|reads %d %d:attempt to perform multiple simultaneous reads (set=%d,sock=%d)
-**sock|uninit:Sock library has not been initialized
-**sock|writes:attempt to perform multiple simultaneous writes
-**sock|writes %d %d:attempt to perform multiple simultaneous writes (set=%d,sock=%d)
-
-**sock|poll|accept:accept failed to acquire a new socket
-**sock|poll|accept %d %s:accept failed to acquire a new socket (errno=%d:%s)
-**sock|poll|badbuf %d %d %d %s:the supplied buffer contains invalid memory (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|badhandle %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d)
-**sock|poll|badhandle %d %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d:%d)
-**sock|poll|bind:unable to bind socket to port
-**sock|poll|bind %d %d %s:unable to bind socket to port (port=%d,errno=%d:%s)
-**sock|poll|connclosed %d %d %d %s:connection closed by peer (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|connfailed %d %d %d %s:connection failure (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|connrefused %d %d %s:connection refused (set=%d,sock=%d,host=%s)
-**sock|poll|eqmalloc:MPL_malloc failed to allocate memory for an event queue structure
-**sock|poll|eqfail:fatal error: failed to enqueue an event; event was lost
-**sock|poll|eqfail %d %d %d:fatal error: failed to enqueue an event; event was lost (set=%d,sock=%d,op=%d)
-**sock|poll|getport %d %s:failed to obtain port number of listener (errno=%d:%s)
-**sock|poll|listen:listen() failed
-**sock|poll|listen %d %s:listen() failed (errno=%d:%s)
-**sock|poll|nodelay:unable to set TCP no delay attribute on socket
-**sock|poll|nodelay %d %s:unable to set TCP no delay attribute on socket (errno=%d:%s)
-**sock|poll|nonblock:unable to set socket to nonblocking
-**sock|poll|nonblock %d %s:unable to set socket to nonblocking (errno=%d:%s)
-**sock|poll|oserror %d %s:unexpected operating system error (errno=%d:%s)
-**sock|poll|oserror %d %d %d %s:unexpected operating system error (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|oserror %s %d %d %d %s:unpected operating system error from %s (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|osnomem %d %d %d %s:operating system routine failed due to lack of memory (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|pipe:unable to allocate pipe to wakeup a blocking poll()
-**sock|poll|pipe %d %s:unable to allocate pipe to wakeup a blocking poll() (errno=%d:%s)
-**sock|poll|pipenonblock:unable to set wakeup pipe to nonblocking
-**sock|poll|pipenonblock %d %s:unable to set wakeup pipe to nonblocking (errno=%d:%s)
-**sock|poll|reuseaddr:unable to set reuseaddr attribute on socket
-**sock|poll|reuseaddr %d %s:unable to set reuseaddr attribute on socket (errno=%d:%s)
-**sock|poll|setrcvbufsz: unable to set the receive socket buffer size
-**sock|poll|setrcvbufsz %d %d %s: unable to set the receive socket buffer size (size=%d,errno=%d:%s)
-**sock|poll|setsndbufsz: unable to set the send socket buffer size
-**sock|poll|setsndbufsz %d %d %s: unable to set the send socket buffer size (size=%d,errno=%d:%s)
-**sock|poll|socket:unable to obtain new socket
-**sock|poll|socket %d %s:unable to obtain new socket (errno=%d:%s)
-**sock|poll|unhandledstate:encountered an unexpected state
-**sock|poll|unhandledstate %d:encountered an unexpected state (%d)
-**sock|poll|unhandledtype:encountered an unexpected sock type
-**sock|poll|unhandledtype %d:encountered an unexpected sock type (%d)
diff --git a/src/mpid/common/sock/subconfigure.m4 b/src/mpid/common/sock/subconfigure.m4
deleted file mode 100644
index 303659f..0000000
--- a/src/mpid/common/sock/subconfigure.m4
+++ /dev/null
@@ -1,142 +0,0 @@
-[#] start of __file__
-
-AC_DEFUN([PAC_SUBCFG_PREREQ_src_mpid_common_sock],[
- AM_CONDITIONAL([BUILD_MPID_COMMON_SOCK],[test "X$build_mpid_common_sock" = "Xyes"])
-])
-
-dnl _BODY handles the former role of configure in the subsystem
-AC_DEFUN([PAC_SUBCFG_BODY_src_mpid_common_sock],[
-AM_COND_IF([BUILD_MPID_COMMON_SOCK],[
-AC_MSG_NOTICE([RUNNING CONFIGURE FOR src/mpid/common/sock])
-
-# Adding this prevents the pesky "(strerror() not found)" problem, which can be
-# very frustrating in the sock code, the most likely to receive an error code
-# from the system. [goodell@ 2008-01-10]
-AC_CHECK_FUNCS([strerror])
-
-AC_ARG_ENABLE([sock-debug],
- [--enable-sock-debug - Turn on tests of the socket data structures],
- [],
- [enable_sock_debug=no])
-
-if test "$enable_sock_debug" = yes ; then
- AC_DEFINE(USE_SOCK_VERIFY,1,[Define it the socket verify macros should be enabled])
-fi
-
-AC_CHECK_FUNC([poll],[pac_cv_have_func_poll=yes],[pac_cv_have_func_poll=no])
-if test "X$pac_cv_have_func_poll" = "Xno" ; then
- if test -f /sw/include/sys/poll.h ; then
- dnl This is for Mac OSX (Darwin) which doesn't have a poll function is
- dnl the standard libraries. Instead we use a contributed library found
- dnl off in la la land (/sw).
- dnl
- dnl I don't think the above comment is true for modern Darwin (goodell@ 2010-06-01)
- CFLAGS="$CFLAGS -I/sw/include"
- LIBS="$LIBS -L/sw/lib -lpoll"
- else
- AC_MSG_ERROR([This device requires the poll function])
- fi
-fi
-
-AC_CHECK_HEADERS([assert.h errno.h fcntl.h limits.h netdb.h netinet/in.h netinet/tcp.h])
-AC_CHECK_HEADERS([poll.h stdlib.h sys/param.h sys/poll.h sys/types.h sys/uio.h unistd.h])
-
-AC_MSG_CHECKING([if struct poll is defined]);
-AC_TRY_COMPILE([
-#if defined(HAVE_POLL_H)
-#include <poll.h>
-#endif
-#if defined(HAVE_SYS_POLL_H)
-#include <sys/poll.h>
-#endif
-],[
-struct pollfd pollfd;
-pollfd.fd = -1;
-],[
-AC_MSG_RESULT([yes])
-],[
-AC_MSG_RESULT([no])
-AC_MSG_ERROR([This device requires the poll function])
-])
-
-AC_MSG_CHECKING([if a simple program using poll() can be compiled]);
-AC_TRY_COMPILE([
-#if defined(HAVE_POLL_H)
-#include <poll.h>
-#endif
-#if defined(HAVE_SYS_POLL_H)
-#include <sys/poll.h>
-#endif
-],[
-struct pollfd pollfds[2];
-int n_fds;
-pollfds[0].fd = -1;
-pollfds[1].fd = -1;
-n_fds = poll(pollfds, 2, -1);
-],[
-AC_MSG_RESULT([yes])
-],[
-AC_MSG_RESULT([no])
-AC_MSG_ERROR([This device requires the poll function])
-])
-
-dnl
-dnl needed on AIX
-dnl
-AC_MSG_CHECKING([whether bit fields work in ip.h]);
-AC_TRY_COMPILE([
-#include <netinet/tcp.h>
-],[
-int i;
-],[
-AC_MSG_RESULT([yes])
-bit_fields=yes
-],[
-AC_MSG_RESULT([no])
-bit_fields=no
-])
-if test "$bit_fields" = "no" ; then
- AC_MSG_RESULT([Adding -D_NO_BITFIELDS to CFLAGS])
- CFLAGS="$CFLAGS -D_NO_BITFIELDS"
-fi
-
-
-AC_CHECK_FUNCS([gethostname])
-if test "$ac_cv_func_gethostname" = "yes" ; then
- # Do we need to declare gethostname?
- PAC_FUNC_NEEDS_DECL([#include <unistd.h>],gethostname)
-fi
-
-AC_SEARCH_LIBS([socket],[socket])
-AC_SEARCH_LIBS([gethostbyname],[nsl])
-
-# Check first for sys/socket.h . We check not only for existence but whether
-# it can be compiled (!), as we have seen some problems with this.
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/socket.h>
-],[int a;],ac_cv_header_sys_socket_h=yes,ac_cv_header_sys_socket_h=no)
-if test "$ac_cv_header_sys_socket_h" = yes ; then
- AC_DEFINE(HAVE_SYS_SOCKET_H,1,[Define if you have the <sys/socket.h> header file.])
-fi
-# Check for socklen_t . If undefined, define it as int
-# (note the conditional inclusion of sys/socket.h)
-AC_CACHE_CHECK([whether socklen_t is defined (in sys/socket.h if present)],
-pac_cv_have_socklen_t,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-typedef struct { double a; int b; } socklen_t;],
-[socklen_t a;a.a=1.0;],
-[pac_cv_have_socklen_t=no],
-[pac_cv_have_socklen_t=yes])])
-if test "X$pac_cv_have_socklen_t" = Xno ; then
- AC_DEFINE([socklen_t],[int],[Define if socklen_t is not defined])
-fi
-
-])dnl end AM_COND_IF(BUILD_MPID_COMMON_SOCK,...)
-])dnl end _BODY
-dnl
-[#] end of __file__
http://git.mpich.org/mpich.git/commitdiff/b9d1a6cc4095382505ca58d0825eb5b54507db36
commit b9d1a6cc4095382505ca58d0825eb5b54507db36
Author: Pavan Balaji <balaji at anl.gov>
Date: Tue Feb 2 13:01:34 2016 -0600
sock: remove .i files.
These files are simply included into the sock.c file. There's no reason
to create separate .i files for them.
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/src/mpid/common/sock/Makefile.mk b/src/mpid/common/sock/Makefile.mk
index a089d18..7e3cfea 100644
--- a/src/mpid/common/sock/Makefile.mk
+++ b/src/mpid/common/sock/Makefile.mk
@@ -24,13 +24,6 @@ mpi_core_sources += \
# files, but rather a giant ".c" file that has been split into several files
# that should be compiled only once, and only together.
noinst_HEADERS += \
- src/mpid/common/sock/sock_init.i \
- src/mpid/common/sock/sock_set.i \
- src/mpid/common/sock/sock_post.i \
- src/mpid/common/sock/sock_immed.i \
- src/mpid/common/sock/sock_misc.i \
- src/mpid/common/sock/sock_wait.i \
- src/mpid/common/sock/socki_util.i \
src/mpid/common/sock/mpidu_socki.h
# FIXME is top_builddir the right way to handle VPATH builds?
diff --git a/src/mpid/common/sock/sock.c b/src/mpid/common/sock/sock.c
index 0f74dca..729cae0 100644
--- a/src/mpid/common/sock/sock.c
+++ b/src/mpid/common/sock/sock.c
@@ -208,13 +208,3980 @@ int MPIDU_Sock_SetSockBufferSize( int fd, int firm );
/* Get a string version of the address in ifaddr*/
int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen );
-/* FIXME: Why are these files included in this way? Why not make them either
- separate files or simply part of (one admittedly large) source file? */
-#include "socki_util.i"
-
-#include "sock_init.i"
-#include "sock_set.i"
-#include "sock_post.i"
-#include "sock_immed.i"
-#include "sock_misc.i"
-#include "sock_wait.i"
+
+
+/*********** socki_util.i ***********/
+
+#ifdef MPICH_IS_THREADED
+static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set);
+int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *, int );
+#endif
+
+static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo,
+ int os_errno, const char * fcname, int line, int * conn_failed);
+
+static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov,
+ const int count, int * const offsetp);
+
+static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set,
+ struct MPIDU_Sock ** sockp);
+static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock);
+
+static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo,
+ enum MPIDU_Sock_op op,
+ MPIU_Size_t num_bytes,
+ void * user_ptr, int error);
+static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set,
+ int * set_elem,
+ struct MPIDU_Sock_event * eventp);
+
+static void MPIDU_Socki_free_eventq_mem(void);
+
+struct MPIDU_Socki_eventq_table
+{
+ struct MPIDU_Socki_eventq_elem elems[MPIDU_SOCK_EVENTQ_POOL_SIZE];
+ struct MPIDU_Socki_eventq_table * next;
+};
+
+static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
+
+
+
+#define MPIDU_Socki_sock_get_pollfd(sock_) (&(sock_)->sock_set->pollfds[(sock_)->elem])
+#define MPIDU_Socki_sock_get_pollinfo(sock_) (&(sock_)->sock_set->pollinfos[(sock_)->elem])
+#define MPIDU_Socki_pollinfo_get_pollfd(pollinfo_) (&(pollinfo_)->sock_set->pollfds[(pollinfo_)->elem])
+
+
+/* Enqueue a new event. If the enqueue fails, generate an error and jump to
+ the fail_label_ */
+#define MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo_, op_, nb_, user_ptr_, event_mpi_errno_, mpi_errno_, fail_label_) \
+{ \
+ mpi_errno_ = MPIDU_Socki_event_enqueue((pollinfo_), (op_), (nb_), (user_ptr_), (event_mpi_errno_)); \
+ if (mpi_errno_ != MPI_SUCCESS) \
+ { \
+ mpi_errno_ = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, \
+ "**sock|poll|eqfail", "**sock|poll|eqfail %d %d %d", \
+ pollinfo->sock_set->id, pollinfo->sock_id, (op_)); \
+ goto fail_label_; \
+ } \
+}
+
+/* FIXME: These need to separate the operations from the thread-related
+ synchronization to ensure that the code that is independent of
+ threads is always the same. Also, the thread-level check needs
+ to be identical to all others, and there should be an option,
+ possibly embedded within special thread macros, to allow
+ runtime control of the thread level */
+
+#ifndef MPICH_IS_THREADED
+# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
+ { \
+ (pollfd_)->events |= (op_); \
+ (pollfd_)->fd = (pollinfo_)->fd; \
+ }
+# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
+ { \
+ (pollfd_)->events &= ~(op_); \
+ (pollfd_)->revents &= ~(op_); \
+ if (((pollfd_)->events & (POLLIN | POLLOUT)) == 0) \
+ { \
+ (pollfd_)->fd = -1; \
+ } \
+ }
+#else /* MPICH_IS_THREADED */
+/* FIXME: Does this need a runtime check on whether threads are in use? */
+# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
+ { \
+ (pollinfo_)->pollfd_events |= (op_); \
+ if ((pollinfo_)->sock_set->pollfds_active == NULL) \
+ { \
+ (pollfd_)->events |= (op_); \
+ (pollfd_)->fd = (pollinfo_)->fd; \
+ } \
+ else \
+ { \
+ (pollinfo_)->sock_set->pollfds_updated = TRUE; \
+ MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
+ } \
+ }
+# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
+ { \
+ (pollinfo_)->pollfd_events &= ~(op_); \
+ if ((pollinfo_)->sock_set->pollfds_active == NULL) \
+ { \
+ (pollfd_)->events &= ~(op_); \
+ (pollfd_)->revents &= ~(op_); \
+ if (((pollfd_)->events & (POLLIN | POLLOUT)) == 0) \
+ { \
+ (pollfd_)->fd = -1; \
+ } \
+ } \
+ else \
+ { \
+ (pollinfo_)->sock_set->pollfds_updated = TRUE; \
+ MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
+ } \
+ }
+#endif
+
+#define MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd_, pollinfo_, op_) ((pollfd_)->events & (op_))
+
+/* FIXME: Low usage operations like this should be a function for
+ better readability, modularity, and code size */
+#define MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo_, os_errno_, mpi_errno_, fail_label_) \
+{ \
+ int rc__; \
+ socklen_t sz__; \
+ \
+ sz__ = sizeof(os_errno_); \
+ rc__ = getsockopt((pollinfo_)->fd, SOL_SOCKET, SO_ERROR, &(os_errno_), &sz__); \
+ if (rc__ != 0) \
+ { \
+ if (errno == ENOMEM || errno == ENOBUFS) \
+ { \
+ mpi_errno_ = MPIR_Err_create_code( \
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**sock|osnomem", \
+ "**sock|osnomem %s %d %d", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id); \
+ } \
+ else \
+ { \
+ mpi_errno = MPIR_Err_create_code( \
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|oserror", \
+ "**sock|poll|oserror %s %d %d %d %s", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id, \
+ (os_errno_), MPIU_Strerror(os_errno_)); \
+ } \
+ \
+ goto fail_label_; \
+ } \
+}
+
+
+/*
+ * Validation tests
+ */
+/* FIXME: Are these really optional? Based on their definitions, it looks
+ like they should only be used when debugging the code. */
+#ifdef USE_SOCK_VERIFY
+#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_, fail_label_) \
+{ \
+ if (MPIDU_Socki_initialized <= 0) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, \
+ "**sock|uninit", NULL); \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_, mpi_errno_, fail_label_)
+
+
+#define MPIDU_SOCKI_VALIDATE_SOCK(sock_, mpi_errno_, fail_label_) \
+{ \
+ struct pollinfo * pollinfo__; \
+ \
+ if ((sock_) == NULL || (sock_)->sock_set == NULL || (sock_)->elem < 0 || \
+ (sock_)->elem >= (sock_)->sock_set->poll_array_elems) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|badsock", NULL); \
+ goto fail_label_; \
+ } \
+ \
+ pollinfo__ = MPIDU_Socki_sock_get_pollinfo(sock_); \
+ \
+ if (pollinfo__->type <= MPIDU_SOCKI_TYPE_FIRST || pollinfo__->type >= MPIDU_SOCKI_TYPE_INTERRUPTER || \
+ pollinfo__->state <= MPIDU_SOCKI_STATE_FIRST || pollinfo__->state >= MPIDU_SOCKI_STATE_LAST) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|badsock", NULL); \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_, mpi_errno_, fail_label_) \
+{ \
+ if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
+ { \
+ if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|notconnected", \
+ "**sock|notconnected %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED) \
+ { \
+ if ((pollinfo_)->os_errno == 0) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
+ "**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ } \
+ else \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
+ "**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
+ (pollinfo_)->os_errno, MPIU_Strerror((pollinfo_)->os_errno)); \
+ } \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, "**sock|closing", \
+ "**sock|closing %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW && (pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RO) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|badsock", NULL); \
+ goto fail_label_; \
+ } \
+ } \
+ else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|listener_read", \
+ "**sock|listener_read %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_, mpi_errno_, fail_label_) \
+{ \
+ if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
+ { \
+ if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|notconnected", "**sock|notconnected %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED || (pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTED_RO) \
+ { \
+ if ((pollinfo_)->os_errno == 0) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
+ "**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ } \
+ else \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code( \
+ (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
+ "**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
+ (pollinfo_)->os_errno, MPIU_Strerror((pollinfo_)->os_errno)); \
+ } \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ "**sock|closing", "**sock|closing %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ \
+ goto fail_label_; \
+ } \
+ else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|badsock", NULL); \
+ goto fail_label_; \
+ } \
+ } \
+ else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|listener_write", "**sock|listener_write %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_, mpi_errno_, fail_label_) \
+{ \
+ if ((pollinfo_)->fd < 0) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
+ "**sock|badhandle", "**sock|poll|badhandle %d %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, (pollinfo_)->fd); \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
+{ \
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLIN)) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ "**sock|reads", "**sock|reads %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ goto fail_label_; \
+ } \
+}
+
+
+#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
+{ \
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLOUT)) \
+ { \
+ (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
+ "**sock|writes", "**sock|writes %d %d", \
+ (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
+ goto fail_label_; \
+ } \
+}
+#else
+/* Use minimal to no checking */
+#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_,mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VALIDATE_SOCK(sock_,mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_,mpi_errno_,fail_label_)
+#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_,pollinfo_,mpi_errno,fail_label_)
+#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_,pollinfo_,mpi_errno,fail_label_)
+
+#endif
+
+
+#ifdef MPICH_IS_THREADED
+
+/*
+ * MPIDU_Socki_wakeup()
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_wakeup
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set)
+{
+ MPIR_THREAD_CHECK_BEGIN;
+ if (sock_set->wakeup_posted == FALSE)
+ {
+ for(;;)
+ {
+ int nb;
+ char c = 0;
+
+ nb = write(sock_set->intr_fds[1], &c, 1);
+ if (nb == 1)
+ {
+ break;
+ }
+
+ MPIU_Assertp(nb == 0 || errno == EINTR);
+ }
+
+ sock_set->wakeup_posted = TRUE;
+ }
+ MPIR_THREAD_CHECK_END;
+ return MPIDU_SOCK_SUCCESS;
+}
+/* end MPIDU_Socki_wakeup() */
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_Sock_update_sock_set
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
+ int pollfds_active_elems )
+{
+ int mpi_errno = MPI_SUCCESS;
+ int elem;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+ for (elem = 0; elem < sock_set->poll_array_elems; elem++) {
+ sock_set->pollfds[elem].events = sock_set->pollinfos[elem].pollfd_events;
+ if ((sock_set->pollfds[elem].events & (POLLIN | POLLOUT)) != 0) {
+ sock_set->pollfds[elem].fd = sock_set->pollinfos[elem].fd;
+ }
+ else {
+ sock_set->pollfds[elem].fd = -1;
+ }
+
+ if (elem < pollfds_active_elems) {
+ if (sock_set->pollfds_active == sock_set->pollfds) {
+ sock_set->pollfds[elem].revents &= ~(POLLIN | POLLOUT) | sock_set->pollfds[elem].events;
+ }
+ else {
+ sock_set->pollfds[elem].revents = sock_set->pollfds_active[elem].revents &
+ (~(POLLIN | POLLOUT) | sock_set->pollfds[elem].events);
+ }
+ }
+ else {
+ sock_set->pollfds[elem].revents = 0;
+ }
+ }
+
+ if (sock_set->pollfds_active != sock_set->pollfds) {
+ MPL_free(sock_set->pollfds_active);
+ }
+
+ sock_set->pollfds_updated = FALSE;
+
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
+ return mpi_errno;
+
+}
+
+#endif /* (MPICH_IS_THREADED) */
+
+
+/*
+ * MPIDU_Socki_os_to_mpi_errno()
+ *
+ * This routine assumes that no thread can change the state between state check before the nonblocking OS operation and the call
+ * to this routine.
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_os_to_mpi_errno
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+/* --BEGIN ERROR HANDLING-- */
+static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno, const char * fcname, int line, int * disconnected)
+{
+ int mpi_errno;
+
+ if (os_errno == ENOMEM || os_errno == ENOBUFS)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|osnomem", "**sock|poll|osnomem %d %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ *disconnected = FALSE;
+ }
+ else if (os_errno == EFAULT || os_errno == EINVAL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_BAD_BUF,
+ "**sock|badbuf", "**sock|poll|badbuf %d %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ *disconnected = FALSE;
+ }
+ else if (os_errno == EPIPE)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_CLOSED,
+ "**sock|connclosed", "**sock|poll|connclosed %d %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ *disconnected = TRUE;
+ }
+ else if (os_errno == ECONNRESET || os_errno == ENOTCONN || os_errno == ETIMEDOUT)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
+ "**sock|connfailed", "**sock|poll|connfailed %d %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->os_errno = os_errno;
+ *disconnected = TRUE;
+ }
+ else if (os_errno == EBADF)
+ {
+ /*
+ * If we have a bad file descriptor, then either the sock was bad to
+ * start with and we didn't catch it in the preliminary
+ * checks, or a sock closure was finalized after the preliminary
+ * checks were performed. The latter should not happen if
+ * the thread safety code is correctly implemented. In any case,
+ * the data structures associated with the sock are no
+ * longer valid and should not be modified. We indicate this by
+ * returning a fatal error.
+ */
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_BAD_SOCK,
+ "**sock|badsock", NULL);
+ *disconnected = FALSE;
+ }
+ else
+ {
+ /*
+ * Unexpected OS error.
+ *
+ * FIXME: technically we should never reach this section of code.
+ * What's the right way to handle this situation? Should
+ * we print an immediate message asking the user to report the errno
+ * so that we can plug the hole?
+ */
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
+ "**sock|oserror", "**sock|poll|oserror %d %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIU_Strerror(os_errno));
+ pollinfo->os_errno = os_errno;
+ *disconnected = TRUE;
+ }
+
+ return mpi_errno;
+}
+/* --END ERROR HANDLING-- */
+/* end MPIDU_Socki_os_to_mpi_errno() */
+
+
+/*
+ * MPIDU_Socki_adjust_iov()
+ *
+ * Use the specified number of bytes (nb) to adjust the iovec and associated
+ * values. If the iovec has been consumed, return
+ * true; otherwise return false.
+ *
+ * The input is an iov (MPL_IOV is just an iov) and the offset into which
+ * to start (start with entry iov[*offsetp]) and remove nb bytes from the iov.
+ * The use of the offsetp term allows use to remove values from the iov without
+ * making a copy to shift down elements when only part of the iov is
+ * consumed.
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_adjust_iov
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov, const int count, int * const offsetp)
+{
+ int offset = *offsetp;
+
+ while (offset < count)
+ {
+ if (iov[offset].MPL_IOV_LEN <= nb)
+ {
+ nb -= iov[offset].MPL_IOV_LEN;
+ offset++;
+ }
+ else
+ {
+ iov[offset].MPL_IOV_BUF = (char *) iov[offset].MPL_IOV_BUF + nb;
+ iov[offset].MPL_IOV_LEN -= nb;
+ *offsetp = offset;
+ return FALSE;
+ }
+ }
+
+ *offsetp = offset;
+ return TRUE;
+}
+/* end MPIDU_Socki_adjust_iov() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_sock_alloc
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU_Sock ** sockp)
+{
+ struct MPIDU_Sock * sock = NULL;
+ int avail_elem;
+ struct pollfd * pollfds = NULL;
+ struct pollinfo * pollinfos = NULL;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+
+ /* FIXME: Should this use the CHKPMEM macros (perm malloc)? */
+ sock = MPL_malloc(sizeof(struct MPIDU_Sock));
+ /* --BEGIN ERROR HANDLING-- */
+ if (sock == NULL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Check existing poll structures for a free element.
+ */
+ for (avail_elem = 0; avail_elem < sock_set->poll_array_sz; avail_elem++)
+ {
+ if (sock_set->pollinfos[avail_elem].sock_id == -1)
+ {
+ if (avail_elem >= sock_set->poll_array_elems)
+ {
+ sock_set->poll_array_elems = avail_elem + 1;
+ }
+
+ break;
+ }
+ }
+
+ /*
+ * No free elements were found. Larger pollfd and pollinfo arrays need to
+ * be allocated and the existing data transfered over.
+ */
+ if (avail_elem == sock_set->poll_array_sz)
+ {
+ int elem;
+
+ pollfds = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollfd));
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollfds == NULL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**nomem", 0);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ pollinfos = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollinfo));
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollinfos == NULL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**nomem", 0);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ if (sock_set->poll_array_sz > 0)
+ {
+ /*
+ * Copy information from the old arrays and then free them.
+ *
+ * In the multi-threaded case, the pollfd array can only be copied
+ * if another thread is not already blocking in poll()
+ * and thus potentially modifying the array. Furthermore, the
+ * pollfd array must not be freed if it is the one
+ * actively being used by pol().
+ */
+# ifndef MPICH_IS_THREADED
+ {
+ memcpy(pollfds, sock_set->pollfds, sock_set->poll_array_sz * sizeof(struct pollfd));
+ MPL_free(sock_set->pollfds);
+ }
+# else
+ {
+ if (sock_set->pollfds_active == NULL)
+ {
+ memcpy(pollfds, sock_set->pollfds, sock_set->poll_array_sz * sizeof(struct pollfd));
+ }
+ if (sock_set->pollfds_active != sock_set->pollfds)
+ {
+ MPL_free(sock_set->pollfds);
+ }
+ }
+# endif
+
+ memcpy(pollinfos, sock_set->pollinfos, sock_set->poll_array_sz * sizeof(struct pollinfo));
+ MPL_free(sock_set->pollinfos);
+ }
+
+ sock_set->poll_array_elems = avail_elem + 1;
+ sock_set->poll_array_sz += MPIDU_SOCK_SET_DEFAULT_SIZE;
+ sock_set->pollfds = pollfds;
+ sock_set->pollinfos = pollinfos;
+
+ /*
+ * Initialize new elements
+ */
+ for (elem = avail_elem; elem < sock_set->poll_array_sz; elem++)
+ {
+ pollfds[elem].fd = -1;
+ pollfds[elem].events = 0;
+ pollfds[elem].revents = 0;
+ }
+ for (elem = avail_elem; elem < sock_set->poll_array_sz; elem++)
+ {
+ pollinfos[elem].fd = -1;
+ pollinfos[elem].sock_set = sock_set;
+ pollinfos[elem].elem = elem;
+ pollinfos[elem].sock = NULL;
+ pollinfos[elem].sock_id = -1;
+ pollinfos[elem].type = MPIDU_SOCKI_TYPE_FIRST;
+ pollinfos[elem].state = MPIDU_SOCKI_STATE_FIRST;
+# ifdef MPICH_IS_THREADED
+ {
+ pollinfos[elem].pollfd_events = 0;
+ }
+# endif
+ }
+ }
+
+ /*
+ * Verify that memory hasn't been messed up.
+ */
+ MPIU_Assert(sock_set->pollinfos[avail_elem].sock_set == sock_set);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].elem == avail_elem);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].fd == -1);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].sock == NULL);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].sock_id == -1);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].type == MPIDU_SOCKI_TYPE_FIRST);
+ MPIU_Assert(sock_set->pollinfos[avail_elem].state == MPIDU_SOCKI_STATE_FIRST);
+# ifdef MPICH_IS_THREADED
+ {
+ MPIU_Assert(sock_set->pollinfos[avail_elem].pollfd_events == 0);
+ }
+# endif
+
+ /*
+ * Initialize newly allocated sock structure and associated poll structures
+ */
+ sock_set->pollinfos[avail_elem].sock_id = (sock_set->id << 24) | avail_elem;
+ sock_set->pollinfos[avail_elem].sock = sock;
+ sock->sock_set = sock_set;
+ sock->elem = avail_elem;
+
+ sock_set->pollfds[avail_elem].fd = -1;
+ sock_set->pollfds[avail_elem].events = 0;
+ sock_set->pollfds[avail_elem].revents = 0;
+
+# ifdef MPICH_IS_THREADED
+ {
+ MPIR_THREAD_CHECK_BEGIN;
+ if (sock_set->pollfds_active != NULL)
+ {
+ sock_set->pollfds_updated = TRUE;
+ }
+ MPIR_THREAD_CHECK_END;
+ }
+# endif
+
+ *sockp = sock;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (pollinfos != NULL)
+ {
+ MPL_free(pollinfos);
+ }
+
+ if (pollfds != NULL)
+ {
+ MPL_free(pollfds);
+ }
+
+ if (sock != NULL)
+ {
+ MPL_free(sock);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+/* end MPIDU_Socki_sock_alloc() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_sock_free
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
+{
+ struct pollfd * pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ struct pollinfo * pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+ struct MPIDU_Sock_set * sock_set = sock->sock_set;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+
+ /* FIXME: We need an abstraction for the thread sync operations */
+# ifdef MPICH_IS_THREADED
+ {
+ /*
+ * Freeing a sock while Sock_wait() is blocked in poll() is not supported
+ */
+ MPIU_Assert(sock_set->pollfds_active == NULL);
+ }
+# endif
+
+ /*
+ * Compress poll array
+ */
+ /* FIXME: move last element into current position and update sock associated with last element.
+ */
+ if (sock->elem + 1 == sock_set->poll_array_elems)
+ {
+ sock_set->poll_array_elems -= 1;
+ if (sock_set->starting_elem >= sock_set->poll_array_elems)
+ {
+ sock_set->starting_elem = 0;
+ }
+ }
+
+ /*
+ * Remove entry from the poll list and mark the entry as free
+ */
+ pollinfo->fd = -1;
+ pollinfo->sock = NULL;
+ pollinfo->sock_id = -1;
+ pollinfo->type = MPIDU_SOCKI_TYPE_FIRST;
+ pollinfo->state = MPIDU_SOCKI_STATE_FIRST;
+# ifdef MPICH_IS_THREADED
+ {
+ pollinfo->pollfd_events = 0;
+ }
+# endif
+
+ pollfd->fd = -1;
+ pollfd->events = 0;
+ pollfd->revents = 0;
+
+ /*
+ * Mark the sock as invalid so that any future use might be caught
+ */
+ sock->sock_set = NULL;
+ sock->elem = -1;
+
+ MPL_free(sock);
+
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
+}
+/* end MPIDU_Socki_sock_free() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_event_enqueue
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t op, MPIU_Size_t num_bytes,
+ void * user_ptr, int error)
+{
+ struct MPIDU_Sock_set * sock_set = pollinfo->sock_set;
+ struct MPIDU_Socki_eventq_elem * eventq_elem;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+
+ if (MPIDU_Socki_eventq_pool != NULL)
+ {
+ eventq_elem = MPIDU_Socki_eventq_pool;
+ MPIDU_Socki_eventq_pool = MPIDU_Socki_eventq_pool->next;
+ }
+ else
+ {
+ int i;
+ struct MPIDU_Socki_eventq_table *eventq_table;
+
+ eventq_table = MPL_malloc(sizeof(struct MPIDU_Socki_eventq_table));
+ /* --BEGIN ERROR HANDLING-- */
+ if (eventq_table == NULL)
+ {
+ mpi_errno = MPIR_Err_create_code(errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPI_ERR_OTHER,
+ "**sock|poll|eqmalloc", 0);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ eventq_elem = eventq_table->elems;
+
+ eventq_table->next = MPIDU_Socki_eventq_table_head;
+ MPIDU_Socki_eventq_table_head = eventq_table;
+
+ if (MPIDU_SOCK_EVENTQ_POOL_SIZE > 1)
+ {
+ MPIDU_Socki_eventq_pool = &eventq_elem[1];
+ for (i = 0; i < MPIDU_SOCK_EVENTQ_POOL_SIZE - 2; i++)
+ {
+ MPIDU_Socki_eventq_pool[i].next = &MPIDU_Socki_eventq_pool[i+1];
+ }
+ MPIDU_Socki_eventq_pool[MPIDU_SOCK_EVENTQ_POOL_SIZE - 2].next = NULL;
+ }
+ }
+
+ eventq_elem->event.op_type = op;
+ eventq_elem->event.num_bytes = num_bytes;
+ eventq_elem->event.user_ptr = user_ptr;
+ eventq_elem->event.error = error;
+ eventq_elem->set_elem = pollinfo->elem;
+ eventq_elem->next = NULL;
+
+ if (sock_set->eventq_head == NULL)
+ {
+ sock_set->eventq_head = eventq_elem;
+ }
+ else
+ {
+ sock_set->eventq_tail->next = eventq_elem;
+ }
+ sock_set->eventq_tail = eventq_elem;
+fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_EVENT_ENQUEUE);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_event_enqueue() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_event_dequeue
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, int * set_elem, struct MPIDU_Sock_event * eventp)
+{
+ struct MPIDU_Socki_eventq_elem * eventq_elem;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+
+ if (sock_set->eventq_head != NULL)
+ {
+ eventq_elem = sock_set->eventq_head;
+
+ sock_set->eventq_head = eventq_elem->next;
+ if (eventq_elem->next == NULL)
+ {
+ sock_set->eventq_tail = NULL;
+ }
+
+ *eventp = eventq_elem->event;
+ *set_elem = eventq_elem->set_elem;
+
+ eventq_elem->next = MPIDU_Socki_eventq_pool;
+ MPIDU_Socki_eventq_pool = eventq_elem;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ /* FIXME: Shouldn't this be an mpi error code? */
+ mpi_errno = MPIDU_SOCK_ERR_FAIL;
+ }
+ /* --END ERROR HANDLING-- */
+
+ MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_EVENT_DEQUEUE);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_event_dequeue() */
+
+
+/* FIXME: Who allocates eventq tables? Should there be a check that these
+ tables are empty first? */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_free_eventq_mem
+#undef FCNAME
+#define FCNAME "MPIDU_Socki_free_eventq_mem"
+static void MPIDU_Socki_free_eventq_mem(void)
+{
+ struct MPIDU_Socki_eventq_table *eventq_table, *eventq_table_next;
+ MPIDI_STATE_DECL(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+
+ eventq_table = MPIDU_Socki_eventq_table_head;
+ while (eventq_table) {
+ eventq_table_next = eventq_table->next;
+ MPL_free(eventq_table);
+ eventq_table = eventq_table_next;
+ }
+ MPIDU_Socki_eventq_table_head = NULL;
+
+ MPIDI_FUNC_EXIT(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
+}
+
+/* Provide a standard mechanism for setting the socket buffer size.
+ The value is -1 if the default size hasn't been set, 0 if no size
+ should be set, and > 0 if that size should be used */
+static int sockBufSize = -1;
+
+/* Set the socket buffer sizes on fd to the standard values (this is controlled
+ by the parameter MPICH_SOCK_BUFSIZE). If "firm" is true, require that the
+ sockets actually accept that buffer size. */
+int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
+{
+ int mpi_errno = MPI_SUCCESS;
+ int rc;
+
+ /* Get the socket buffer size if we haven't yet acquired it */
+ if (sockBufSize < 0) {
+ /* FIXME: Is this the name that we want to use (this was chosen
+ to match the original, undocumented name) */
+ rc = MPL_env2int( "MPICH_SOCKET_BUFFER_SIZE", &sockBufSize );
+ if (rc <= 0) {
+ sockBufSize = 0;
+ }
+ MPL_DBG_MSG_D(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Sock buf size = %d",sockBufSize);
+ }
+
+ if (sockBufSize > 0) {
+ int bufsz;
+ socklen_t bufsz_len;
+
+ bufsz = sockBufSize;
+ bufsz_len = sizeof(bufsz);
+ rc = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, bufsz_len);
+ if (rc == -1) {
+ MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|setsndbufsz",
+ "**sock|poll|setsndbufsz %d %d %s",
+ bufsz, errno, MPIU_Strerror(errno));
+ }
+ bufsz = sockBufSize;
+ bufsz_len = sizeof(bufsz);
+ rc = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, bufsz_len);
+ if (rc == -1) {
+ MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|setrcvbufsz",
+ "**sock|poll|setrcvbufsz %d %d %s",
+ bufsz, errno, MPIU_Strerror(errno));
+ }
+ bufsz_len = sizeof(bufsz);
+
+ if (firm) {
+ rc = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, &bufsz_len);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == 0) {
+ if (bufsz < sockBufSize * 0.9) {
+ MPL_msg_printf("WARNING: send socket buffer size differs from requested size (requested=%d, actual=%d)\n",
+ sockBufSize, bufsz);
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ bufsz_len = sizeof(bufsz);
+ rc = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, &bufsz_len);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == 0) {
+ if (bufsz < sockBufSize * 0.9) {
+ MPL_msg_printf("WARNING: receive socket buffer size differs from requested size (requested=%d, actual=%d)\n",
+ sockBufSize, bufsz);
+ }
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ }
+ fn_fail:
+ return mpi_errno;
+}
+
+/* This routine provides a string version of the address. */
+int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen )
+{
+ int i;
+ unsigned char *p = ifaddr->ifaddr;
+ for (i=0; i<ifaddr->len && maxlen > 4; i++) {
+ snprintf( str, maxlen, "%.3d.", *p++ );
+ str += 4;
+ maxlen -= 4;
+ }
+ /* Change the last period to a null; but be careful in case len was zero */
+ if (i > 0) *--str = 0;
+ else *str = 0;
+ return 0;
+}
+
+/*********** end of socki_util.i *********/
+
+/*********** sock_init.i *****************/
+
+#if defined (MPL_USE_DBG_LOGGING)
+MPL_dbg_class MPIDU_DBG_SOCK_CONNECT;
+#endif /* MPL_USE_DBG_LOGGING */
+
+/* FIXME: The usual missing documentation (what are these routines for?
+ preconditions? who calls? post conditions? */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_init
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_init(void)
+{
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
+
+#if defined (MPL_USE_DBG_LOGGING)
+ MPIDU_DBG_SOCK_CONNECT = MPL_dbg_class_alloc("SOCK_CONNECT", "sock_connect");
+#endif
+
+ MPIDU_Socki_initialized++;
+
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
+ return MPI_SUCCESS;
+}
+
+/* FIXME: Who calls? When? Should this be a finalize handler instead? */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_finalize
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_finalize(void)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
+
+ MPIDU_Socki_initialized--;
+
+ if (MPIDU_Socki_initialized == 0)
+ {
+ MPIDU_Socki_free_eventq_mem();
+ }
+
+#ifdef USE_SOCK_VERIFY
+ fn_exit:
+#endif
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
+ return mpi_errno;
+}
+
+/*********** end of sock_init.i *****************/
+
+/*********** sock_set.i *****************/
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_create_set
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
+{
+ struct MPIDU_Sock_set * sock_set = NULL;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ /*
+ * Allocate and initialized a new sock set structure
+ */
+ sock_set = MPL_malloc(sizeof(struct MPIDU_Sock_set));
+ /* --BEGIN ERROR HANDLING-- */
+ if (sock_set == NULL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|setalloc", 0);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ sock_set->id = MPIDU_Socki_set_next_id++;
+ sock_set->poll_array_sz = 0;
+ sock_set->poll_array_elems = 0;
+ sock_set->starting_elem = 0;
+ sock_set->pollfds = NULL;
+ sock_set->pollinfos = NULL;
+ sock_set->eventq_head = NULL;
+ sock_set->eventq_tail = NULL;
+ /* FIXME: Move the thread-specific operations into thread-specific
+ routines (to allow for alternative thread sync models and
+ for runtime control of thread level) */
+# ifdef MPICH_IS_THREADED
+ {
+ sock_set->pollfds_active = NULL;
+ sock_set->pollfds_updated = FALSE;
+ sock_set->wakeup_posted = FALSE;
+ sock_set->intr_fds[0] = -1;
+ sock_set->intr_fds[1] = -1;
+ sock_set->intr_sock = NULL;
+ }
+# endif
+
+# ifdef MPICH_IS_THREADED
+ MPIR_THREAD_CHECK_BEGIN;
+ {
+ struct MPIDU_Sock * sock = NULL;
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ long flags;
+ int rc;
+
+ /*
+ * Acquire a pipe (the interrupter) to wake up a blocking poll should
+ * it become necessary.
+ *
+ * Make the read descriptor nonblocking. The write descriptor is left
+ * as a blocking descriptor. The write has to
+ * succeed or the system will lock up. Should the blocking descriptor
+ * prove to be a problem, then (1) copy the above
+ * code, applying it to the write descriptor, and (2) update
+ * MPIDU_Socki_wakeup() so that it loops while write returns 0,
+ * performing a thread yield between iterations.
+ */
+ rc = pipe(sock_set->intr_fds);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc != 0)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|pipe", "**sock|poll|pipe %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ flags = fcntl(sock_set->intr_fds[0], F_GETFL, 0);
+ /* --BEGIN ERROR HANDLING-- */
+ if (flags == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
+ errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ rc = fcntl(sock_set->intr_fds[0], F_SETFL, flags | O_NONBLOCK);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
+ errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Allocate and initialize a sock structure for the interrupter pipe
+ */
+ mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ /* --BEGIN ERROR HANDLING-- */
+ if (mpi_errno != MPI_SUCCESS)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|sockalloc", NULL);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ sock_set->intr_sock = sock;
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ pollfd->fd = sock_set->intr_fds[0];
+ pollinfo->fd = sock_set->intr_fds[0];
+ pollinfo->user_ptr = NULL;
+ pollinfo->type = MPIDU_SOCKI_TYPE_INTERRUPTER;
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ pollinfo->os_errno = 0;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ }
+ MPIR_THREAD_CHECK_END;
+# endif
+
+ *sock_setp = sock_set;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (sock_set != NULL)
+ {
+# ifdef MPICH_IS_THREADED
+ MPIR_THREAD_CHECK_BEGIN;
+ {
+ if (sock_set->intr_fds[0] != -1)
+ {
+ close(sock_set->intr_fds[0]);
+ }
+
+ if (sock_set->intr_fds[1] != -1)
+ {
+ close(sock_set->intr_fds[1]);
+ }
+ }
+ MPIR_THREAD_CHECK_END;
+# endif
+
+ MPL_free(sock_set);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_close_open_sockets
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_ptr ){
+
+ int i;
+ int mpi_errno = MPI_SUCCESS;
+ struct pollinfo * pollinfos = NULL;
+ pollinfos = sock_set->pollinfos;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ /* wakeup waiting socket if mullti-threades */
+ *user_ptr = NULL;
+ for (i = 0; i < sock_set->poll_array_elems; i++) {
+ if(pollinfos[i].sock != NULL && pollinfos[i].type != MPIDU_SOCKI_TYPE_INTERRUPTER){
+ close(pollinfos[i].fd);
+ MPIDU_Socki_sock_free(pollinfos[i].sock);
+ *user_ptr = pollinfos[i].user_ptr;
+ break;
+ }
+ }
+#ifdef USE_SOCK_VERIFY
+ fn_exit:
+#endif
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
+ return mpi_errno;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_destroy_set
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
+{
+ int elem;
+ struct MPIDU_Sock_event event;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ /*
+ * FIXME: check for open socks and return an error if any are found
+ */
+
+ /*
+ * FIXME: verify no other thread is blocked in poll(). wake it up and
+ * get it to exit.
+ */
+
+ /*
+ * Close pipe for interrupting a blocking poll()
+ */
+# ifdef MPICH_IS_THREADED
+ MPIR_THREAD_CHECK_BEGIN;
+ {
+ close(sock_set->intr_fds[1]);
+ close(sock_set->intr_fds[0]);
+ MPIDU_Socki_sock_free(sock_set->intr_sock);
+
+ sock_set->pollfds_updated = FALSE;
+ sock_set->pollfds_active = NULL;
+ sock_set->wakeup_posted = FALSE;
+ sock_set->intr_fds[0] = -1;
+ sock_set->intr_fds[1] = -1;
+ sock_set->intr_sock = NULL;
+ }
+ MPIR_THREAD_CHECK_END;
+# endif
+
+ /*
+ * Clear the event queue to eliminate memory leaks
+ */
+ while (MPIDU_Socki_event_dequeue(sock_set, &elem, &event) == MPI_SUCCESS);
+
+ /*
+ * Free structures used by the sock set
+ */
+ MPL_free(sock_set->pollinfos);
+ MPL_free(sock_set->pollfds);
+
+ /*
+ * Reset the sock set fields
+ */
+ sock_set->id = ~0;
+ sock_set->poll_array_sz = 0;
+ sock_set->poll_array_elems = 0;
+ sock_set->starting_elem = 0;
+ sock_set->pollfds = NULL;
+ sock_set->pollinfos = NULL;
+ sock_set->eventq_head = NULL;
+ sock_set->eventq_tail = NULL;
+
+ /*
+ * Free the structure
+ */
+ MPL_free(sock_set);
+
+#ifdef USE_SOCK_VERIFY
+ fn_exit:
+#endif
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
+ return mpi_errno;
+}
+
+/*********** end of sock_set.i *****************/
+
+/*********** sock_post.i *****************/
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_connect_ifaddr
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+/*
+ This routine connects to a particular address (in byte form; for ipv4,
+ the address is four bytes, typically the value of h_addr_list[0] in
+ struct hostent. By avoiding a character name for an interface (we *never*
+ connect to a host; we are *always* connecting to a particular interface
+ on a host), we avoid problems with DNS services, including lack of properly
+ configured services and scalability problems. As this routine uses
+ a four-byte field, it is currently restricted to ipv4. This routine should
+ evolve to support ipv4 and ipv6 addresses.
+
+ This routine was constructed from MPIDU_Sock_post_connect by removing the
+ poorly placed use of gethostname within the middle of that routine and
+ simply using the ifaddr field that is passed to this routine.
+ MPIDU_Sock_post_connect simply uses the hostname field to get the canonical
+ IP address. The original routine and its API was retained to allow backwards
+ compatibility until it is determined that we can always use explicit addrs
+ needed in setting up the socket instead of character strings.
+ */
+int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
+ void * user_ptr,
+ MPIDU_Sock_ifaddr_t *ifaddr, int port,
+ struct MPIDU_Sock ** sockp)
+{
+ struct MPIDU_Sock * sock = NULL;
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int fd = -1;
+ struct sockaddr_in addr;
+ long flags;
+ int nodelay;
+ int rc;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ /*
+ * Create a non-blocking socket with Nagle's algorithm disabled
+ */
+ fd = socket(PF_INET, SOCK_STREAM, 0);
+ if (fd == -1) {
+ /* FIXME: It would be better to include a special formatting
+ clue for system error messages (e.g., %dSE; in the recommended
+ revision for error reporting (that is, value (errno) is an int,
+ but should be interpreted as an System Error string) */
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|socket",
+ "**sock|poll|socket %d %s", errno, MPIU_Strerror(errno));
+ }
+
+ flags = fcntl(fd, F_GETFL, 0);
+ if (flags == -1) {
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock",
+ "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ }
+ rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ if (rc == -1) {
+ MPIR_ERR_SETANDJUMP2( mpi_errno, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock",
+ "**sock|poll|nonblock %d %s",
+ errno, MPIU_Strerror(errno));
+ }
+
+ nodelay = 1;
+ rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
+ if (rc != 0) {
+ MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nodelay",
+ "**sock|poll|nodelay %d %s",
+ errno, MPIU_Strerror(errno));
+ }
+
+ /*
+ * Allocate and initialize sock and poll structures
+ *
+ * NOTE: pollfd->fd is initialized to -1. It is only set to the true fd
+ * value when an operation is posted on the sock. This
+ * (hopefully) eliminates a little overhead in the OS and avoids
+ * repetitive POLLHUP events when the connection is closed by
+ * the remote process.
+ */
+ mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ if (mpi_errno != MPI_SUCCESS) {
+ MPIR_ERR_SETANDJUMP(mpi_errno,MPIDU_SOCK_ERR_NOMEM,
+ "**sock|sockalloc");
+ }
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ pollinfo->fd = fd;
+ pollinfo->user_ptr = user_ptr;
+ pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ pollinfo->os_errno = 0;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ memcpy(&addr.sin_addr.s_addr, ifaddr->ifaddr,
+ sizeof(addr.sin_addr.s_addr));
+ addr.sin_port = htons( (unsigned short)port);
+
+ /*
+ * Set and verify the socket buffer size
+ */
+ mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
+
+ /*
+ * Attempt to establish the connection
+ */
+ MPL_DBG_STMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,{
+ char addrString[64];
+ MPIDU_Sock_AddrToStr( ifaddr, addrString, sizeof(addrString) );
+ MPL_DBG_MSG_FMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,(MPL_DBG_FDEST,
+ "Connecting to %s:%d", addrString, port ));
+ })
+
+ do
+ {
+ rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr));
+ }
+ while (rc == -1 && errno == EINTR);
+
+ if (rc == 0)
+ {
+ /* connection succeeded */
+ MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTED_RW for sock %p",sock);
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPI_SUCCESS, mpi_errno, fn_fail);
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (errno == EINPROGRESS)
+ {
+ /* connection pending */
+ MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTING for sock %p",sock);
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTING;
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+ }
+ else
+ {
+ MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_DISCONNECTED (failure in connect) for sock %p",sock);
+ pollinfo->os_errno = errno;
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+
+ if (errno == ECONNREFUSED)
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
+ "**sock|connrefused", "**sock|poll|connrefused %d %d %s",
+ pollinfo->sock_set->id, pollinfo->sock_id, ""), mpi_errno, fn_fail);
+ }
+ else
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
+ "**sock|oserror", "**sock|poll|oserror %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, errno,
+ MPIU_Strerror(errno)), mpi_errno, fn_fail);
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ *sockp = sock;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (fd != -1)
+ {
+ close(fd);
+ }
+
+ if (sock != NULL)
+ {
+ MPIDU_Socki_sock_free(sock);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+/* FIXME: What does this routine do? Why does it take a host description
+ instead of an interface name or address? */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_connect
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_connect(struct MPIDU_Sock_set * sock_set, void * user_ptr,
+ char * host_description, int port,
+ struct MPIDU_Sock ** sockp)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDU_Sock_ifaddr_t ifaddr;
+ struct hostent * hostent;
+
+ /*
+ * Convert hostname to IP address
+ *
+ * FIXME: this should handle failures caused by a backed up listener queue
+ * at the remote process. It should also use a
+ * specific interface if one is specified by the user.
+ */
+ /* FIXME: strtok may change the contents of host_description. Shouldn't
+ the host description be a const char [] and not modified by this
+ routine? */
+ strtok(host_description, " ");
+ /* FIXME: For ipv6, we should use getaddrinfo */
+ hostent = gethostbyname(host_description);
+ /* --BEGIN ERROR HANDLING-- */
+ if (hostent == NULL || hostent->h_addrtype != AF_INET) {
+ /* FIXME: Set error */
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ /* These are correct for IPv4 */
+ memcpy( ifaddr.ifaddr, (unsigned char *)hostent->h_addr_list[0], 4 );
+ ifaddr.len = 4;
+ ifaddr.type = AF_INET;
+ mpi_errno = MPIDU_Sock_post_connect_ifaddr( sock_set, user_ptr,
+ &ifaddr, port, sockp );
+ fn_exit:
+ return mpi_errno;
+}
+/* end MPIDU_Sock_post_connect() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_listen
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535 /* 2^16-1 */
+#endif
+int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
+ int * port, struct MPIDU_Sock ** sockp)
+{
+ struct MPIDU_Sock * sock;
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int fd = -1;
+ long flags;
+ int optval;
+ struct sockaddr_in addr;
+ socklen_t addr_len;
+ int rc;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ /* --BEGIN ERROR HANDLING-- */
+ if (*port < 0 || *port > USHRT_MAX)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_PORT,
+ "**sock|badport", "**sock|badport %d", *port);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Create a non-blocking socket for the listener
+ */
+ fd = socket(PF_INET, SOCK_STREAM, 0);
+ /* --BEGIN ERROR HANDLING-- */
+ if (fd == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|socket", "**sock|poll|socket %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /* set SO_REUSEADDR to a prevent a fixed service port from being bound to during subsequent invocations */
+ if (*port != 0)
+ {
+ optval = 1;
+ rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int));
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|reuseaddr", "**sock|poll|reuseaddr %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ /* make the socket non-blocking so that accept() will return immediately if no new connection is available */
+ flags = fcntl(fd, F_GETFL, 0);
+ /* --BEGIN ERROR HANDLING-- */
+ if (flags == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Bind the socket to all interfaces and the specified port. The port specified by the calling routine may be 0, indicating
+ * that the operating system can select an available port in the ephemeral port range.
+ */
+ if (*port == 0) {
+ int portnum;
+ /* see if we actually want to find values within a range */
+
+ MPIR_ERR_CHKANDJUMP(MPIR_CVAR_CH3_PORT_RANGE.low < 0 || MPIR_CVAR_CH3_PORT_RANGE.low > MPIR_CVAR_CH3_PORT_RANGE.high, mpi_errno, MPI_ERR_OTHER, "**badportrange");
+
+ /* default MPICH_PORT_RANGE is {0,0} so bind will use any available port */
+ for (portnum = MPIR_CVAR_CH3_PORT_RANGE.low; portnum <= MPIR_CVAR_CH3_PORT_RANGE.high; ++portnum) {
+ memset( (void *)&addr, 0, sizeof(addr) );
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons( (unsigned short)portnum );
+
+ rc = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
+ if (rc < 0) {
+ if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
+ close(fd);
+ break;
+ }
+ }
+ else
+ break;
+ }
+ }
+ else {
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons((unsigned short) *port);
+ rc = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|bind", "**sock|poll|bind %d %d %s", *port, errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Set and verify the socket buffer size
+ */
+ mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ if (mpi_errno) { MPIR_ERR_POP( mpi_errno ); }
+
+ /*
+ * Start listening for incoming connections...
+ */
+ rc = listen(fd, SOMAXCONN);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|listen", "**sock|poll|listen %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Get listener port. Techincally we don't need to do this if a port was
+ * specified by the calling routine; but it adds an extra error check.
+ */
+ addr_len = sizeof(addr);
+ rc = getsockname(fd, (struct sockaddr *) &addr, &addr_len);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|getport", "**sock|poll|getport %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ *port = (unsigned int) ntohs(addr.sin_port);
+
+ /*
+ * Allocate and initialize sock and poll structures. If another thread is
+ * blocking in poll(), that thread must be woke up
+ * long enough to pick up the addition of the listener socket.
+ */
+ mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ /* --BEGIN ERROR HANDLING-- */
+ if (mpi_errno != MPI_SUCCESS)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|sockalloc", NULL);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ pollinfo->fd = fd;
+ pollinfo->user_ptr = user_ptr;
+ pollinfo->type = MPIDU_SOCKI_TYPE_LISTENER;
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+
+ *sockp = sock;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (fd != -1)
+ {
+ close(fd);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+/* end MPIDU_Sock_listen() */
+
+
+/* FIXME: What does this function do? */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_read
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minlen, MPIU_Size_t maxlen,
+ MPIDU_Sock_progress_update_func_t fn)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (minlen < 1 || minlen > maxlen)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ "**sock|badlen", "**sock|badlen %d %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollinfo->read.buf.ptr = buf;
+ pollinfo->read.buf.min = minlen;
+ pollinfo->read.buf.max = maxlen;
+ pollinfo->read_iov_flag = FALSE;
+ pollinfo->read_nb = 0;
+ pollinfo->read_progress_update_fn = fn;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_post_read() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_readv
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ "**sock|badiovn", "**sock|badiovn %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollinfo->read.iov.ptr = iov;
+ pollinfo->read.iov.count = iov_n;
+ pollinfo->read.iov.offset = 0;
+ pollinfo->read_iov_flag = TRUE;
+ pollinfo->read_nb = 0;
+ pollinfo->read_progress_update_fn = fn;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_post_readv() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_write
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, MPIU_Size_t minlen, MPIU_Size_t maxlen,
+ MPIDU_Sock_progress_update_func_t fn)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (minlen < 1 || minlen > maxlen)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ "**sock|badlen", "**sock|badlen %d %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollinfo->write.buf.ptr = buf;
+ pollinfo->write.buf.min = minlen;
+ pollinfo->write.buf.max = maxlen;
+ pollinfo->write_iov_flag = FALSE;
+ pollinfo->write_nb = 0;
+ pollinfo->write_progress_update_fn = fn;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_post_write() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_writev
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ "**sock|badiovn", "**sock|badiovn %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollinfo->write.iov.ptr = iov;
+ pollinfo->write.iov.count = iov_n;
+ pollinfo->write.iov.offset = 0;
+ pollinfo->write_iov_flag = TRUE;
+ pollinfo->write_nb = 0;
+ pollinfo->write_progress_update_fn = fn;
+
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_post_writev() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_post_close
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollinfo->state == MPIDU_SOCKI_STATE_CLOSING)
+ {
+ mpi_errno = MPIR_Err_create_code(
+ mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|closing_already",
+ "**sock|closing_already %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ {
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN | POLLOUT))
+ {
+ /* --BEGIN ERROR HANDLING-- */
+ int event_mpi_errno;
+
+ event_mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_SOCK_CLOSED, "**sock|close_cancel",
+ "**sock|close_cancel %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
+
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN))
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPI_SUCCESS, mpi_errno, fn_exit);
+ }
+
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPI_SUCCESS, mpi_errno, fn_exit);
+ }
+
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
+ /* --END ERROR HANDLING-- */
+ }
+ }
+ else /* if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER) */
+ {
+ /*
+ * The event queue may contain an accept event which means that
+ * MPIDU_Sock_accept() may be legally called after
+ * MPIDU_Sock_post_close(). However, MPIDU_Sock_accept() must be
+ * called before the close event is return by
+ * MPIDU_Sock_wait().
+ */
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ }
+
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CLOSE, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
+ pollinfo->state = MPIDU_SOCKI_STATE_CLOSING;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
+ return mpi_errno;
+}
+
+/*********** end of sock_post.i *****************/
+
+/*********** sock_immed.i *****************/
+
+/* FIXME: Why is this the _immed file (what does immed stand for?) */
+
+/* FIXME: What do any of these routines do? What are the arguments?
+ Special conditions (see the FIXME on len = SSIZE_MAX)? preconditions?
+ postconditions? */
+
+/* FIXME: What does this function do? What are its arguments?
+ It appears to execute a nonblocking accept call */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_accept
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
+ struct MPIDU_Sock_set * sock_set, void * user_ptr,
+ struct MPIDU_Sock ** sockp)
+{
+ struct MPIDU_Sock * sock;
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int fd = -1;
+ struct sockaddr_in addr;
+ socklen_t addr_len;
+ long flags;
+ int nodelay;
+ int rc;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(listener, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(listener);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(listener);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollinfo->type != MPIDU_SOCKI_TYPE_LISTENER)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ "**sock|listener_bad_sock", "**sock|listener_bad_sock %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id);
+ goto fn_exit;
+ }
+
+ if (pollinfo->state != MPIDU_SOCKI_STATE_CONNECTED_RO &&
+ pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ "**sock|listener_bad_state", "**sock|listener_bad_state %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->state);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Get a socket for the new connection from the operating system.
+ * Make the socket nonblocking, and disable Nagle's
+ * alogorithm (to minimize latency of small messages).
+ */
+ addr_len = sizeof(struct sockaddr_in);
+ /* FIXME: Either use the syscall macro or correctly wrap this in a
+ test for EINTR */
+ fd = accept(pollinfo->fd, (struct sockaddr *) &addr, &addr_len);
+
+ if (pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
+ {
+ /*
+ * Unless the listener sock is being closed, add it back into the
+ * poll list so that new connections will be detected.
+ */
+ MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
+ }
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (fd == -1)
+ {
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
+ "**sock|nosock", NULL);
+ }
+ else if (errno == ENOBUFS || errno == ENOMEM)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|osnomem", NULL);
+ }
+ else if (errno == EBADF || errno == ENOTSOCK || errno == EOPNOTSUPP)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ "**sock|badhandle", "**sock|poll|badhandle %d %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id,
+ pollinfo->fd);
+ }
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
+ "**sock|poll|accept", "**sock|poll|accept %d %s",
+ errno, MPIU_Strerror(errno));
+ }
+
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ flags = fcntl(fd, F_GETFL, 0);
+ /* FIXME: There should be a simpler macro for reporting errno messages */
+ /* --BEGIN ERROR HANDLING-- */
+ if (flags == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
+ errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
+ errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ nodelay = 1;
+ rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc != 0)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nodelay", "**sock|poll|nodelay %d %s",
+ errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /*
+ * Verify that the socket buffer size is correct
+ */
+ /* FIXME: Who sets the socket buffer size? Why isn't the test
+ made at that time? */
+#if 1
+ mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
+ if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
+#else
+ if (MPIDU_Socki_socket_bufsz > 0)
+ {
+ int bufsz;
+ socklen_t bufsz_len;
+
+ bufsz_len = sizeof(bufsz);
+ rc = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, &bufsz_len);
+ /* FIXME: There's normally no need to check that the socket buffer
+ size was set to the requested size. This should only be part of
+ some more verbose diagnostic output, not a general action */
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == 0)
+ {
+ if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
+ bufsz < MPIDU_Socki_socket_bufsz * 1.0)
+ {
+ MPL_msg_printf("WARNING: send socket buffer size differs from requested size (requested=%d, actual=%d)\n",
+ MPIDU_Socki_socket_bufsz, bufsz);
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ bufsz_len = sizeof(bufsz);
+ rc = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, &bufsz_len);
+ /* FIXME: There's normally no need to check that the socket buffer
+ size was set to the requested size. This should only be part of
+ some more verbose diagnostic output, not a general action */
+ /* FIXME: Cut and paste code is a disaster waiting to happen.
+ Particularly in any non-performance critical section,
+ create a separate routine instead of using cut and paste. */
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == 0)
+ {
+ if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
+ bufsz < MPIDU_Socki_socket_bufsz * 1.0)
+ {
+ MPL_msg_printf("WARNING: receive socket buffer size differs from requested size (requested=%d, actual=%d)\n",
+ MPIDU_Socki_socket_bufsz, bufsz);
+ }
+ }
+ /* --END ERROR HANDLING-- */
+ }
+#endif
+ /*
+ * Allocate and initialize sock and poll structures.
+ *
+ * NOTE: pollfd->fd is initialized to -1. It is only set to the true fd
+ * value when an operation is posted on the sock. This
+ * (hopefully) eliminates a little overhead in the OS and avoids
+ * repetitive POLLHUP events when the connection is closed by
+ * the remote process.
+ */
+ mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ /* --BEGIN ERROR HANDLING-- */
+ if (mpi_errno != MPI_SUCCESS)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|sockalloc", NULL);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ pollinfo->fd = fd;
+ pollinfo->user_ptr = user_ptr;
+ pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ pollinfo->os_errno = 0;
+
+ *sockp = sock;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (fd != -1)
+ {
+ close(fd);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+/* end MPIDU_Sock_accept() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_read
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
+ MPIU_Size_t * num_read)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ size_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_READ);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_READ);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* FIXME: multiple passes should be made if
+ len > SSIZE_MAX and nb == SSIZE_MAX */
+ /* FIXME: This is a scary test/assignment. It needs an explanation
+ (presumably that this routine will be called again if len is
+ shortened. However, in that case, the description of the routine
+ (which is also missing!!!!) needs to be very clear about this
+ requirement. */
+ if (len > SSIZE_MAX)
+ {
+ len = SSIZE_MAX;
+ }
+
+ do
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_READ);
+ nb = read(pollinfo->fd, buf, len);
+ MPIDI_FUNC_EXIT(MPID_STATE_READ);
+ }
+ while (nb == -1 && errno == EINTR);
+
+ if (nb > 0)
+ {
+ *num_read = (MPIU_Size_t) nb;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (nb == 0)
+ {
+ *num_read = 0;
+
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
+ MPIDU_SOCK_ERR_CONN_CLOSED,
+ "**sock|connclosed", "**sock|connclosed %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id);
+
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ /* A write is posted on this connection. Enqueue an event for
+ the write indicating the connection is closed. */
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ pollinfo->write_nb, pollinfo->user_ptr,
+ mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ *num_read = 0;
+ }
+ else
+ {
+ int disconnected;
+
+ *num_read = 0;
+
+ mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno,
+ FCNAME, __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the
+ * data structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ goto fn_exit;
+ }
+
+ if (disconnected)
+ {
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ /* A write is posted on this connection. Enqueue an event
+ for the write indicating the connection is closed. */
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ pollinfo->write_nb, pollinfo->user_ptr,
+ mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_READ);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_read() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_readv
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
+ MPIU_Size_t * num_read)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ ssize_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_READV);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_READV);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /*
+ * FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
+ * fields exceeds SSIZE_MAX, an errno of EINVAL will be
+ * returned. How do we handle this? Can we place an equivalent
+ * limitation in the Sock interface?
+ */
+ do
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_READV);
+ nb = MPL_large_readv(pollinfo->fd, iov, iov_n);
+ MPIDI_FUNC_EXIT(MPID_STATE_READV);
+ }
+ while (nb == -1 && errno == EINTR);
+
+ if (nb > 0)
+ {
+ *num_read = (MPIU_Size_t) nb;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (nb == 0)
+ {
+ *num_read = 0;
+
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
+ MPIDU_SOCK_ERR_CONN_CLOSED,
+ "**sock|connclosed", "**sock|connclosed %d %d",
+ pollinfo->sock_set->id, pollinfo->sock_id);
+
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+
+ /* A write is posted on this connection. Enqueue an event
+ for the write indicating the connection is closed. */
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ pollinfo->write_nb, pollinfo->user_ptr,
+ mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ *num_read = 0;
+ }
+ else
+ {
+ int disconnected;
+
+ *num_read = 0;
+
+ mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the
+ * data structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ goto fn_exit;
+ }
+
+ if (disconnected)
+ {
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ /* A write is posted on this connection. Enqueue an event
+ for the write indicating the connection is closed. */
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
+ pollinfo->write_nb, pollinfo->user_ptr,
+ mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_READV);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_readv() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_write
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, MPIU_Size_t len,
+ MPIU_Size_t * num_written)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ ssize_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_WRITE);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /* FIXME: multiple passes should be made if len > SSIZE_MAX and nb == SSIZE_MAX */
+ if (len > SSIZE_MAX)
+ {
+ len = SSIZE_MAX;
+ }
+
+ do
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_WRITE);
+ nb = write(pollinfo->fd, buf, len);
+ MPIDI_FUNC_EXIT(MPID_STATE_WRITE);
+ }
+ while (nb == -1 && errno == EINTR);
+
+ if (nb >= 0)
+ {
+ *num_written = nb;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ *num_written = 0;
+ }
+ else
+ {
+ int disconnected;
+
+ *num_written = 0;
+
+ mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the data
+ * structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ goto fn_exit;
+ }
+
+ if (disconnected)
+ {
+ /*
+ * The connection is dead but data may still be in the socket
+ * buffer; thus, we change the state and let
+ * MPIDU_Sock_wait() clean things up.
+ */
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_write() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_writev
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIU_Size_t * num_written)
+{
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ ssize_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_WRITEV);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
+ MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
+
+ /*
+ * FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
+ * fields exceeds SSIZE_MAX, an errno of EINVAL will be
+ * returned. How do we handle this? Can we place an equivalent
+ * limitation in the Sock interface?
+ */
+ do
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_WRITEV);
+ nb = MPL_large_writev(pollinfo->fd, iov, iov_n);
+ MPIDI_FUNC_EXIT(MPID_STATE_WRITEV);
+ }
+ while (nb == -1 && errno == EINTR);
+
+ if (nb >= 0)
+ {
+ *num_written = (MPIU_Size_t) nb;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ *num_written = 0;
+ }
+ else
+ {
+ int disconnected;
+
+ *num_written = 0;
+
+ mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
+ __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the
+ * data structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ goto fn_exit;
+ }
+
+ if (disconnected)
+ {
+ /*
+ * The connection is dead but data may still be in the socket
+ * buffer; thus, we change the state and let
+ * MPIDU_Sock_wait() clean things up.
+ */
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_writev() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_wakeup
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAKEUP);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WAKEUP);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
+
+ /* FIXME: We need (1) a standardized test for including multithreaded
+ code and (2) include support for user requests for a lower-level
+ of thread safety. Finally, things like this should probably
+ be implemented as an abstraction (e.g., wakeup_progress_threads?)
+ rather than this specific code. */
+#ifdef MPICH_IS_THREADED
+ MPIR_THREAD_CHECK_BEGIN;
+ {
+ struct pollinfo * pollinfo;
+
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock_set->intr_sock);
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WAKEUP, 0, NULL,
+ mpi_errno, mpi_errno, fn_exit);
+ MPIDU_Socki_wakeup(sock_set);
+ }
+ MPIR_THREAD_CHECK_END;
+# endif
+
+#ifdef MPICH_IS_THREADED
+ fn_exit:
+#endif
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WAKEUP);
+ return mpi_errno;
+}
+/* end MPIDU_Sock_wakeup() */
+
+/*********** end of sock_immed.i *****************/
+
+/*********** sock_misc.i *****************/
+
+/* This routine is called in mpid/ch3/util/sock/ch3u_connect_sock.c */
+/* FIXME: This routine is misnamed; it is really get_interface_name (in the
+ case where there are several networks available to the calling process,
+ this picks one but even in the current code can pick a different
+ interface if a particular environment variable is set) . */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_get_host_description
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_get_host_description(int myRank,
+ char * host_description, int len)
+{
+ char * env_hostname;
+ int rc;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+ /* --BEGIN ERROR HANDLING-- */
+ if (len < 0)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
+ FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
+ "**sock|badhdmax", NULL);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /* FIXME: Is this documented? How does it work if the process manager
+ cannot give each process a different value for an environment
+ name? What if a different interface is needed? */
+ /* Use hostname supplied in environment variable, if it exists */
+ env_hostname = getenv("MPICH_INTERFACE_HOSTNAME");
+
+ if (!env_hostname) {
+ /* See if there is a per-process name for the interfaces (e.g.,
+ the process manager only delievers the same values for the
+ environment to each process */
+ char namebuf[1024];
+ MPL_snprintf( namebuf, sizeof(namebuf),
+ "MPICH_INTERFACE_HOSTNAME_R_%d", myRank );
+ env_hostname = getenv( namebuf );
+ }
+
+ if (env_hostname != NULL)
+ {
+ rc = MPL_strncpy(host_description, env_hostname, (size_t) len);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc != 0)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ "**sock|badhdlen", NULL);
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ else {
+ rc = gethostname(host_description, len);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ if (errno == EINVAL)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ "**sock|badhdlen", NULL);
+ }
+ else if (errno == EFAULT)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
+ "**sock|badhdbuf", NULL);
+ }
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIU_Strerror(errno));
+ }
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
+ return mpi_errno;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_native_to_sock
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIVE_FD fd, void *user_ptr,
+ struct MPIDU_Sock ** sockp)
+{
+ struct MPIDU_Sock * sock = NULL;
+ struct pollfd * pollfd;
+ struct pollinfo * pollinfo;
+ int rc;
+ long flags;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ /* allocate sock and poll structures */
+ mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
+ /* --BEGIN ERROR HANDLING-- */
+ if (mpi_errno != MPI_SUCCESS)
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|sockalloc", NULL);
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ pollfd = MPIDU_Socki_sock_get_pollfd(sock);
+ pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
+
+ /* set file descriptor to non-blocking */
+ flags = fcntl(fd, F_GETFL, 0);
+ /* --BEGIN ERROR HANDLING-- */
+ if (flags == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+ rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ /* --BEGIN ERROR HANDLING-- */
+ if (rc == -1)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIU_Strerror(errno));
+ goto fn_fail;
+ }
+ /* --END ERROR HANDLING-- */
+
+ /* initialize sock and poll structures */
+ pollfd->fd = -1;
+ pollfd->events = 0;
+ pollfd->revents = 0;
+
+ pollinfo->fd = fd;
+ pollinfo->user_ptr = user_ptr;
+ pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+
+ *sockp = sock;
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_SOCK_NATIVE_TO_SOCK);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ if (sock != NULL)
+ {
+ MPIDU_Socki_sock_free(sock);
+ }
+
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_set_user_ptr
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+
+ MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
+
+ if (sock != MPIDU_SOCK_INVALID_SOCK &&
+ sock->sock_set != MPIDU_SOCK_INVALID_SET)
+ {
+ MPIDU_Socki_sock_get_pollinfo(sock)->user_ptr = user_ptr;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
+ "**sock|badsock", NULL);
+ }
+ /* --END ERROR HANDLING-- */
+
+#ifdef USE_SOCK_VERIFY
+ fn_exit:
+#endif
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
+ return mpi_errno;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_get_sock_id
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
+{
+ int id;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+
+ if (sock != MPIDU_SOCK_INVALID_SOCK)
+ {
+ if (sock->sock_set != MPIDU_SOCK_INVALID_SET)
+ {
+ id = MPIDU_Socki_sock_get_pollinfo(sock)->sock_id;
+ }
+ else
+ {
+ id = -1;
+ }
+ }
+ else
+ {
+ id = -1;
+ }
+
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
+ return id;
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_get_sock_set_id
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
+{
+ int id;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+
+ if (sock_set != MPIDU_SOCK_INVALID_SET)
+ {
+ id = sock_set->id;
+ }
+ else
+ {
+ id = -1;
+ }
+
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
+ return id;
+}
+
+/* FIXME: This function violates the internationalization design by
+ using English language strings rather than the error translation mechanism.
+ This unnecessarily breaks the goal of allowing internationalization.
+ Read the design documentation and if there is a problem, raise it rather
+ than ignoring it.
+*/
+/* FIXME: It appears that this function was used instead of making use of the
+ existing MPI-2 features to extend MPI error classes and code, of to export
+ messages to non-MPI application */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_get_error_class_string
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+/* --BEGIN ERROR HANDLING-- */
+int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length)
+{
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ switch (MPIR_ERR_GET_CLASS(error))
+ {
+ case MPIDU_SOCK_ERR_FAIL:
+ MPL_strncpy(error_string, "generic socket failure", length);
+ break;
+ case MPIDU_SOCK_ERR_INIT:
+ MPL_strncpy(error_string, "socket module not initialized", length);
+ break;
+ case MPIDU_SOCK_ERR_NOMEM:
+ MPL_strncpy(error_string, "not enough memory to complete the socket operation", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_SET:
+ MPL_strncpy(error_string, "invalid socket set", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_SOCK:
+ MPL_strncpy(error_string, "invalid socket", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_HOST:
+ MPL_strncpy(error_string, "host description buffer not large enough", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_HOSTNAME:
+ MPL_strncpy(error_string, "invalid host name", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_PORT:
+ MPL_strncpy(error_string, "invalid port", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_BUF:
+ MPL_strncpy(error_string, "invalid buffer", length);
+ break;
+ case MPIDU_SOCK_ERR_BAD_LEN:
+ MPL_strncpy(error_string, "invalid length", length);
+ break;
+ case MPIDU_SOCK_ERR_SOCK_CLOSED:
+ MPL_strncpy(error_string, "socket closed", length);
+ break;
+ case MPIDU_SOCK_ERR_CONN_CLOSED:
+ MPL_strncpy(error_string, "socket connection closed", length);
+ break;
+ case MPIDU_SOCK_ERR_CONN_FAILED:
+ MPL_strncpy(error_string, "socket connection failed", length);
+ break;
+ case MPIDU_SOCK_ERR_INPROGRESS:
+ MPL_strncpy(error_string, "socket operation in progress", length);
+ break;
+ case MPIDU_SOCK_ERR_TIMEOUT:
+ MPL_strncpy(error_string, "socket operation timed out", length);
+ break;
+ case MPIDU_SOCK_ERR_INTR:
+ MPL_strncpy(error_string, "socket operation interrupted", length);
+ break;
+ case MPIDU_SOCK_ERR_NO_NEW_SOCK:
+ MPL_strncpy(error_string, "no new connection available", length);
+ break;
+ default:
+ MPL_snprintf(error_string, length, "unknown socket error %d", error);
+ break;
+ }
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
+ return MPI_SUCCESS;
+}
+/* --END ERROR HANDLING-- */
+
+/*********** end of sock_misc.i *****************/
+
+/*********** sock_wait.i *****************/
+
+/* Make sure that we can properly ensure atomic access to the poll routine */
+#ifdef MPICH_IS_THREADED
+#if !(MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY_GLOBAL)
+#error selected multi-threaded implementation is not supported
+#endif
+#endif
+
+
+static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd,
+ struct pollinfo * const pollinfo);
+static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd,
+ struct pollinfo * const pollinfo);
+static int MPIDU_Socki_handle_read(struct pollfd * const pollfd,
+ struct pollinfo * const pollinfo);
+static int MPIDU_Socki_handle_write(struct pollfd * const pollfd,
+ struct pollinfo * const pollinfo);
+static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd,
+ struct pollinfo * const pollinfo);
+
+/*
+ * MPIDU_Sock_wait()
+ *
+ * NOTES:
+ *
+ * For fatal errors, the state of the connection progresses directly to the
+ * failed state and the connection is marked inactive in
+ * the poll array. Under normal conditions, the fatal error should result in
+ * the termination of the process; but, if that
+ * doesn't happen, we try to leave the implementation in a somewhat sane state.
+ *
+ * In the multithreaded case, only one routine at a time may call this routine
+ * To permit progress by other threads, it will release any global lock or
+ * coarse-grain critical section.
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Sock_wait
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
+ struct MPIDU_Sock_event * eventp)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
+ MPIDI_STATE_DECL(MPID_STATE_POLL);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
+
+ for (;;)
+ {
+ int elem=0; /* Keep compiler happy */
+ int n_fds;
+ int n_elems;
+ int found_active_elem = FALSE;
+
+ mpi_errno = MPIDU_Socki_event_dequeue(sock_set, &elem, eventp);
+ if (mpi_errno == MPI_SUCCESS) {
+ struct pollinfo * pollinfo;
+ int flags;
+
+ if (eventp->op_type != MPIDU_SOCK_OP_CLOSE)
+ {
+ break;
+ }
+
+ pollinfo = &sock_set->pollinfos[elem];
+
+ /*
+ * Attempt to set socket back to blocking. This *should* prevent
+ * any data in the socket send buffer from being
+ * discarded. Instead close() will block until the buffer is
+ * flushed or the connection timeouts and is considered
+ * lost. Theoretically, this could cause the MPIDU_Sock_wait() to
+ * hang indefinitely; however, the calling code
+ * should ensure this will not happen by going through a shutdown
+ * protocol before posting a close operation.
+ *
+ * FIXME: If the attempt to set the socket back to blocking fails,
+ * we presently ignore it. Should we return an
+ * error? We need to define acceptible data loss at close time.
+ * MS Windows has worse problems with this, so it
+ * may not be possible to make any guarantees.
+ */
+ flags = fcntl(pollinfo->fd, F_GETFL, 0);
+ if (flags != -1)
+ {
+ fcntl(pollinfo->fd, F_SETFL, flags & ~O_NONBLOCK);
+ }
+
+ /* FIXME: return code? If an error occurs do we return it
+ instead of the error specified in the event? */
+ close(pollinfo->fd);
+
+ MPIDU_Socki_sock_free(pollinfo->sock);
+
+ break;
+ }
+
+ for(;;)
+ {
+# ifndef MPICH_IS_THREADED
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
+ millisecond_timeout);
+ MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ }
+# else /* MPICH_IS_THREADED */
+ {
+ /* If we've enabled runtime checking of the thread level,
+ then test for that and if we are *not* multithreaded,
+ just use the same code as above. Otherwise, use
+ multithreaded code (and we don't then need the
+ MPIR_THREAD_CHECK_BEGIN/END macros) */
+ if (!MPIR_ThreadInfo.isThreaded) {
+ MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
+ millisecond_timeout);
+ MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+ }
+ else
+ {
+ /*
+ * First try a non-blocking poll to see if any immediate
+ * progress can be made. This avoids the lock manipulation
+ * overhead.
+ */
+ MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems, 0);
+ MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+
+ if (n_fds == 0 && millisecond_timeout != 0)
+ {
+ int pollfds_active_elems = sock_set->poll_array_elems;
+ int err;
+
+ /* The abstraction here is a shared (blocking) resource that
+ the threads must coordinate. That means not holding
+ a lock across the blocking operation but also
+ ensuring that only one thread at a time attempts
+ to use this resource.
+
+ What isn't yet clear in this where the test is made
+ to ensure that two threads don't call the poll operation,
+ even in a nonblocking sense.
+ */
+ sock_set->pollfds_active = sock_set->pollfds;
+
+ /* Release the lock so that other threads may make
+ progress while this thread waits for something to
+ do */
+ MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Exit global critical section (sock_wait)");
+ /* MPID_THREAD_CS_EXIT(POBJ, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
+ MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); */
+ MPID_Thread_mutex_unlock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_POLL);
+ n_fds = poll(sock_set->pollfds_active,
+ pollfds_active_elems, millisecond_timeout);
+ MPIDI_FUNC_EXIT(MPID_STATE_POLL);
+
+ /* Reaquire the lock before processing any of the
+ information returned from poll */
+ MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Enter global critical section (sock_wait)");
+ /* MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
+ MPID_THREAD_CS_ENTER(POBJ, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); */
+ MPID_Thread_mutex_lock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
+
+ /*
+ * Update pollfds array if changes were posted while we
+ * were blocked in poll
+ */
+ if (sock_set->pollfds_updated) {
+ mpi_errno = MPIDI_Sock_update_sock_set(
+ sock_set, pollfds_active_elems );
+ }
+
+ sock_set->pollfds_active = NULL;
+ sock_set->wakeup_posted = FALSE;
+ }
+ } /* else !MPIR_ThreadInfo.isThreaded */
+ }
+# endif /* MPICH_IS_THREADED */
+
+ if (n_fds > 0)
+ {
+ break;
+ }
+ else if (n_fds == 0)
+ {
+ mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
+ goto fn_exit;
+ }
+ else if (errno == EINTR)
+ {
+ if (millisecond_timeout != MPIDU_SOCK_INFINITE_TIME)
+ {
+ mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
+ goto fn_exit;
+ }
+
+ continue;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (errno == ENOMEM || errno == EAGAIN)
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
+ "**sock|osnomem", NULL);
+ goto fn_exit;
+ }
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
+ "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIU_Strerror(errno));
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ elem = sock_set->starting_elem;
+ n_elems = sock_set->poll_array_elems;
+ while (n_fds > 0 && n_elems > 0)
+ {
+ /*
+ * Acquire pointers to the pollfd and pollinfo structures for the next element
+ *
+ * NOTE: These pointers could become stale, if a new sock were to be allocated during the processing of the element.
+ * At present, none of the handler routines allocate a sock, so the issue does not arise.
+ */
+ struct pollfd * const pollfd = &sock_set->pollfds[elem];
+ struct pollinfo * const pollinfo = &sock_set->pollinfos[elem];
+
+ MPIU_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
+ MPIU_Assert(pollfd->fd >= 0 || pollfd->fd == -1);
+
+ if (pollfd->fd < 0 || pollfd->revents == 0)
+ {
+ /* This optimization assumes that most FDs will not have a pending event. */
+ n_elems -= 1;
+ elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
+ continue;
+ }
+
+ if (found_active_elem == FALSE)
+ {
+ found_active_elem = TRUE;
+ sock_set->starting_elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
+ }
+
+ if (pollfd->revents & POLLNVAL)
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|badhandle",
+ "**sock|poll|badhandle %d %d %d %d", pollinfo->sock_set->id, pollinfo->sock_id, pollfd->fd, pollinfo->fd);
+ goto fn_exit;
+ }
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollfd->revents & POLLHUP)
+ {
+ mpi_errno = MPIDU_Socki_handle_pollhup(pollfd, pollinfo);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ goto fn_exit;
+ }
+ }
+
+ /* According to Stevens, some errors are reported as normal data
+ (POLLIN) and some are reported with POLLERR. */
+ if (pollfd->revents & POLLERR)
+ {
+ mpi_errno = MPIDU_Socki_handle_pollerr(pollfd, pollinfo);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ goto fn_exit;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ if (pollfd->revents & POLLIN)
+ {
+ if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ {
+ if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW ||
+ pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ {
+ mpi_errno = MPIDU_Socki_handle_read(pollfd, pollinfo);
+ /* --BEGIN ERROR HANDLING-- */
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ "**sock|poll|unhandledstate %d", pollinfo->state);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ }
+ else if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER)
+ {
+ pollfd->events &= ~POLLIN;
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_ACCEPT, 0, pollinfo->user_ptr,
+ MPI_SUCCESS, mpi_errno, fn_exit);
+ }
+ else if ((MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE) && pollinfo->type == MPIDU_SOCKI_TYPE_INTERRUPTER)
+ {
+ char c[16];
+ ssize_t nb;
+
+ do
+ {
+ nb = read(pollfd->fd, c, 16);
+ }
+ while (nb > 0 || (nb < 0 && errno == EINTR));
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ "**sock|poll|unhandledtype %d", pollinfo->type);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ if (pollfd->revents & POLLOUT)
+ {
+ if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
+ {
+ if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ {
+ mpi_errno = MPIDU_Socki_handle_write(pollfd, pollinfo);
+ /* --BEGIN ERROR HANDLING-- */
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ {
+ mpi_errno = MPIDU_Socki_handle_connect(pollfd, pollinfo);
+ /* --BEGIN ERROR HANDLING-- */
+ if (MPIR_Err_is_fatal(mpi_errno))
+ {
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ "**sock|poll|unhandledstate %d", pollinfo->state);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ "**sock|poll|unhandledtype %d", pollinfo->type);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ n_fds -= 1;
+ n_elems -= 1;
+ elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
+ }
+ }
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
+ return mpi_errno;
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_handle_pollhup
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+
+ if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ {
+ /*
+ * If a write was posted then cancel it and generate an connection closed event. If a read is posted, it will be handled
+ * by the POLLIN handler.
+ */
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollfd->events & POLLOUT)
+ {
+ int event_mpi_errno;
+
+ event_mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED,
+ "**sock|connclosed", "**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ }
+ /* --END ERROR HANDLING-- */
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ {
+ /*
+ * If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
+ * reading data, then pollfd->fd should be set to -1 and we should not be getting a POLLHUP event.
+ *
+ * There may still be data in the socket buffer, so we will let the POLLIN handler deal with the error. Once all of the
+ * data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
+ * list.
+ */
+ MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
+ {
+ /*
+ * We should never reach this state because pollfd->fd should be set to -1 if we are in the disconnected state.
+ */
+ MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ {
+ /*
+ * The process we were connecting to died. Let the POLLOUT handler deal with the error.
+ */
+ MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ pollfd->revents = POLLOUT;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ "**sock|poll|unhandledstate %d", pollinfo->state);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_handle_pollhup() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_handle_pollerr
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (pollinfo->type != MPIDU_SOCKI_TYPE_COMMUNICATION)
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
+ "**sock|poll|unhandledtype %d", pollinfo->type);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
+ {
+ /*
+ * Stevens suggests that some older version of UNIX did not properly reset so_error, which could allow POLLERR to be
+ * continuously triggered. We remove the socket from the poll list (pollfd->fd = 1) in order to prevent this issue.
+ * Here, we simple check that things are as we expect them to be.
+ */
+ MPIU_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
+
+ /* If a write was posted then cancel it and generate an write completion event */
+ if (pollfd->events & POLLOUT)
+ {
+ int disconnected;
+ int os_errno;
+ int event_mpi_errno;
+
+ MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, os_errno, mpi_errno, fn_exit);
+
+ event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, os_errno, FCNAME, __LINE__, &disconnected);
+ /* --BEGIN ERROR HANDLING-- */
+ if (MPIR_Err_is_fatal(event_mpi_errno))
+ {
+ mpi_errno = event_mpi_errno;
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ }
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
+ {
+ /*
+ * If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
+ * reading data, then pollfd->fd should be set to -1 and we should not be getting a POLLERR event.
+ *
+ * There may still be data in the socket buffer, so we will let the POLLIN handler deal with the error. Once all of the
+ * data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
+ * list.
+ */
+ MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
+ {
+ /*
+ * The process we were connecting to died. Let the POLLOUT handler deal with the error.
+ */
+ MPIU_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
+ pollfd->revents = POLLOUT;
+ }
+ else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
+ {
+ /* We are already disconnected! Why are we handling an error? */
+ MPIU_Assert(pollfd->fd == -1);
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
+ "**sock|poll|unhandledstate %d", pollinfo->state);
+ goto fn_exit;
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_handle_pollerr() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_handle_read
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+{
+ ssize_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_READ);
+ MPIDI_STATE_DECL(MPID_STATE_READV);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+
+ do
+ {
+ if (pollinfo->read_iov_flag)
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_READV);
+ nb = MPL_large_readv(pollinfo->fd, pollinfo->read.iov.ptr + pollinfo->read.iov.offset,
+ pollinfo->read.iov.count - pollinfo->read.iov.offset);
+ MPIDI_FUNC_EXIT(MPID_STATE_READV);
+ }
+ else
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_READ);
+ nb = read(pollinfo->fd, pollinfo->read.buf.ptr + pollinfo->read_nb,
+ pollinfo->read.buf.max - pollinfo->read_nb);
+ MPIDI_FUNC_EXIT(MPID_STATE_READ);
+ }
+ }
+ while (nb < 0 && errno == EINTR);
+
+ if (nb > 0)
+ {
+ int done;
+
+ pollinfo->read_nb += nb;
+
+ done = pollinfo->read_iov_flag ?
+ MPIDU_Socki_adjust_iov(nb, pollinfo->read.iov.ptr, pollinfo->read.iov.count, &pollinfo->read.iov.offset) :
+ (pollinfo->read_nb >= pollinfo->read.buf.min);
+
+ if (done)
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ MPI_SUCCESS, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ }
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else if (nb == 0)
+ {
+ int event_mpi_errno;
+
+ event_mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed",
+ "**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ }
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+
+ }
+ /* --END ERROR HANDLING-- */
+ else if (errno == EAGAIN && errno == EWOULDBLOCK)
+ {
+ /* do nothing... */
+ goto fn_exit;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ int disconnected;
+ int event_mpi_errno;
+
+ event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(event_mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the data
+ * structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ mpi_errno = event_mpi_errno;
+ goto fn_exit;
+ }
+
+ if (disconnected)
+ {
+ if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_handle_read() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_handle_write
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+{
+ ssize_t nb;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_WRITE);
+ MPIDI_STATE_DECL(MPID_STATE_WRITEV);
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+
+ do
+ {
+ if (pollinfo->write_iov_flag)
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_WRITEV);
+ nb = MPL_large_writev(pollinfo->fd, pollinfo->write.iov.ptr + pollinfo->write.iov.offset,
+ pollinfo->write.iov.count - pollinfo->write.iov.offset);
+ MPIDI_FUNC_EXIT(MPID_STATE_WRITEV);
+ }
+ else
+ {
+ MPIDI_FUNC_ENTER(MPID_STATE_WRITE);
+ nb = write(pollinfo->fd, pollinfo->write.buf.ptr + pollinfo->write_nb,
+ pollinfo->write.buf.max - pollinfo->write_nb);
+ MPIDI_FUNC_EXIT(MPID_STATE_WRITE);
+ }
+ }
+ while (nb < 0 && errno == EINTR);
+
+ if (nb >= 0)
+ {
+ int done;
+
+ pollinfo->write_nb += nb;
+
+ done = pollinfo->write_iov_flag ?
+ MPIDU_Socki_adjust_iov(nb, pollinfo->write.iov.ptr, pollinfo->write.iov.count, &pollinfo->write.iov.offset) :
+ (pollinfo->write_nb >= pollinfo->write.buf.min);
+
+ if (done)
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ MPI_SUCCESS, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ }
+ }
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ /* do nothing... */
+ goto fn_exit;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ int disconnected;
+ int event_mpi_errno;
+
+ event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
+ if (MPIR_Err_is_fatal(event_mpi_errno))
+ {
+ /*
+ * A serious error occurred. There is no guarantee that the data structures are still intact. Therefore, we avoid
+ * modifying them.
+ */
+ mpi_errno = event_mpi_errno;
+ goto fn_exit;
+ }
+
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
+ event_mpi_errno, mpi_errno, fn_exit);
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+ if (disconnected)
+ {
+ /*
+ * The connection is dead but data may still be in the socket buffer; thus, we change the state and let
+ * MPIDU_Sock_wait() clean things up.
+ */
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
+ }
+ }
+ /* --END ERROR HANDLING-- */
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_handle_write() */
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDU_Socki_handle_connect
+#undef FCNAME
+#define FCNAME MPL_QUOTE(FUNCNAME)
+static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
+{
+ struct sockaddr_in addr;
+ socklen_t addr_len;
+ int rc;
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+
+ addr_len = sizeof(struct sockaddr_in);
+ rc = getpeername(pollfd->fd, (struct sockaddr *) &addr, &addr_len);
+ if (rc == 0)
+ {
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
+ pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
+ }
+ /* --BEGIN ERROR HANDLING-- */
+ else
+ {
+ int event_mpi_errno;
+
+ MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, pollinfo->os_errno, mpi_errno, fn_exit);
+ event_mpi_errno = MPIR_Err_create_code(
+ MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed",
+ "**sock|poll|connfailed %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->os_errno,
+ MPIU_Strerror(pollinfo->os_errno));
+ MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, event_mpi_errno, mpi_errno, fn_exit);
+ pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
+ }
+ /* --END ERROR HANDLING-- */
+
+ MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
+
+ fn_exit:
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
+ return mpi_errno;
+}
+/* end MPIDU_Socki_handle_connect() */
+
+/*********** end of sock_wait.i *****************/
diff --git a/src/mpid/common/sock/sock_immed.i b/src/mpid/common/sock/sock_immed.i
deleted file mode 100644
index f5203d1..0000000
--- a/src/mpid/common/sock/sock_immed.i
+++ /dev/null
@@ -1,701 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-
-/* FIXME: Why is this the _immed file (what does immed stand for?) */
-
-/* FIXME: What do any of these routines do? What are the arguments?
- Special conditions (see the FIXME on len = SSIZE_MAX)? preconditions?
- postconditions? */
-
-/* FIXME: What does this function do? What are its arguments?
- It appears to execute a nonblocking accept call */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_accept
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_accept(struct MPIDU_Sock * listener,
- struct MPIDU_Sock_set * sock_set, void * user_ptr,
- struct MPIDU_Sock ** sockp)
-{
- struct MPIDU_Sock * sock;
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int fd = -1;
- struct sockaddr_in addr;
- socklen_t addr_len;
- long flags;
- int nodelay;
- int rc;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(listener, mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(listener);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(listener);
-
- /* --BEGIN ERROR HANDLING-- */
- if (pollinfo->type != MPIDU_SOCKI_TYPE_LISTENER)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
- "**sock|listener_bad_sock", "**sock|listener_bad_sock %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id);
- goto fn_exit;
- }
-
- if (pollinfo->state != MPIDU_SOCKI_STATE_CONNECTED_RO &&
- pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
- "**sock|listener_bad_state", "**sock|listener_bad_state %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->state);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Get a socket for the new connection from the operating system.
- * Make the socket nonblocking, and disable Nagle's
- * alogorithm (to minimize latency of small messages).
- */
- addr_len = sizeof(struct sockaddr_in);
- /* FIXME: Either use the syscall macro or correctly wrap this in a
- test for EINTR */
- fd = accept(pollinfo->fd, (struct sockaddr *) &addr, &addr_len);
-
- if (pollinfo->state != MPIDU_SOCKI_STATE_CLOSING)
- {
- /*
- * Unless the listener sock is being closed, add it back into the
- * poll list so that new connections will be detected.
- */
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
- }
-
- /* --BEGIN ERROR HANDLING-- */
- if (fd == -1)
- {
- if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
- "**sock|nosock", NULL);
- }
- else if (errno == ENOBUFS || errno == ENOMEM)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|osnomem", NULL);
- }
- else if (errno == EBADF || errno == ENOTSOCK || errno == EOPNOTSUPP)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
- "**sock|badhandle", "**sock|poll|badhandle %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id,
- pollinfo->fd);
- }
- else
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_NO_NEW_SOCK,
- "**sock|poll|accept", "**sock|poll|accept %d %s",
- errno, MPIR_Strerror(errno));
- }
-
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- flags = fcntl(fd, F_GETFL, 0);
- /* FIXME: There should be a simpler macro for reporting errno messages */
- /* --BEGIN ERROR HANDLING-- */
- if (flags == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
- errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s",
- errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- nodelay = 1;
- rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
- /* --BEGIN ERROR HANDLING-- */
- if (rc != 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nodelay", "**sock|poll|nodelay %d %s",
- errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Verify that the socket buffer size is correct
- */
- /* FIXME: Who sets the socket buffer size? Why isn't the test
- made at that time? */
-#if 1
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
- if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
-#else
- if (MPIDU_Socki_socket_bufsz > 0)
- {
- int bufsz;
- socklen_t bufsz_len;
-
- bufsz_len = sizeof(bufsz);
- rc = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, &bufsz_len);
- /* FIXME: There's normally no need to check that the socket buffer
- size was set to the requested size. This should only be part of
- some more verbose diagnostic output, not a general action */
- /* --BEGIN ERROR HANDLING-- */
- if (rc == 0)
- {
- if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
- bufsz < MPIDU_Socki_socket_bufsz * 1.0)
- {
- MPL_msg_printf("WARNING: send socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- MPIDU_Socki_socket_bufsz, bufsz);
- }
- }
- /* --END ERROR HANDLING-- */
-
- bufsz_len = sizeof(bufsz);
- rc = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, &bufsz_len);
- /* FIXME: There's normally no need to check that the socket buffer
- size was set to the requested size. This should only be part of
- some more verbose diagnostic output, not a general action */
- /* FIXME: Cut and paste code is a disaster waiting to happen.
- Particularly in any non-performance critical section,
- create a separate routine instead of using cut and paste. */
- /* --BEGIN ERROR HANDLING-- */
- if (rc == 0)
- {
- if (bufsz < MPIDU_Socki_socket_bufsz * 0.9 ||
- bufsz < MPIDU_Socki_socket_bufsz * 1.0)
- {
- MPL_msg_printf("WARNING: receive socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- MPIDU_Socki_socket_bufsz, bufsz);
- }
- }
- /* --END ERROR HANDLING-- */
- }
-#endif
- /*
- * Allocate and initialize sock and poll structures.
- *
- * NOTE: pollfd->fd is initialized to -1. It is only set to the true fd
- * value when an operation is posted on the sock. This
- * (hopefully) eliminates a little overhead in the OS and avoids
- * repetitive POLLHUP events when the connection is closed by
- * the remote process.
- */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
- /* --BEGIN ERROR HANDLING-- */
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|sockalloc", NULL);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- pollinfo->fd = fd;
- pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
- pollinfo->os_errno = 0;
-
- *sockp = sock;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (fd != -1)
- {
- close(fd);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-/* end MPIDU_Sock_accept() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_read
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len,
- size_t * num_read)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- size_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READ);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* FIXME: multiple passes should be made if
- len > SSIZE_MAX and nb == SSIZE_MAX */
- /* FIXME: This is a scary test/assignment. It needs an explanation
- (presumably that this routine will be called again if len is
- shortened. However, in that case, the description of the routine
- (which is also missing!!!!) needs to be very clear about this
- requirement. */
- if (len > SSIZE_MAX)
- {
- len = SSIZE_MAX;
- }
-
- do
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READ);
- nb = read(pollinfo->fd, buf, len);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READ);
- }
- while (nb == -1 && errno == EINTR);
-
- if (nb > 0)
- {
- *num_read = (size_t) nb;
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (nb == 0)
- {
- *num_read = 0;
-
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
- MPIDU_SOCK_ERR_CONN_CLOSED,
- "**sock|connclosed", "**sock|connclosed %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id);
-
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- /* A write is posted on this connection. Enqueue an event for
- the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
- pollinfo->write_nb, pollinfo->user_ptr,
- mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
-
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
- else if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- *num_read = 0;
- }
- else
- {
- int disconnected;
-
- *num_read = 0;
-
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno,
- FCNAME, __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the
- * data structures are still intact. Therefore, we avoid
- * modifying them.
- */
- goto fn_exit;
- }
-
- if (disconnected)
- {
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- /* A write is posted on this connection. Enqueue an event
- for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
- pollinfo->write_nb, pollinfo->user_ptr,
- mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
-
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READ);
- return mpi_errno;
-}
-/* end MPIDU_Sock_read() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_readv
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n,
- size_t * num_read)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- ssize_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READV);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /*
- * FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
- * fields exceeds SSIZE_MAX, an errno of EINVAL will be
- * returned. How do we handle this? Can we place an equivalent
- * limitation in the Sock interface?
- */
- do
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READV);
- nb = MPL_large_readv(pollinfo->fd, iov, iov_n);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READV);
- }
- while (nb == -1 && errno == EINTR);
-
- if (nb > 0)
- {
- *num_read = (size_t) nb;
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (nb == 0)
- {
- *num_read = 0;
-
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
- MPIDU_SOCK_ERR_CONN_CLOSED,
- "**sock|connclosed", "**sock|connclosed %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id);
-
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
-
- /* A write is posted on this connection. Enqueue an event
- for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
- pollinfo->write_nb, pollinfo->user_ptr,
- mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
-
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
- else if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- *num_read = 0;
- }
- else
- {
- int disconnected;
-
- *num_read = 0;
-
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
- __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the
- * data structures are still intact. Therefore, we avoid
- * modifying them.
- */
- goto fn_exit;
- }
-
- if (disconnected)
- {
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- /* A write is posted on this connection. Enqueue an event
- for the write indicating the connection is closed. */
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE,
- pollinfo->write_nb, pollinfo->user_ptr,
- mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
-
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READV);
- return mpi_errno;
-}
-/* end MPIDU_Sock_readv() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_write
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len,
- size_t * num_written)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- ssize_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* FIXME: multiple passes should be made if len > SSIZE_MAX and nb == SSIZE_MAX */
- if (len > SSIZE_MAX)
- {
- len = SSIZE_MAX;
- }
-
- do
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITE);
- nb = write(pollinfo->fd, buf, len);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITE);
- }
- while (nb == -1 && errno == EINTR);
-
- if (nb >= 0)
- {
- *num_written = nb;
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- *num_written = 0;
- }
- else
- {
- int disconnected;
-
- *num_written = 0;
-
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
- __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the data
- * structures are still intact. Therefore, we avoid
- * modifying them.
- */
- goto fn_exit;
- }
-
- if (disconnected)
- {
- /*
- * The connection is dead but data may still be in the socket
- * buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
- */
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- }
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
- return mpi_errno;
-}
-/* end MPIDU_Sock_write() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_writev
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- ssize_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /*
- * FIXME: The IEEE 1003.1 standard says that if the sum of the iov_len
- * fields exceeds SSIZE_MAX, an errno of EINVAL will be
- * returned. How do we handle this? Can we place an equivalent
- * limitation in the Sock interface?
- */
- do
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITEV);
- nb = MPL_large_writev(pollinfo->fd, iov, iov_n);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITEV);
- }
- while (nb == -1 && errno == EINTR);
-
- if (nb >= 0)
- {
- *num_written = (size_t) nb;
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- *num_written = 0;
- }
- else
- {
- int disconnected;
-
- *num_written = 0;
-
- mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME,
- __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the
- * data structures are still intact. Therefore, we avoid
- * modifying them.
- */
- goto fn_exit;
- }
-
- if (disconnected)
- {
- /*
- * The connection is dead but data may still be in the socket
- * buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
- */
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- }
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
- return mpi_errno;
-}
-/* end MPIDU_Sock_writev() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wakeup
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wakeup(struct MPIDU_Sock_set * sock_set)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAKEUP);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAKEUP);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set, mpi_errno, fn_exit);
-
- /* FIXME: We need (1) a standardized test for including multithreaded
- code and (2) include support for user requests for a lower-level
- of thread safety. Finally, things like this should probably
- be implemented as an abstraction (e.g., wakeup_progress_threads?)
- rather than this specific code. */
-#ifdef MPICH_IS_THREADED
- MPIR_THREAD_CHECK_BEGIN;
- {
- struct pollinfo * pollinfo;
-
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock_set->intr_sock);
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WAKEUP, 0, NULL,
- mpi_errno, mpi_errno, fn_exit);
- MPIDU_Socki_wakeup(sock_set);
- }
- MPIR_THREAD_CHECK_END;
-# endif
-
-#ifdef MPICH_IS_THREADED
- fn_exit:
-#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAKEUP);
- return mpi_errno;
-}
-/* end MPIDU_Sock_wakeup() */
-
-
diff --git a/src/mpid/common/sock/sock_init.i b/src/mpid/common/sock/sock_init.i
deleted file mode 100644
index 70ec261..0000000
--- a/src/mpid/common/sock/sock_init.i
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#if defined (MPL_USE_DBG_LOGGING)
-MPL_dbg_class MPIDU_DBG_SOCK_CONNECT;
-#endif /* MPL_USE_DBG_LOGGING */
-
-/* FIXME: The usual missing documentation (what are these routines for?
- preconditions? who calls? post conditions? */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_init
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_init(void)
-{
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
-
-#if defined (MPL_USE_DBG_LOGGING)
- MPIDU_DBG_SOCK_CONNECT = MPL_dbg_class_alloc("SOCK_CONNECT", "sock_connect");
-#endif
-
- MPIDU_Socki_initialized++;
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
- return MPI_SUCCESS;
-}
-
-/* FIXME: Who calls? When? Should this be a finalize handler instead? */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_finalize
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_finalize(void)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
-
- MPIDU_Socki_initialized--;
-
- if (MPIDU_Socki_initialized == 0)
- {
- MPIDU_Socki_free_eventq_mem();
- }
-
-#ifdef USE_SOCK_VERIFY
- fn_exit:
-#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
- return mpi_errno;
-}
diff --git a/src/mpid/common/sock/sock_misc.i b/src/mpid/common/sock/sock_misc.i
deleted file mode 100644
index bb8b1a1..0000000
--- a/src/mpid/common/sock/sock_misc.i
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-/* This routine is called in mpid/ch3/util/sock/ch3u_connect_sock.c */
-/* FIXME: This routine is misnamed; it is really get_interface_name (in the
- case where there are several networks available to the calling process,
- this picks one but even in the current code can pick a different
- interface if a particular environment variable is set) . */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_host_description
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_host_description(int myRank,
- char * host_description, int len)
-{
- char * env_hostname;
- int rc;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- /* --BEGIN ERROR HANDLING-- */
- if (len < 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
- FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
- "**sock|badhdmax", NULL);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- /* FIXME: Is this documented? How does it work if the process manager
- cannot give each process a different value for an environment
- name? What if a different interface is needed? */
- /* Use hostname supplied in environment variable, if it exists */
- env_hostname = getenv("MPICH_INTERFACE_HOSTNAME");
-
- if (!env_hostname) {
- /* See if there is a per-process name for the interfaces (e.g.,
- the process manager only delievers the same values for the
- environment to each process */
- char namebuf[1024];
- MPL_snprintf( namebuf, sizeof(namebuf),
- "MPICH_INTERFACE_HOSTNAME_R_%d", myRank );
- env_hostname = getenv( namebuf );
- }
-
- if (env_hostname != NULL)
- {
- rc = MPL_strncpy(host_description, env_hostname, (size_t) len);
- /* --BEGIN ERROR HANDLING-- */
- if (rc != 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
- "**sock|badhdlen", NULL);
- }
- /* --END ERROR HANDLING-- */
- }
- else {
- rc = gethostname(host_description, len);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- if (errno == EINVAL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
- "**sock|badhdlen", NULL);
- }
- else if (errno == EFAULT)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_HOST,
- "**sock|badhdbuf", NULL);
- }
- else
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
- }
- }
- /* --END ERROR HANDLING-- */
- }
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
- return mpi_errno;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_native_to_sock
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_native_to_sock(struct MPIDU_Sock_set * sock_set, MPIDU_SOCK_NATIVE_FD fd, void *user_ptr,
- struct MPIDU_Sock ** sockp)
-{
- struct MPIDU_Sock * sock = NULL;
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int rc;
- long flags;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCK_NATIVE_TO_SOCK);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCK_NATIVE_TO_SOCK);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- /* allocate sock and poll structures */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
- /* --BEGIN ERROR HANDLING-- */
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|sockalloc", NULL);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- /* set file descriptor to non-blocking */
- flags = fcntl(fd, F_GETFL, 0);
- /* --BEGIN ERROR HANDLING-- */
- if (flags == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /* initialize sock and poll structures */
- pollfd->fd = -1;
- pollfd->events = 0;
- pollfd->revents = 0;
-
- pollinfo->fd = fd;
- pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
-
- *sockp = sock;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCK_NATIVE_TO_SOCK);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (sock != NULL)
- {
- MPIDU_Socki_sock_free(sock);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_set_user_ptr
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_set_user_ptr(struct MPIDU_Sock * sock, void * user_ptr)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- if (sock != MPIDU_SOCK_INVALID_SOCK &&
- sock->sock_set != MPIDU_SOCK_INVALID_SET)
- {
- MPIDU_Socki_sock_get_pollinfo(sock)->user_ptr = user_ptr;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK,
- "**sock|badsock", NULL);
- }
- /* --END ERROR HANDLING-- */
-
-#ifdef USE_SOCK_VERIFY
- fn_exit:
-#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- return mpi_errno;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_id
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_id(struct MPIDU_Sock * sock)
-{
- int id;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
-
- if (sock != MPIDU_SOCK_INVALID_SOCK)
- {
- if (sock->sock_set != MPIDU_SOCK_INVALID_SET)
- {
- id = MPIDU_Socki_sock_get_pollinfo(sock)->sock_id;
- }
- else
- {
- id = -1;
- }
- }
- else
- {
- id = -1;
- }
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
- return id;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_set_id
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_set_id(struct MPIDU_Sock_set * sock_set)
-{
- int id;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
-
- if (sock_set != MPIDU_SOCK_INVALID_SET)
- {
- id = sock_set->id;
- }
- else
- {
- id = -1;
- }
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
- return id;
-}
-
-/* FIXME: This function violates the internationalization design by
- using English language strings rather than the error translation mechanism.
- This unnecessarily breaks the goal of allowing internationalization.
- Read the design documentation and if there is a problem, raise it rather
- than ignoring it.
-*/
-/* FIXME: It appears that this function was used instead of making use of the
- existing MPI-2 features to extend MPI error classes and code, of to export
- messages to non-MPI application */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_error_class_string
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-/* --BEGIN ERROR HANDLING-- */
-int MPIDU_Sock_get_error_class_string(int error, char *error_string, size_t length)
-{
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
- switch (MPIR_ERR_GET_CLASS(error))
- {
- case MPIDU_SOCK_ERR_FAIL:
- MPL_strncpy(error_string, "generic socket failure", length);
- break;
- case MPIDU_SOCK_ERR_INIT:
- MPL_strncpy(error_string, "socket module not initialized", length);
- break;
- case MPIDU_SOCK_ERR_NOMEM:
- MPL_strncpy(error_string, "not enough memory to complete the socket operation", length);
- break;
- case MPIDU_SOCK_ERR_BAD_SET:
- MPL_strncpy(error_string, "invalid socket set", length);
- break;
- case MPIDU_SOCK_ERR_BAD_SOCK:
- MPL_strncpy(error_string, "invalid socket", length);
- break;
- case MPIDU_SOCK_ERR_BAD_HOST:
- MPL_strncpy(error_string, "host description buffer not large enough", length);
- break;
- case MPIDU_SOCK_ERR_BAD_HOSTNAME:
- MPL_strncpy(error_string, "invalid host name", length);
- break;
- case MPIDU_SOCK_ERR_BAD_PORT:
- MPL_strncpy(error_string, "invalid port", length);
- break;
- case MPIDU_SOCK_ERR_BAD_BUF:
- MPL_strncpy(error_string, "invalid buffer", length);
- break;
- case MPIDU_SOCK_ERR_BAD_LEN:
- MPL_strncpy(error_string, "invalid length", length);
- break;
- case MPIDU_SOCK_ERR_SOCK_CLOSED:
- MPL_strncpy(error_string, "socket closed", length);
- break;
- case MPIDU_SOCK_ERR_CONN_CLOSED:
- MPL_strncpy(error_string, "socket connection closed", length);
- break;
- case MPIDU_SOCK_ERR_CONN_FAILED:
- MPL_strncpy(error_string, "socket connection failed", length);
- break;
- case MPIDU_SOCK_ERR_INPROGRESS:
- MPL_strncpy(error_string, "socket operation in progress", length);
- break;
- case MPIDU_SOCK_ERR_TIMEOUT:
- MPL_strncpy(error_string, "socket operation timed out", length);
- break;
- case MPIDU_SOCK_ERR_INTR:
- MPL_strncpy(error_string, "socket operation interrupted", length);
- break;
- case MPIDU_SOCK_ERR_NO_NEW_SOCK:
- MPL_strncpy(error_string, "no new connection available", length);
- break;
- default:
- MPL_snprintf(error_string, length, "unknown socket error %d", error);
- break;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
- return MPI_SUCCESS;
-}
-/* --END ERROR HANDLING-- */
diff --git a/src/mpid/common/sock/sock_post.i b/src/mpid/common/sock/sock_post.i
deleted file mode 100644
index 61818d6..0000000
--- a/src/mpid/common/sock/sock_post.i
+++ /dev/null
@@ -1,729 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-/* FIXME: Provide an overview for the functions in this file */
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_connect_ifaddr
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-/*
- This routine connects to a particular address (in byte form; for ipv4,
- the address is four bytes, typically the value of h_addr_list[0] in
- struct hostent. By avoiding a character name for an interface (we *never*
- connect to a host; we are *always* connecting to a particular interface
- on a host), we avoid problems with DNS services, including lack of properly
- configured services and scalability problems. As this routine uses
- a four-byte field, it is currently restricted to ipv4. This routine should
- evolve to support ipv4 and ipv6 addresses.
-
- This routine was constructed from MPIDU_Sock_post_connect by removing the
- poorly placed use of gethostname within the middle of that routine and
- simply using the ifaddr field that is passed to this routine.
- MPIDU_Sock_post_connect simply uses the hostname field to get the canonical
- IP address. The original routine and its API was retained to allow backwards
- compatibility until it is determined that we can always use explicit addrs
- needed in setting up the socket instead of character strings.
- */
-int MPIDU_Sock_post_connect_ifaddr( struct MPIDU_Sock_set * sock_set,
- void * user_ptr,
- MPIDU_Sock_ifaddr_t *ifaddr, int port,
- struct MPIDU_Sock ** sockp)
-{
- struct MPIDU_Sock * sock = NULL;
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int fd = -1;
- struct sockaddr_in addr;
- long flags;
- int nodelay;
- int rc;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- /*
- * Create a non-blocking socket with Nagle's algorithm disabled
- */
- fd = socket(PF_INET, SOCK_STREAM, 0);
- if (fd == -1) {
- /* FIXME: It would be better to include a special formatting
- clue for system error messages (e.g., %dSE; in the recommended
- revision for error reporting (that is, value (errno) is an int,
- but should be interpreted as an System Error string) */
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|socket",
- "**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
- }
-
- flags = fcntl(fd, F_GETFL, 0);
- if (flags == -1) {
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock",
- "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
- }
- rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- if (rc == -1) {
- MPIR_ERR_SETANDJUMP2( mpi_errno, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock",
- "**sock|poll|nonblock %d %s",
- errno, MPIR_Strerror(errno));
- }
-
- nodelay = 1;
- rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
- if (rc != 0) {
- MPIR_ERR_SETANDJUMP2(mpi_errno,MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nodelay",
- "**sock|poll|nodelay %d %s",
- errno, MPIR_Strerror(errno));
- }
-
- /*
- * Allocate and initialize sock and poll structures
- *
- * NOTE: pollfd->fd is initialized to -1. It is only set to the true fd
- * value when an operation is posted on the sock. This
- * (hopefully) eliminates a little overhead in the OS and avoids
- * repetitive POLLHUP events when the connection is closed by
- * the remote process.
- */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
- if (mpi_errno != MPI_SUCCESS) {
- MPIR_ERR_SETANDJUMP(mpi_errno,MPIDU_SOCK_ERR_NOMEM,
- "**sock|sockalloc");
- }
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- pollinfo->fd = fd;
- pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_COMMUNICATION;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
- pollinfo->os_errno = 0;
-
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- memcpy(&addr.sin_addr.s_addr, ifaddr->ifaddr,
- sizeof(addr.sin_addr.s_addr));
- addr.sin_port = htons( (unsigned short)port);
-
- /*
- * Set and verify the socket buffer size
- */
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
- if (mpi_errno) { MPIR_ERR_POP(mpi_errno); }
-
- /*
- * Attempt to establish the connection
- */
- MPL_DBG_STMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,{
- char addrString[64];
- MPIDU_Sock_AddrToStr( ifaddr, addrString, sizeof(addrString) );
- MPL_DBG_MSG_FMT(MPIDU_DBG_SOCK_CONNECT,TYPICAL,(MPL_DBG_FDEST,
- "Connecting to %s:%d", addrString, port ));
- })
-
- do
- {
- rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr));
- }
- while (rc == -1 && errno == EINTR);
-
- if (rc == 0)
- {
- /* connection succeeded */
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTED_RW for sock %p",sock);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPI_SUCCESS, mpi_errno, fn_fail);
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (errno == EINPROGRESS)
- {
- /* connection pending */
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_CONNECTING for sock %p",sock);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTING;
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
- }
- else
- {
- MPL_DBG_MSG_P(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Setting state to SOCKI_STATE_DISCONNECTED (failure in connect) for sock %p",sock);
- pollinfo->os_errno = errno;
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
-
- if (errno == ECONNREFUSED)
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
- "**sock|connrefused", "**sock|poll|connrefused %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, ""), mpi_errno, fn_fail);
- }
- else
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, user_ptr, MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED,
- "**sock|oserror", "**sock|poll|oserror %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, errno,
- MPIR_Strerror(errno)), mpi_errno, fn_fail);
- }
- }
- /* --END ERROR HANDLING-- */
-
- *sockp = sock;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT_IFADDR);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (fd != -1)
- {
- close(fd);
- }
-
- if (sock != NULL)
- {
- MPIDU_Socki_sock_free(sock);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-/* FIXME: What does this routine do? Why does it take a host description
- instead of an interface name or address? */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_connect
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_connect(struct MPIDU_Sock_set * sock_set, void * user_ptr,
- char * host_description, int port,
- struct MPIDU_Sock ** sockp)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIDU_Sock_ifaddr_t ifaddr;
- struct hostent * hostent;
-
- /*
- * Convert hostname to IP address
- *
- * FIXME: this should handle failures caused by a backed up listener queue
- * at the remote process. It should also use a
- * specific interface if one is specified by the user.
- */
- /* FIXME: strtok may change the contents of host_description. Shouldn't
- the host description be a const char [] and not modified by this
- routine? */
- strtok(host_description, " ");
- /* FIXME: For ipv6, we should use getaddrinfo */
- hostent = gethostbyname(host_description);
- /* --BEGIN ERROR HANDLING-- */
- if (hostent == NULL || hostent->h_addrtype != AF_INET) {
- /* FIXME: Set error */
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- /* These are correct for IPv4 */
- memcpy( ifaddr.ifaddr, (unsigned char *)hostent->h_addr_list[0], 4 );
- ifaddr.len = 4;
- ifaddr.type = AF_INET;
- mpi_errno = MPIDU_Sock_post_connect_ifaddr( sock_set, user_ptr,
- &ifaddr, port, sockp );
- fn_exit:
- return mpi_errno;
-}
-/* end MPIDU_Sock_post_connect() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_listen
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-#ifndef USHRT_MAX
-#define USHRT_MAX 65535 /* 2^16-1 */
-#endif
-int MPIDU_Sock_listen(struct MPIDU_Sock_set * sock_set, void * user_ptr,
- int * port, struct MPIDU_Sock ** sockp)
-{
- struct MPIDU_Sock * sock;
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int fd = -1;
- long flags;
- int optval;
- struct sockaddr_in addr;
- socklen_t addr_len;
- int rc;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- /* --BEGIN ERROR HANDLING-- */
- if (*port < 0 || *port > USHRT_MAX)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_PORT,
- "**sock|badport", "**sock|badport %d", *port);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Create a non-blocking socket for the listener
- */
- fd = socket(PF_INET, SOCK_STREAM, 0);
- /* --BEGIN ERROR HANDLING-- */
- if (fd == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|socket", "**sock|poll|socket %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /* set SO_REUSEADDR to a prevent a fixed service port from being bound to during subsequent invocations */
- if (*port != 0)
- {
- optval = 1;
- rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int));
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|reuseaddr", "**sock|poll|reuseaddr %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- }
-
- /* make the socket non-blocking so that accept() will return immediately if no new connection is available */
- flags = fcntl(fd, F_GETFL, 0);
- /* --BEGIN ERROR HANDLING-- */
- if (flags == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|nonblock", "**sock|poll|nonblock %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Bind the socket to all interfaces and the specified port. The port specified by the calling routine may be 0, indicating
- * that the operating system can select an available port in the ephemeral port range.
- */
- if (*port == 0) {
- int portnum;
- /* see if we actually want to find values within a range */
-
- MPIR_ERR_CHKANDJUMP(MPIR_CVAR_CH3_PORT_RANGE.low < 0 || MPIR_CVAR_CH3_PORT_RANGE.low > MPIR_CVAR_CH3_PORT_RANGE.high, mpi_errno, MPI_ERR_OTHER, "**badportrange");
-
- /* default MPICH_PORT_RANGE is {0,0} so bind will use any available port */
- for (portnum = MPIR_CVAR_CH3_PORT_RANGE.low; portnum <= MPIR_CVAR_CH3_PORT_RANGE.high; ++portnum) {
- memset( (void *)&addr, 0, sizeof(addr) );
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
- addr.sin_port = htons( (unsigned short)portnum );
-
- rc = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
- if (rc < 0) {
- if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
- close(fd);
- break;
- }
- }
- else
- break;
- }
- }
- else {
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
- addr.sin_port = htons((unsigned short) *port);
- rc = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
- }
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|bind", "**sock|poll|bind %d %d %s", *port, errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Set and verify the socket buffer size
- */
- mpi_errno = MPIDU_Sock_SetSockBufferSize( fd, 1 );
- if (mpi_errno) { MPIR_ERR_POP( mpi_errno ); }
-
- /*
- * Start listening for incoming connections...
- */
- rc = listen(fd, SOMAXCONN);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|listen", "**sock|poll|listen %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Get listener port. Techincally we don't need to do this if a port was
- * specified by the calling routine; but it adds an extra error check.
- */
- addr_len = sizeof(addr);
- rc = getsockname(fd, (struct sockaddr *) &addr, &addr_len);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|getport", "**sock|poll|getport %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- *port = (unsigned int) ntohs(addr.sin_port);
-
- /*
- * Allocate and initialize sock and poll structures. If another thread is
- * blocking in poll(), that thread must be woke up
- * long enough to pick up the addition of the listener socket.
- */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
- /* --BEGIN ERROR HANDLING-- */
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|sockalloc", NULL);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- pollinfo->fd = fd;
- pollinfo->user_ptr = user_ptr;
- pollinfo->type = MPIDU_SOCKI_TYPE_LISTENER;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
-
- *sockp = sock;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (fd != -1)
- {
- close(fd);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-/* end MPIDU_Sock_listen() */
-
-
-/* FIXME: What does this function do? */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_read
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_read(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
- MPIDU_Sock_progress_update_func_t fn)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* --BEGIN ERROR HANDLING-- */
- if (minlen < 1 || minlen > maxlen)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
- "**sock|badlen", "**sock|badlen %d %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- pollinfo->read.buf.ptr = buf;
- pollinfo->read.buf.min = minlen;
- pollinfo->read.buf.max = maxlen;
- pollinfo->read_iov_flag = FALSE;
- pollinfo->read_nb = 0;
- pollinfo->read_progress_update_fn = fn;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
- return mpi_errno;
-}
-/* end MPIDU_Sock_post_read() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_readv
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_readv(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* --BEGIN ERROR HANDLING-- */
- if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
- "**sock|badiovn", "**sock|badiovn %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- pollinfo->read.iov.ptr = iov;
- pollinfo->read.iov.count = iov_n;
- pollinfo->read.iov.offset = 0;
- pollinfo->read_iov_flag = TRUE;
- pollinfo->read_nb = 0;
- pollinfo->read_progress_update_fn = fn;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
- return mpi_errno;
-}
-/* end MPIDU_Sock_post_readv() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_write
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_write(struct MPIDU_Sock * sock, void * buf, size_t minlen, size_t maxlen,
- MPIDU_Sock_progress_update_func_t fn)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* --BEGIN ERROR HANDLING-- */
- if (minlen < 1 || minlen > maxlen)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
- "**sock|badlen", "**sock|badlen %d %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id, minlen, maxlen);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- pollinfo->write.buf.ptr = buf;
- pollinfo->write.buf.min = minlen;
- pollinfo->write.buf.max = maxlen;
- pollinfo->write_iov_flag = FALSE;
- pollinfo->write_nb = 0;
- pollinfo->write_progress_update_fn = fn;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
- return mpi_errno;
-}
-/* end MPIDU_Sock_post_write() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_writev
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_writev(struct MPIDU_Sock * sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo, mpi_errno, fn_exit);
- MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd, pollinfo, mpi_errno, fn_exit);
-
- /* --BEGIN ERROR HANDLING-- */
- if (iov_n < 1 || iov_n > MPL_IOV_LIMIT)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_LEN,
- "**sock|badiovn", "**sock|badiovn %d %d %d",
- pollinfo->sock_set->id, pollinfo->sock_id, iov_n);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- pollinfo->write.iov.ptr = iov;
- pollinfo->write.iov.count = iov_n;
- pollinfo->write.iov.offset = 0;
- pollinfo->write_iov_flag = TRUE;
- pollinfo->write_nb = 0;
- pollinfo->write_progress_update_fn = fn;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLOUT);
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
- return mpi_errno;
-}
-/* end MPIDU_Sock_post_writev() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_close
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_close(struct MPIDU_Sock * sock)
-{
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
-
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- MPIDU_SOCKI_VALIDATE_SOCK(sock, mpi_errno, fn_exit);
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- MPIDU_SOCKI_VALIDATE_FD(pollinfo, mpi_errno, fn_exit);
-
- /* --BEGIN ERROR HANDLING-- */
- if (pollinfo->state == MPIDU_SOCKI_STATE_CLOSING)
- {
- mpi_errno = MPIR_Err_create_code(
- mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|closing_already",
- "**sock|closing_already %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
- {
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN | POLLOUT))
- {
- /* --BEGIN ERROR HANDLING-- */
- int event_mpi_errno;
-
- event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_SOCK_CLOSED, "**sock|close_cancel",
- "**sock|close_cancel %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
-
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLIN))
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
- MPI_SUCCESS, mpi_errno, fn_exit);
- }
-
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- MPI_SUCCESS, mpi_errno, fn_exit);
- }
-
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
- /* --END ERROR HANDLING-- */
- }
- }
- else /* if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER) */
- {
- /*
- * The event queue may contain an accept event which means that
- * MPIDU_Sock_accept() may be legally called after
- * MPIDU_Sock_post_close(). However, MPIDU_Sock_accept() must be
- * called before the close event is return by
- * MPIDU_Sock_wait().
- */
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
- }
-
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CLOSE, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_CLOSING;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
-}
-
-
diff --git a/src/mpid/common/sock/sock_set.i b/src/mpid/common/sock/sock_set.i
deleted file mode 100644
index fcdd78c..0000000
--- a/src/mpid/common/sock/sock_set.i
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_create_set
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_create_set(struct MPIDU_Sock_set ** sock_setp)
-{
- struct MPIDU_Sock_set * sock_set = NULL;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- /*
- * Allocate and initialized a new sock set structure
- */
- sock_set = MPL_malloc(sizeof(struct MPIDU_Sock_set));
- /* --BEGIN ERROR HANDLING-- */
- if (sock_set == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|setalloc", 0);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- sock_set->id = MPIDU_Socki_set_next_id++;
- sock_set->poll_array_sz = 0;
- sock_set->poll_array_elems = 0;
- sock_set->starting_elem = 0;
- sock_set->pollfds = NULL;
- sock_set->pollinfos = NULL;
- sock_set->eventq_head = NULL;
- sock_set->eventq_tail = NULL;
- /* FIXME: Move the thread-specific operations into thread-specific
- routines (to allow for alternative thread sync models and
- for runtime control of thread level) */
-# ifdef MPICH_IS_THREADED
- {
- sock_set->pollfds_active = NULL;
- sock_set->pollfds_updated = FALSE;
- sock_set->wakeup_posted = FALSE;
- sock_set->intr_fds[0] = -1;
- sock_set->intr_fds[1] = -1;
- sock_set->intr_sock = NULL;
- }
-# endif
-
-# ifdef MPICH_IS_THREADED
- MPIR_THREAD_CHECK_BEGIN;
- {
- struct MPIDU_Sock * sock = NULL;
- struct pollfd * pollfd;
- struct pollinfo * pollinfo;
- long flags;
- int rc;
-
- /*
- * Acquire a pipe (the interrupter) to wake up a blocking poll should
- * it become necessary.
- *
- * Make the read descriptor nonblocking. The write descriptor is left
- * as a blocking descriptor. The write has to
- * succeed or the system will lock up. Should the blocking descriptor
- * prove to be a problem, then (1) copy the above
- * code, applying it to the write descriptor, and (2) update
- * MPIDU_Socki_wakeup() so that it loops while write returns 0,
- * performing a thread yield between iterations.
- */
- rc = pipe(sock_set->intr_fds);
- /* --BEGIN ERROR HANDLING-- */
- if (rc != 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|pipe", "**sock|poll|pipe %d %s", errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- flags = fcntl(sock_set->intr_fds[0], F_GETFL, 0);
- /* --BEGIN ERROR HANDLING-- */
- if (flags == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
- errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- rc = fcntl(sock_set->intr_fds[0], F_SETFL, flags | O_NONBLOCK);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == -1)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|pipenonblock", "**sock|poll|pipenonblock %d %s",
- errno, MPIR_Strerror(errno));
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Allocate and initialize a sock structure for the interrupter pipe
- */
- mpi_errno = MPIDU_Socki_sock_alloc(sock_set, &sock);
- /* --BEGIN ERROR HANDLING-- */
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|sockalloc", NULL);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- sock_set->intr_sock = sock;
-
- pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
-
- pollfd->fd = sock_set->intr_fds[0];
- pollinfo->fd = sock_set->intr_fds[0];
- pollinfo->user_ptr = NULL;
- pollinfo->type = MPIDU_SOCKI_TYPE_INTERRUPTER;
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- pollinfo->os_errno = 0;
-
- MPIDU_SOCKI_POLLFD_OP_SET(pollfd, pollinfo, POLLIN);
- }
- MPIR_THREAD_CHECK_END;
-# endif
-
- *sock_setp = sock_set;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (sock_set != NULL)
- {
-# ifdef MPICH_IS_THREADED
- MPIR_THREAD_CHECK_BEGIN;
- {
- if (sock_set->intr_fds[0] != -1)
- {
- close(sock_set->intr_fds[0]);
- }
-
- if (sock_set->intr_fds[1] != -1)
- {
- close(sock_set->intr_fds[1]);
- }
- }
- MPIR_THREAD_CHECK_END;
-# endif
-
- MPL_free(sock_set);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_close_open_sockets
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_close_open_sockets(struct MPIDU_Sock_set * sock_set, void** user_ptr ){
-
- int i;
- int mpi_errno = MPI_SUCCESS;
- struct pollinfo * pollinfos = NULL;
- pollinfos = sock_set->pollinfos;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
- /* wakeup waiting socket if mullti-threades */
- *user_ptr = NULL;
- for (i = 0; i < sock_set->poll_array_elems; i++) {
- if(pollinfos[i].sock != NULL && pollinfos[i].type != MPIDU_SOCKI_TYPE_INTERRUPTER){
- close(pollinfos[i].fd);
- MPIDU_Socki_sock_free(pollinfos[i].sock);
- *user_ptr = pollinfos[i].user_ptr;
- break;
- }
- }
-#ifdef USE_SOCK_VERIFY
- fn_exit:
-#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CLOSE_OPEN_SOCKETS);
- return mpi_errno;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_destroy_set
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_destroy_set(struct MPIDU_Sock_set * sock_set)
-{
- int elem;
- struct MPIDU_Sock_event event;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
-
- MPIDU_SOCKI_VERIFY_INIT(mpi_errno, fn_exit);
-
- /*
- * FIXME: check for open socks and return an error if any are found
- */
-
- /*
- * FIXME: verify no other thread is blocked in poll(). wake it up and
- * get it to exit.
- */
-
- /*
- * Close pipe for interrupting a blocking poll()
- */
-# ifdef MPICH_IS_THREADED
- MPIR_THREAD_CHECK_BEGIN;
- {
- close(sock_set->intr_fds[1]);
- close(sock_set->intr_fds[0]);
- MPIDU_Socki_sock_free(sock_set->intr_sock);
-
- sock_set->pollfds_updated = FALSE;
- sock_set->pollfds_active = NULL;
- sock_set->wakeup_posted = FALSE;
- sock_set->intr_fds[0] = -1;
- sock_set->intr_fds[1] = -1;
- sock_set->intr_sock = NULL;
- }
- MPIR_THREAD_CHECK_END;
-# endif
-
- /*
- * Clear the event queue to eliminate memory leaks
- */
- while (MPIDU_Socki_event_dequeue(sock_set, &elem, &event) == MPI_SUCCESS);
-
- /*
- * Free structures used by the sock set
- */
- MPL_free(sock_set->pollinfos);
- MPL_free(sock_set->pollfds);
-
- /*
- * Reset the sock set fields
- */
- sock_set->id = ~0;
- sock_set->poll_array_sz = 0;
- sock_set->poll_array_elems = 0;
- sock_set->starting_elem = 0;
- sock_set->pollfds = NULL;
- sock_set->pollinfos = NULL;
- sock_set->eventq_head = NULL;
- sock_set->eventq_tail = NULL;
-
- /*
- * Free the structure
- */
- MPL_free(sock_set);
-
-#ifdef USE_SOCK_VERIFY
- fn_exit:
-#endif
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- return mpi_errno;
-}
diff --git a/src/mpid/common/sock/sock_wait.i b/src/mpid/common/sock/sock_wait.i
deleted file mode 100644
index 658ac23..0000000
--- a/src/mpid/common/sock/sock_wait.i
+++ /dev/null
@@ -1,822 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-/* Make sure that we can properly ensure atomic access to the poll routine */
-#ifdef MPICH_IS_THREADED
-#if !(MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL)
-#error selected multi-threaded implementation is not supported
-#endif
-#endif
-
-
-static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd,
- struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd,
- struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_read(struct pollfd * const pollfd,
- struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_write(struct pollfd * const pollfd,
- struct pollinfo * const pollinfo);
-static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd,
- struct pollinfo * const pollinfo);
-
-/*
- * MPIDU_Sock_wait()
- *
- * NOTES:
- *
- * For fatal errors, the state of the connection progresses directly to the
- * failed state and the connection is marked inactive in
- * the poll array. Under normal conditions, the fatal error should result in
- * the termination of the process; but, if that
- * doesn't happen, we try to leave the implementation in a somewhat sane state.
- *
- * In the multithreaded case, only one routine at a time may call this routine
- * To permit progress by other threads, it will release any global lock or
- * coarse-grain critical section.
- */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wait
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
- struct MPIDU_Sock_event * eventp)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_POLL);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
-
- for (;;)
- {
- int elem=0; /* Keep compiler happy */
- int n_fds;
- int n_elems;
- int found_active_elem = FALSE;
-
- mpi_errno = MPIDU_Socki_event_dequeue(sock_set, &elem, eventp);
- if (mpi_errno == MPI_SUCCESS) {
- struct pollinfo * pollinfo;
- int flags;
-
- if (eventp->op_type != MPIDU_SOCK_OP_CLOSE)
- {
- break;
- }
-
- pollinfo = &sock_set->pollinfos[elem];
-
- /*
- * Attempt to set socket back to blocking. This *should* prevent
- * any data in the socket send buffer from being
- * discarded. Instead close() will block until the buffer is
- * flushed or the connection timeouts and is considered
- * lost. Theoretically, this could cause the MPIDU_Sock_wait() to
- * hang indefinitely; however, the calling code
- * should ensure this will not happen by going through a shutdown
- * protocol before posting a close operation.
- *
- * FIXME: If the attempt to set the socket back to blocking fails,
- * we presently ignore it. Should we return an
- * error? We need to define acceptible data loss at close time.
- * MS Windows has worse problems with this, so it
- * may not be possible to make any guarantees.
- */
- flags = fcntl(pollinfo->fd, F_GETFL, 0);
- if (flags != -1)
- {
- fcntl(pollinfo->fd, F_SETFL, flags & ~O_NONBLOCK);
- }
-
- /* FIXME: return code? If an error occurs do we return it
- instead of the error specified in the event? */
- close(pollinfo->fd);
-
- MPIDU_Socki_sock_free(pollinfo->sock);
-
- break;
- }
-
- for(;;)
- {
-# ifndef MPICH_IS_THREADED
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
- n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
- millisecond_timeout);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
- }
-# else /* MPICH_IS_THREADED */
- {
- /* If we've enabled runtime checking of the thread level,
- then test for that and if we are *not* multithreaded,
- just use the same code as above. Otherwise, use
- multithreaded code (and we don't then need the
- MPIR_THREAD_CHECK_BEGIN/END macros) */
- if (!MPIR_ThreadInfo.isThreaded) {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
- n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
- millisecond_timeout);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
- }
- else
- {
- /*
- * First try a non-blocking poll to see if any immediate
- * progress can be made. This avoids the lock manipulation
- * overhead.
- */
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
- n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems, 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
-
- if (n_fds == 0 && millisecond_timeout != 0)
- {
- int pollfds_active_elems = sock_set->poll_array_elems;
- int err;
-
- /* The abstraction here is a shared (blocking) resource that
- the threads must coordinate. That means not holding
- a lock across the blocking operation but also
- ensuring that only one thread at a time attempts
- to use this resource.
-
- What isn't yet clear in this where the test is made
- to ensure that two threads don't call the poll operation,
- even in a nonblocking sense.
- */
- sock_set->pollfds_active = sock_set->pollfds;
-
- /* Release the lock so that other threads may make
- progress while this thread waits for something to
- do */
- MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Exit global critical section (sock_wait)");
- /* MPID_THREAD_CS_EXIT(POBJ, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
- MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); */
- MPID_Thread_mutex_unlock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_POLL);
- n_fds = poll(sock_set->pollfds_active,
- pollfds_active_elems, millisecond_timeout);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_POLL);
-
- /* Reaquire the lock before processing any of the
- information returned from poll */
- MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Enter global critical section (sock_wait)");
- /* MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
- MPID_THREAD_CS_ENTER(POBJ, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX); */
- MPID_Thread_mutex_lock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
-
- /*
- * Update pollfds array if changes were posted while we
- * were blocked in poll
- */
- if (sock_set->pollfds_updated) {
- mpi_errno = MPIDI_Sock_update_sock_set(
- sock_set, pollfds_active_elems );
- }
-
- sock_set->pollfds_active = NULL;
- sock_set->wakeup_posted = FALSE;
- }
- } /* else !MPIR_ThreadInfo.isThreaded */
- }
-# endif /* MPICH_IS_THREADED */
-
- if (n_fds > 0)
- {
- break;
- }
- else if (n_fds == 0)
- {
- mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
- goto fn_exit;
- }
- else if (errno == EINTR)
- {
- if (millisecond_timeout != MPIDU_SOCK_INFINITE_TIME)
- {
- mpi_errno = MPIDU_SOCK_ERR_TIMEOUT;
- goto fn_exit;
- }
-
- continue;
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (errno == ENOMEM || errno == EAGAIN)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**sock|osnomem", NULL);
- goto fn_exit;
- }
- else
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL,
- "**sock|oserror", "**sock|poll|oserror %d %s", errno, MPIR_Strerror(errno));
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
-
- elem = sock_set->starting_elem;
- n_elems = sock_set->poll_array_elems;
- while (n_fds > 0 && n_elems > 0)
- {
- /*
- * Acquire pointers to the pollfd and pollinfo structures for the next element
- *
- * NOTE: These pointers could become stale, if a new sock were to be allocated during the processing of the element.
- * At present, none of the handler routines allocate a sock, so the issue does not arise.
- */
- struct pollfd * const pollfd = &sock_set->pollfds[elem];
- struct pollinfo * const pollinfo = &sock_set->pollinfos[elem];
-
- MPIR_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
- MPIR_Assert(pollfd->fd >= 0 || pollfd->fd == -1);
-
- if (pollfd->fd < 0 || pollfd->revents == 0)
- {
- /* This optimization assumes that most FDs will not have a pending event. */
- n_elems -= 1;
- elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
- continue;
- }
-
- if (found_active_elem == FALSE)
- {
- found_active_elem = TRUE;
- sock_set->starting_elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
- }
-
- if (pollfd->revents & POLLNVAL)
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|badhandle",
- "**sock|poll|badhandle %d %d %d %d", pollinfo->sock_set->id, pollinfo->sock_id, pollfd->fd, pollinfo->fd);
- goto fn_exit;
- }
-
- /* --BEGIN ERROR HANDLING-- */
- if (pollfd->revents & POLLHUP)
- {
- mpi_errno = MPIDU_Socki_handle_pollhup(pollfd, pollinfo);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- goto fn_exit;
- }
- }
-
- /* According to Stevens, some errors are reported as normal data
- (POLLIN) and some are reported with POLLERR. */
- if (pollfd->revents & POLLERR)
- {
- mpi_errno = MPIDU_Socki_handle_pollerr(pollfd, pollinfo);
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- goto fn_exit;
- }
- }
- /* --END ERROR HANDLING-- */
-
- if (pollfd->revents & POLLIN)
- {
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
- {
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW ||
- pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
- {
- mpi_errno = MPIDU_Socki_handle_read(pollfd, pollinfo);
- /* --BEGIN ERROR HANDLING-- */
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
- "**sock|poll|unhandledstate %d", pollinfo->state);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- }
- else if (pollinfo->type == MPIDU_SOCKI_TYPE_LISTENER)
- {
- pollfd->events &= ~POLLIN;
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_ACCEPT, 0, pollinfo->user_ptr,
- MPI_SUCCESS, mpi_errno, fn_exit);
- }
- else if ((MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE) && pollinfo->type == MPIDU_SOCKI_TYPE_INTERRUPTER)
- {
- char c[16];
- ssize_t nb;
-
- do
- {
- nb = read(pollfd->fd, c, 16);
- }
- while (nb > 0 || (nb < 0 && errno == EINTR));
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
- "**sock|poll|unhandledtype %d", pollinfo->type);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
-
- if (pollfd->revents & POLLOUT)
- {
- if (pollinfo->type == MPIDU_SOCKI_TYPE_COMMUNICATION)
- {
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
- {
- mpi_errno = MPIDU_Socki_handle_write(pollfd, pollinfo);
- /* --BEGIN ERROR HANDLING-- */
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
- {
- mpi_errno = MPIDU_Socki_handle_connect(pollfd, pollinfo);
- /* --BEGIN ERROR HANDLING-- */
- if (MPIR_Err_is_fatal(mpi_errno))
- {
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
- "**sock|poll|unhandledstate %d", pollinfo->state);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
- "**sock|poll|unhandledtype %d", pollinfo->type);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
- }
-
- n_fds -= 1;
- n_elems -= 1;
- elem = (elem + 1 < sock_set->poll_array_elems) ? elem + 1 : 0;
- }
- }
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_pollhup
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_pollhup(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
-
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
- {
- /*
- * If a write was posted then cancel it and generate an connection closed event. If a read is posted, it will be handled
- * by the POLLIN handler.
- */
- /* --BEGIN ERROR HANDLING-- */
- if (pollfd->events & POLLOUT)
- {
- int event_mpi_errno;
-
- event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED,
- "**sock|connclosed", "**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- }
- /* --END ERROR HANDLING-- */
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
- {
- /*
- * If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
- * reading data, then pollfd->fd should be set to -1 and we should not be getting a POLLHUP event.
- *
- * There may still be data in the socket buffer, so we will let the POLLIN handler deal with the error. Once all of the
- * data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
- * list.
- */
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
- {
- /*
- * We should never reach this state because pollfd->fd should be set to -1 if we are in the disconnected state.
- */
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED && pollfd->fd == -1);
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
- {
- /*
- * The process we were connecting to died. Let the POLLOUT handler deal with the error.
- */
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
- pollfd->revents = POLLOUT;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
- "**sock|poll|unhandledstate %d", pollinfo->state);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLHUP);
- return mpi_errno;
-}
-/* end MPIDU_Socki_handle_pollhup() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_pollerr
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_pollerr(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
-
- /* --BEGIN ERROR HANDLING-- */
- if (pollinfo->type != MPIDU_SOCKI_TYPE_COMMUNICATION)
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledtype",
- "**sock|poll|unhandledtype %d", pollinfo->type);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RW)
- {
- /*
- * Stevens suggests that some older version of UNIX did not properly reset so_error, which could allow POLLERR to be
- * continuously triggered. We remove the socket from the poll list (pollfd->fd = 1) in order to prevent this issue.
- * Here, we simple check that things are as we expect them to be.
- */
- MPIR_Assert((pollfd->events & (POLLIN | POLLOUT)) || pollfd->fd == -1);
-
- /* If a write was posted then cancel it and generate an write completion event */
- if (pollfd->events & POLLOUT)
- {
- int disconnected;
- int os_errno;
- int event_mpi_errno;
-
- MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, os_errno, mpi_errno, fn_exit);
-
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, os_errno, FCNAME, __LINE__, &disconnected);
- /* --BEGIN ERROR HANDLING-- */
- if (MPIR_Err_is_fatal(event_mpi_errno))
- {
- mpi_errno = event_mpi_errno;
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- }
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO)
- {
- /*
- * If we are in the read-only state, then we should only get an error if we are looking to read data. If we are not
- * reading data, then pollfd->fd should be set to -1 and we should not be getting a POLLERR event.
- *
- * There may still be data in the socket buffer, so we will let the POLLIN handler deal with the error. Once all of the
- * data has been read, the POLLIN handler will change the connection state and remove the connection from the active poll
- * list.
- */
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTED_RO && (pollfd->events & POLLIN) && (pollfd->revents & POLLIN));
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING)
- {
- /*
- * The process we were connecting to died. Let the POLLOUT handler deal with the error.
- */
- MPIR_Assert(pollinfo->state == MPIDU_SOCKI_STATE_CONNECTING && (pollfd->events & POLLOUT));
- pollfd->revents = POLLOUT;
- }
- else if (pollinfo->state == MPIDU_SOCKI_STATE_DISCONNECTED)
- {
- /* We are already disconnected! Why are we handling an error? */
- MPIR_Assert(pollfd->fd == -1);
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|poll|unhandledstate",
- "**sock|poll|unhandledstate %d", pollinfo->state);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_POLLERR);
- return mpi_errno;
-}
-/* end MPIDU_Socki_handle_pollerr() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_read
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_read(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
-{
- ssize_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READ);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_READV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
-
- do
- {
- if (pollinfo->read_iov_flag)
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READV);
- nb = MPL_large_readv(pollinfo->fd, pollinfo->read.iov.ptr + pollinfo->read.iov.offset,
- pollinfo->read.iov.count - pollinfo->read.iov.offset);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READV);
- }
- else
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_READ);
- nb = read(pollinfo->fd, pollinfo->read.buf.ptr + pollinfo->read_nb,
- pollinfo->read.buf.max - pollinfo->read_nb);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_READ);
- }
- }
- while (nb < 0 && errno == EINTR);
-
- if (nb > 0)
- {
- int done;
-
- pollinfo->read_nb += nb;
-
- done = pollinfo->read_iov_flag ?
- MPIDU_Socki_adjust_iov(nb, pollinfo->read.iov.ptr, pollinfo->read.iov.count, &pollinfo->read.iov.offset) :
- (pollinfo->read_nb >= pollinfo->read.buf.min);
-
- if (done)
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
- MPI_SUCCESS, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
- }
- }
- /* --BEGIN ERROR HANDLING-- */
- else if (nb == 0)
- {
- int event_mpi_errno;
-
- event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed",
- "**sock|connclosed %d %d", pollinfo->sock_set->id, pollinfo->sock_id);
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- }
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
-
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN | POLLOUT);
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
-
- }
- /* --END ERROR HANDLING-- */
- else if (errno == EAGAIN && errno == EWOULDBLOCK)
- {
- /* do nothing... */
- goto fn_exit;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- int disconnected;
- int event_mpi_errno;
-
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(event_mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the data
- * structures are still intact. Therefore, we avoid
- * modifying them.
- */
- mpi_errno = event_mpi_errno;
- goto fn_exit;
- }
-
- if (disconnected)
- {
- if (MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd, pollinfo, POLLOUT))
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
-
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
-
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_READ, pollinfo->read_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLIN);
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_READ);
- return mpi_errno;
-}
-/* end MPIDU_Socki_handle_read() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_write
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_write(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
-{
- ssize_t nb;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITE);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_WRITEV);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
-
- do
- {
- if (pollinfo->write_iov_flag)
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITEV);
- nb = MPL_large_writev(pollinfo->fd, pollinfo->write.iov.ptr + pollinfo->write.iov.offset,
- pollinfo->write.iov.count - pollinfo->write.iov.offset);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITEV);
- }
- else
- {
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_WRITE);
- nb = write(pollinfo->fd, pollinfo->write.buf.ptr + pollinfo->write_nb,
- pollinfo->write.buf.max - pollinfo->write_nb);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_WRITE);
- }
- }
- while (nb < 0 && errno == EINTR);
-
- if (nb >= 0)
- {
- int done;
-
- pollinfo->write_nb += nb;
-
- done = pollinfo->write_iov_flag ?
- MPIDU_Socki_adjust_iov(nb, pollinfo->write.iov.ptr, pollinfo->write.iov.count, &pollinfo->write.iov.offset) :
- (pollinfo->write_nb >= pollinfo->write.buf.min);
-
- if (done)
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- MPI_SUCCESS, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- }
- }
- else if (errno == EAGAIN || errno == EWOULDBLOCK)
- {
- /* do nothing... */
- goto fn_exit;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- int disconnected;
- int event_mpi_errno;
-
- event_mpi_errno = MPIDU_Socki_os_to_mpi_errno(pollinfo, errno, FCNAME, __LINE__, &disconnected);
- if (MPIR_Err_is_fatal(event_mpi_errno))
- {
- /*
- * A serious error occurred. There is no guarantee that the data structures are still intact. Therefore, we avoid
- * modifying them.
- */
- mpi_errno = event_mpi_errno;
- goto fn_exit;
- }
-
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_WRITE, pollinfo->write_nb, pollinfo->user_ptr,
- event_mpi_errno, mpi_errno, fn_exit);
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
- if (disconnected)
- {
- /*
- * The connection is dead but data may still be in the socket buffer; thus, we change the state and let
- * MPIDU_Sock_wait() clean things up.
- */
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RO;
- }
- }
- /* --END ERROR HANDLING-- */
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_WRITE);
- return mpi_errno;
-}
-/* end MPIDU_Socki_handle_write() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_handle_connect
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_handle_connect(struct pollfd * const pollfd, struct pollinfo * const pollinfo)
-{
- struct sockaddr_in addr;
- socklen_t addr_len;
- int rc;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
-
- addr_len = sizeof(struct sockaddr_in);
- rc = getpeername(pollfd->fd, (struct sockaddr *) &addr, &addr_len);
- if (rc == 0)
- {
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, MPI_SUCCESS, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_CONNECTED_RW;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- int event_mpi_errno;
-
- MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo, pollinfo->os_errno, mpi_errno, fn_exit);
- event_mpi_errno = MPIR_Err_create_code(
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed",
- "**sock|poll|connfailed %d %d %d %s", pollinfo->sock_set->id, pollinfo->sock_id, pollinfo->os_errno,
- MPIR_Strerror(pollinfo->os_errno));
- MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo, MPIDU_SOCK_OP_CONNECT, 0, pollinfo->user_ptr, event_mpi_errno, mpi_errno, fn_exit);
- pollinfo->state = MPIDU_SOCKI_STATE_DISCONNECTED;
- }
- /* --END ERROR HANDLING-- */
-
- MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd, pollinfo, POLLOUT);
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_HANDLE_CONNECT);
- return mpi_errno;
-}
-/* end MPIDU_Socki_handle_connect() */
diff --git a/src/mpid/common/sock/socki_util.i b/src/mpid/common/sock/socki_util.i
deleted file mode 100644
index f3d1f0a..0000000
--- a/src/mpid/common/sock/socki_util.i
+++ /dev/null
@@ -1,1059 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-
-#ifdef MPICH_IS_THREADED
-static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set);
-int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *, int );
-#endif
-
-static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo,
- int os_errno, const char * fcname, int line, int * conn_failed);
-
-static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov,
- const int count, int * const offsetp);
-
-static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set,
- struct MPIDU_Sock ** sockp);
-static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock);
-
-static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo,
- enum MPIDU_Sock_op op,
- size_t num_bytes,
- void * user_ptr, int error);
-static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set,
- int * set_elem,
- struct MPIDU_Sock_event * eventp);
-
-static void MPIDU_Socki_free_eventq_mem(void);
-
-struct MPIDU_Socki_eventq_table
-{
- struct MPIDU_Socki_eventq_elem elems[MPIDU_SOCK_EVENTQ_POOL_SIZE];
- struct MPIDU_Socki_eventq_table * next;
-};
-
-static struct MPIDU_Socki_eventq_table *MPIDU_Socki_eventq_table_head=NULL;
-
-
-
-#define MPIDU_Socki_sock_get_pollfd(sock_) (&(sock_)->sock_set->pollfds[(sock_)->elem])
-#define MPIDU_Socki_sock_get_pollinfo(sock_) (&(sock_)->sock_set->pollinfos[(sock_)->elem])
-#define MPIDU_Socki_pollinfo_get_pollfd(pollinfo_) (&(pollinfo_)->sock_set->pollfds[(pollinfo_)->elem])
-
-
-/* Enqueue a new event. If the enqueue fails, generate an error and jump to
- the fail_label_ */
-#define MPIDU_SOCKI_EVENT_ENQUEUE(pollinfo_, op_, nb_, user_ptr_, event_mpi_errno_, mpi_errno_, fail_label_) \
-{ \
- mpi_errno_ = MPIDU_Socki_event_enqueue((pollinfo_), (op_), (nb_), (user_ptr_), (event_mpi_errno_)); \
- if (mpi_errno_ != MPI_SUCCESS) \
- { \
- mpi_errno_ = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, \
- "**sock|poll|eqfail", "**sock|poll|eqfail %d %d %d", \
- pollinfo->sock_set->id, pollinfo->sock_id, (op_)); \
- goto fail_label_; \
- } \
-}
-
-/* FIXME: These need to separate the operations from the thread-related
- synchronization to ensure that the code that is independent of
- threads is always the same. Also, the thread-level check needs
- to be identical to all others, and there should be an option,
- possibly embedded within special thread macros, to allow
- runtime control of the thread level */
-
-#ifndef MPICH_IS_THREADED
-# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
- { \
- (pollfd_)->events |= (op_); \
- (pollfd_)->fd = (pollinfo_)->fd; \
- }
-# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
- { \
- (pollfd_)->events &= ~(op_); \
- (pollfd_)->revents &= ~(op_); \
- if (((pollfd_)->events & (POLLIN | POLLOUT)) == 0) \
- { \
- (pollfd_)->fd = -1; \
- } \
- }
-#else /* MPICH_IS_THREADED */
-/* FIXME: Does this need a runtime check on whether threads are in use? */
-# define MPIDU_SOCKI_POLLFD_OP_SET(pollfd_, pollinfo_, op_) \
- { \
- (pollinfo_)->pollfd_events |= (op_); \
- if ((pollinfo_)->sock_set->pollfds_active == NULL) \
- { \
- (pollfd_)->events |= (op_); \
- (pollfd_)->fd = (pollinfo_)->fd; \
- } \
- else \
- { \
- (pollinfo_)->sock_set->pollfds_updated = TRUE; \
- MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
- } \
- }
-# define MPIDU_SOCKI_POLLFD_OP_CLEAR(pollfd_, pollinfo_, op_) \
- { \
- (pollinfo_)->pollfd_events &= ~(op_); \
- if ((pollinfo_)->sock_set->pollfds_active == NULL) \
- { \
- (pollfd_)->events &= ~(op_); \
- (pollfd_)->revents &= ~(op_); \
- if (((pollfd_)->events & (POLLIN | POLLOUT)) == 0) \
- { \
- (pollfd_)->fd = -1; \
- } \
- } \
- else \
- { \
- (pollinfo_)->sock_set->pollfds_updated = TRUE; \
- MPIDU_Socki_wakeup((pollinfo_)->sock_set); \
- } \
- }
-#endif
-
-#define MPIDU_SOCKI_POLLFD_OP_ISSET(pollfd_, pollinfo_, op_) ((pollfd_)->events & (op_))
-
-/* FIXME: Low usage operations like this should be a function for
- better readability, modularity, and code size */
-#define MPIDU_SOCKI_GET_SOCKET_ERROR(pollinfo_, os_errno_, mpi_errno_, fail_label_) \
-{ \
- int rc__; \
- socklen_t sz__; \
- \
- sz__ = sizeof(os_errno_); \
- rc__ = getsockopt((pollinfo_)->fd, SOL_SOCKET, SO_ERROR, &(os_errno_), &sz__); \
- if (rc__ != 0) \
- { \
- if (errno == ENOMEM || errno == ENOBUFS) \
- { \
- mpi_errno_ = MPIR_Err_create_code( \
- MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**sock|osnomem", \
- "**sock|osnomem %s %d %d", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id); \
- } \
- else \
- { \
- mpi_errno = MPIR_Err_create_code( \
- MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock|oserror", \
- "**sock|poll|oserror %s %d %d %d %s", "getsockopt", pollinfo->sock_set->id, pollinfo->sock_id, \
- (os_errno_), MPIR_Strerror(os_errno_)); \
- } \
- \
- goto fail_label_; \
- } \
-}
-
-
-/*
- * Validation tests
- */
-/* FIXME: Are these really optional? Based on their definitions, it looks
- like they should only be used when debugging the code. */
-#ifdef USE_SOCK_VERIFY
-#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_, fail_label_) \
-{ \
- if (MPIDU_Socki_initialized <= 0) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, \
- "**sock|uninit", NULL); \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_, mpi_errno_, fail_label_)
-
-
-#define MPIDU_SOCKI_VALIDATE_SOCK(sock_, mpi_errno_, fail_label_) \
-{ \
- struct pollinfo * pollinfo__; \
- \
- if ((sock_) == NULL || (sock_)->sock_set == NULL || (sock_)->elem < 0 || \
- (sock_)->elem >= (sock_)->sock_set->poll_array_elems) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|badsock", NULL); \
- goto fail_label_; \
- } \
- \
- pollinfo__ = MPIDU_Socki_sock_get_pollinfo(sock_); \
- \
- if (pollinfo__->type <= MPIDU_SOCKI_TYPE_FIRST || pollinfo__->type >= MPIDU_SOCKI_TYPE_INTERRUPTER || \
- pollinfo__->state <= MPIDU_SOCKI_STATE_FIRST || pollinfo__->state >= MPIDU_SOCKI_STATE_LAST) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|badsock", NULL); \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_, mpi_errno_, fail_label_) \
-{ \
- if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
- { \
- if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|notconnected", \
- "**sock|notconnected %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED) \
- { \
- if ((pollinfo_)->os_errno == 0) \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
- "**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- } \
- else \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
- "**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
- (pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
- } \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, "**sock|closing", \
- "**sock|closing %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW && (pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RO) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|badsock", NULL); \
- goto fail_label_; \
- } \
- } \
- else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**sock|listener_read", \
- "**sock|listener_read %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_, mpi_errno_, fail_label_) \
-{ \
- if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_COMMUNICATION) \
- { \
- if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTING) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|notconnected", "**sock|notconnected %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_DISCONNECTED || (pollinfo_)->state == MPIDU_SOCKI_STATE_CONNECTED_RO) \
- { \
- if ((pollinfo_)->os_errno == 0) \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_CLOSED, "**sock|connclosed", \
- "**sock|connclosed %d %d", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- } \
- else \
- { \
- (mpi_errno_) = MPIR_Err_create_code( \
- (mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_CONN_FAILED, "**sock|connfailed", \
- "**sock|poll|connfailed %d %d %d %s", (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, \
- (pollinfo_)->os_errno, MPIR_Strerror((pollinfo_)->os_errno)); \
- } \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state == MPIDU_SOCKI_STATE_CLOSING) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
- "**sock|closing", "**sock|closing %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- \
- goto fail_label_; \
- } \
- else if ((pollinfo_)->state != MPIDU_SOCKI_STATE_CONNECTED_RW) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|badsock", NULL); \
- goto fail_label_; \
- } \
- } \
- else if ((pollinfo_)->type == MPIDU_SOCKI_TYPE_LISTENER) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|listener_write", "**sock|listener_write %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_, mpi_errno_, fail_label_) \
-{ \
- if ((pollinfo_)->fd < 0) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, \
- "**sock|badhandle", "**sock|poll|badhandle %d %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id, (pollinfo_)->fd); \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
-{ \
- if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLIN)) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
- "**sock|reads", "**sock|reads %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- goto fail_label_; \
- } \
-}
-
-
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_, pollinfo_, mpi_errno_, fail_label_) \
-{ \
- if (MPIDU_SOCKI_POLLFD_OP_ISSET((pollfd_), (pollinfo_), POLLOUT)) \
- { \
- (mpi_errno_) = MPIR_Err_create_code((mpi_errno_), MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INPROGRESS, \
- "**sock|writes", "**sock|writes %d %d", \
- (pollinfo_)->sock_set->id, (pollinfo_)->sock_id); \
- goto fail_label_; \
- } \
-}
-#else
-/* Use minimal to no checking */
-#define MPIDU_SOCKI_VERIFY_INIT(mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_SOCK_SET(sock_set_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_SOCK(sock_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_CONNECTED_READABLE(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_CONNECTED_WRITABLE(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VALIDATE_FD(pollinfo_,mpi_errno_,fail_label_)
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_READ(pollfd_,pollinfo_,mpi_errno,fail_label_)
-#define MPIDU_SOCKI_VERIFY_NO_POSTED_WRITE(pollfd_,pollinfo_,mpi_errno,fail_label_)
-
-#endif
-
-
-#ifdef MPICH_IS_THREADED
-
-/*
- * MPIDU_Socki_wakeup()
- */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_wakeup
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_wakeup(struct MPIDU_Sock_set * sock_set)
-{
- MPIR_THREAD_CHECK_BEGIN;
- if (sock_set->wakeup_posted == FALSE)
- {
- for(;;)
- {
- int nb;
- char c = 0;
-
- nb = write(sock_set->intr_fds[1], &c, 1);
- if (nb == 1)
- {
- break;
- }
-
- MPIR_Assertp(nb == 0 || errno == EINTR);
- }
-
- sock_set->wakeup_posted = TRUE;
- }
- MPIR_THREAD_CHECK_END;
- return MPIDU_SOCK_SUCCESS;
-}
-/* end MPIDU_Socki_wakeup() */
-
-#undef FUNCNAME
-#define FUNCNAME MPIDI_Sock_update_sock_set
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDI_Sock_update_sock_set( struct MPIDU_Sock_set *sock_set,
- int pollfds_active_elems )
-{
- int mpi_errno = MPI_SUCCESS;
- int elem;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
- for (elem = 0; elem < sock_set->poll_array_elems; elem++) {
- sock_set->pollfds[elem].events = sock_set->pollinfos[elem].pollfd_events;
- if ((sock_set->pollfds[elem].events & (POLLIN | POLLOUT)) != 0) {
- sock_set->pollfds[elem].fd = sock_set->pollinfos[elem].fd;
- }
- else {
- sock_set->pollfds[elem].fd = -1;
- }
-
- if (elem < pollfds_active_elems) {
- if (sock_set->pollfds_active == sock_set->pollfds) {
- sock_set->pollfds[elem].revents &= ~(POLLIN | POLLOUT) | sock_set->pollfds[elem].events;
- }
- else {
- sock_set->pollfds[elem].revents = sock_set->pollfds_active[elem].revents &
- (~(POLLIN | POLLOUT) | sock_set->pollfds[elem].events);
- }
- }
- else {
- sock_set->pollfds[elem].revents = 0;
- }
- }
-
- if (sock_set->pollfds_active != sock_set->pollfds) {
- MPL_free(sock_set->pollfds_active);
- }
-
- sock_set->pollfds_updated = FALSE;
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_SOCK_UPDATE_SOCK_SET);
- return mpi_errno;
-
-}
-
-#endif /* (MPICH_IS_THREADED) */
-
-
-/*
- * MPIDU_Socki_os_to_mpi_errno()
- *
- * This routine assumes that no thread can change the state between state check before the nonblocking OS operation and the call
- * to this routine.
- */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_os_to_mpi_errno
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-/* --BEGIN ERROR HANDLING-- */
-static int MPIDU_Socki_os_to_mpi_errno(struct pollinfo * pollinfo, int os_errno, const char * fcname, int line, int * disconnected)
-{
- int mpi_errno;
-
- if (os_errno == ENOMEM || os_errno == ENOBUFS)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_NOMEM,
- "**sock|osnomem", "**sock|poll|osnomem %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
- *disconnected = FALSE;
- }
- else if (os_errno == EFAULT || os_errno == EINVAL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_BAD_BUF,
- "**sock|badbuf", "**sock|poll|badbuf %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
- *disconnected = FALSE;
- }
- else if (os_errno == EPIPE)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_CLOSED,
- "**sock|connclosed", "**sock|poll|connclosed %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
- *disconnected = TRUE;
- }
- else if (os_errno == ECONNRESET || os_errno == ENOTCONN || os_errno == ETIMEDOUT)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
- "**sock|connfailed", "**sock|poll|connfailed %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
- pollinfo->os_errno = os_errno;
- *disconnected = TRUE;
- }
- else if (os_errno == EBADF)
- {
- /*
- * If we have a bad file descriptor, then either the sock was bad to
- * start with and we didn't catch it in the preliminary
- * checks, or a sock closure was finalized after the preliminary
- * checks were performed. The latter should not happen if
- * the thread safety code is correctly implemented. In any case,
- * the data structures associated with the sock are no
- * longer valid and should not be modified. We indicate this by
- * returning a fatal error.
- */
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_BAD_SOCK,
- "**sock|badsock", NULL);
- *disconnected = FALSE;
- }
- else
- {
- /*
- * Unexpected OS error.
- *
- * FIXME: technically we should never reach this section of code.
- * What's the right way to handle this situation? Should
- * we print an immediate message asking the user to report the errno
- * so that we can plug the hole?
- */
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, fcname, line, MPIDU_SOCK_ERR_CONN_FAILED,
- "**sock|oserror", "**sock|poll|oserror %d %d %d %s",
- pollinfo->sock_set->id, pollinfo->sock_id, os_errno, MPIR_Strerror(os_errno));
- pollinfo->os_errno = os_errno;
- *disconnected = TRUE;
- }
-
- return mpi_errno;
-}
-/* --END ERROR HANDLING-- */
-/* end MPIDU_Socki_os_to_mpi_errno() */
-
-
-/*
- * MPIDU_Socki_adjust_iov()
- *
- * Use the specified number of bytes (nb) to adjust the iovec and associated
- * values. If the iovec has been consumed, return
- * true; otherwise return false.
- *
- * The input is an iov (MPL_IOV is just an iov) and the offset into which
- * to start (start with entry iov[*offsetp]) and remove nb bytes from the iov.
- * The use of the offsetp term allows use to remove values from the iov without
- * making a copy to shift down elements when only part of the iov is
- * consumed.
- */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_adjust_iov
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_adjust_iov(ssize_t nb, MPL_IOV * const iov, const int count, int * const offsetp)
-{
- int offset = *offsetp;
-
- while (offset < count)
- {
- if (iov[offset].MPL_IOV_LEN <= nb)
- {
- nb -= iov[offset].MPL_IOV_LEN;
- offset++;
- }
- else
- {
- iov[offset].MPL_IOV_BUF = (char *) iov[offset].MPL_IOV_BUF + nb;
- iov[offset].MPL_IOV_LEN -= nb;
- *offsetp = offset;
- return FALSE;
- }
- }
-
- *offsetp = offset;
- return TRUE;
-}
-/* end MPIDU_Socki_adjust_iov() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_sock_alloc
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_sock_alloc(struct MPIDU_Sock_set * sock_set, struct MPIDU_Sock ** sockp)
-{
- struct MPIDU_Sock * sock = NULL;
- int avail_elem;
- struct pollfd * pollfds = NULL;
- struct pollinfo * pollinfos = NULL;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
-
- /* FIXME: Should this use the CHKPMEM macros (perm malloc)? */
- sock = MPL_malloc(sizeof(struct MPIDU_Sock));
- /* --BEGIN ERROR HANDLING-- */
- if (sock == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- /*
- * Check existing poll structures for a free element.
- */
- for (avail_elem = 0; avail_elem < sock_set->poll_array_sz; avail_elem++)
- {
- if (sock_set->pollinfos[avail_elem].sock_id == -1)
- {
- if (avail_elem >= sock_set->poll_array_elems)
- {
- sock_set->poll_array_elems = avail_elem + 1;
- }
-
- break;
- }
- }
-
- /*
- * No free elements were found. Larger pollfd and pollinfo arrays need to
- * be allocated and the existing data transfered over.
- */
- if (avail_elem == sock_set->poll_array_sz)
- {
- int elem;
-
- pollfds = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollfd));
- /* --BEGIN ERROR HANDLING-- */
- if (pollfds == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**nomem", 0);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
- pollinfos = MPL_malloc((sock_set->poll_array_sz + MPIDU_SOCK_SET_DEFAULT_SIZE) * sizeof(struct pollinfo));
- /* --BEGIN ERROR HANDLING-- */
- if (pollinfos == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM,
- "**nomem", 0);
- goto fn_fail;
- }
- /* --END ERROR HANDLING-- */
-
- if (sock_set->poll_array_sz > 0)
- {
- /*
- * Copy information from the old arrays and then free them.
- *
- * In the multi-threaded case, the pollfd array can only be copied
- * if another thread is not already blocking in poll()
- * and thus potentially modifying the array. Furthermore, the
- * pollfd array must not be freed if it is the one
- * actively being used by pol().
- */
-# ifndef MPICH_IS_THREADED
- {
- memcpy(pollfds, sock_set->pollfds, sock_set->poll_array_sz * sizeof(struct pollfd));
- MPL_free(sock_set->pollfds);
- }
-# else
- {
- if (sock_set->pollfds_active == NULL)
- {
- memcpy(pollfds, sock_set->pollfds, sock_set->poll_array_sz * sizeof(struct pollfd));
- }
- if (sock_set->pollfds_active != sock_set->pollfds)
- {
- MPL_free(sock_set->pollfds);
- }
- }
-# endif
-
- memcpy(pollinfos, sock_set->pollinfos, sock_set->poll_array_sz * sizeof(struct pollinfo));
- MPL_free(sock_set->pollinfos);
- }
-
- sock_set->poll_array_elems = avail_elem + 1;
- sock_set->poll_array_sz += MPIDU_SOCK_SET_DEFAULT_SIZE;
- sock_set->pollfds = pollfds;
- sock_set->pollinfos = pollinfos;
-
- /*
- * Initialize new elements
- */
- for (elem = avail_elem; elem < sock_set->poll_array_sz; elem++)
- {
- pollfds[elem].fd = -1;
- pollfds[elem].events = 0;
- pollfds[elem].revents = 0;
- }
- for (elem = avail_elem; elem < sock_set->poll_array_sz; elem++)
- {
- pollinfos[elem].fd = -1;
- pollinfos[elem].sock_set = sock_set;
- pollinfos[elem].elem = elem;
- pollinfos[elem].sock = NULL;
- pollinfos[elem].sock_id = -1;
- pollinfos[elem].type = MPIDU_SOCKI_TYPE_FIRST;
- pollinfos[elem].state = MPIDU_SOCKI_STATE_FIRST;
-# ifdef MPICH_IS_THREADED
- {
- pollinfos[elem].pollfd_events = 0;
- }
-# endif
- }
- }
-
- /*
- * Verify that memory hasn't been messed up.
- */
- MPIR_Assert(sock_set->pollinfos[avail_elem].sock_set == sock_set);
- MPIR_Assert(sock_set->pollinfos[avail_elem].elem == avail_elem);
- MPIR_Assert(sock_set->pollinfos[avail_elem].fd == -1);
- MPIR_Assert(sock_set->pollinfos[avail_elem].sock == NULL);
- MPIR_Assert(sock_set->pollinfos[avail_elem].sock_id == -1);
- MPIR_Assert(sock_set->pollinfos[avail_elem].type == MPIDU_SOCKI_TYPE_FIRST);
- MPIR_Assert(sock_set->pollinfos[avail_elem].state == MPIDU_SOCKI_STATE_FIRST);
-# ifdef MPICH_IS_THREADED
- {
- MPIR_Assert(sock_set->pollinfos[avail_elem].pollfd_events == 0);
- }
-# endif
-
- /*
- * Initialize newly allocated sock structure and associated poll structures
- */
- sock_set->pollinfos[avail_elem].sock_id = (sock_set->id << 24) | avail_elem;
- sock_set->pollinfos[avail_elem].sock = sock;
- sock->sock_set = sock_set;
- sock->elem = avail_elem;
-
- sock_set->pollfds[avail_elem].fd = -1;
- sock_set->pollfds[avail_elem].events = 0;
- sock_set->pollfds[avail_elem].revents = 0;
-
-# ifdef MPICH_IS_THREADED
- {
- MPIR_THREAD_CHECK_BEGIN;
- if (sock_set->pollfds_active != NULL)
- {
- sock_set->pollfds_updated = TRUE;
- }
- MPIR_THREAD_CHECK_END;
- }
-# endif
-
- *sockp = sock;
-
- fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_ALLOC);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- if (pollinfos != NULL)
- {
- MPL_free(pollinfos);
- }
-
- if (pollfds != NULL)
- {
- MPL_free(pollfds);
- }
-
- if (sock != NULL)
- {
- MPL_free(sock);
- }
-
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-/* end MPIDU_Socki_sock_alloc() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_sock_free
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static void MPIDU_Socki_sock_free(struct MPIDU_Sock * sock)
-{
- struct pollfd * pollfd = MPIDU_Socki_sock_get_pollfd(sock);
- struct pollinfo * pollinfo = MPIDU_Socki_sock_get_pollinfo(sock);
- struct MPIDU_Sock_set * sock_set = sock->sock_set;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
-
- /* FIXME: We need an abstraction for the thread sync operations */
-# ifdef MPICH_IS_THREADED
- {
- /*
- * Freeing a sock while Sock_wait() is blocked in poll() is not supported
- */
- MPIR_Assert(sock_set->pollfds_active == NULL);
- }
-# endif
-
- /*
- * Compress poll array
- */
- /* FIXME: move last element into current position and update sock associated with last element.
- */
- if (sock->elem + 1 == sock_set->poll_array_elems)
- {
- sock_set->poll_array_elems -= 1;
- if (sock_set->starting_elem >= sock_set->poll_array_elems)
- {
- sock_set->starting_elem = 0;
- }
- }
-
- /*
- * Remove entry from the poll list and mark the entry as free
- */
- pollinfo->fd = -1;
- pollinfo->sock = NULL;
- pollinfo->sock_id = -1;
- pollinfo->type = MPIDU_SOCKI_TYPE_FIRST;
- pollinfo->state = MPIDU_SOCKI_STATE_FIRST;
-# ifdef MPICH_IS_THREADED
- {
- pollinfo->pollfd_events = 0;
- }
-# endif
-
- pollfd->fd = -1;
- pollfd->events = 0;
- pollfd->revents = 0;
-
- /*
- * Mark the sock as invalid so that any future use might be caught
- */
- sock->sock_set = NULL;
- sock->elem = -1;
-
- MPL_free(sock);
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCKI_SOCK_FREE);
-}
-/* end MPIDU_Socki_sock_free() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_event_enqueue
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int MPIDU_Socki_event_enqueue(struct pollinfo * pollinfo, MPIDU_Sock_op_t op, size_t num_bytes,
- void * user_ptr, int error)
-{
- struct MPIDU_Sock_set * sock_set = pollinfo->sock_set;
- struct MPIDU_Socki_eventq_elem * eventq_elem;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCKI_EVENT_ENQUEUE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCKI_EVENT_ENQUEUE);
-
- if (MPIDU_Socki_eventq_pool != NULL)
- {
- eventq_elem = MPIDU_Socki_eventq_pool;
- MPIDU_Socki_eventq_pool = MPIDU_Socki_eventq_pool->next;
- }
- else
- {
- int i;
- struct MPIDU_Socki_eventq_table *eventq_table;
-
- eventq_table = MPL_malloc(sizeof(struct MPIDU_Socki_eventq_table));
- /* --BEGIN ERROR HANDLING-- */
- if (eventq_table == NULL)
- {
- mpi_errno = MPIR_Err_create_code(errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPI_ERR_OTHER,
- "**sock|poll|eqmalloc", 0);
- goto fn_exit;
- }
- /* --END ERROR HANDLING-- */
-
- eventq_elem = eventq_table->elems;
-
- eventq_table->next = MPIDU_Socki_eventq_table_head;
- MPIDU_Socki_eventq_table_head = eventq_table;
-
- if (MPIDU_SOCK_EVENTQ_POOL_SIZE > 1)
- {
- MPIDU_Socki_eventq_pool = &eventq_elem[1];
- for (i = 0; i < MPIDU_SOCK_EVENTQ_POOL_SIZE - 2; i++)
- {
- MPIDU_Socki_eventq_pool[i].next = &MPIDU_Socki_eventq_pool[i+1];
- }
- MPIDU_Socki_eventq_pool[MPIDU_SOCK_EVENTQ_POOL_SIZE - 2].next = NULL;
- }
- }
-
- eventq_elem->event.op_type = op;
- eventq_elem->event.num_bytes = num_bytes;
- eventq_elem->event.user_ptr = user_ptr;
- eventq_elem->event.error = error;
- eventq_elem->set_elem = pollinfo->elem;
- eventq_elem->next = NULL;
-
- if (sock_set->eventq_head == NULL)
- {
- sock_set->eventq_head = eventq_elem;
- }
- else
- {
- sock_set->eventq_tail->next = eventq_elem;
- }
- sock_set->eventq_tail = eventq_elem;
-fn_exit:
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCKI_EVENT_ENQUEUE);
- return mpi_errno;
-}
-/* end MPIDU_Socki_event_enqueue() */
-
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_event_dequeue
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static inline int MPIDU_Socki_event_dequeue(struct MPIDU_Sock_set * sock_set, int * set_elem, struct MPIDU_Sock_event * eventp)
-{
- struct MPIDU_Socki_eventq_elem * eventq_elem;
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCKI_EVENT_DEQUEUE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCKI_EVENT_DEQUEUE);
-
- if (sock_set->eventq_head != NULL)
- {
- eventq_elem = sock_set->eventq_head;
-
- sock_set->eventq_head = eventq_elem->next;
- if (eventq_elem->next == NULL)
- {
- sock_set->eventq_tail = NULL;
- }
-
- *eventp = eventq_elem->event;
- *set_elem = eventq_elem->set_elem;
-
- eventq_elem->next = MPIDU_Socki_eventq_pool;
- MPIDU_Socki_eventq_pool = eventq_elem;
- }
- /* --BEGIN ERROR HANDLING-- */
- else
- {
- /* FIXME: Shouldn't this be an mpi error code? */
- mpi_errno = MPIDU_SOCK_ERR_FAIL;
- }
- /* --END ERROR HANDLING-- */
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCKI_EVENT_DEQUEUE);
- return mpi_errno;
-}
-/* end MPIDU_Socki_event_dequeue() */
-
-
-/* FIXME: Who allocates eventq tables? Should there be a check that these
- tables are empty first? */
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Socki_free_eventq_mem
-#undef FCNAME
-#define FCNAME "MPIDU_Socki_free_eventq_mem"
-static void MPIDU_Socki_free_eventq_mem(void)
-{
- struct MPIDU_Socki_eventq_table *eventq_table, *eventq_table_next;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
-
- eventq_table = MPIDU_Socki_eventq_table_head;
- while (eventq_table) {
- eventq_table_next = eventq_table->next;
- MPL_free(eventq_table);
- eventq_table = eventq_table_next;
- }
- MPIDU_Socki_eventq_table_head = NULL;
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_SOCKI_FREE_EVENTQ_MEM);
-}
-
-/* Provide a standard mechanism for setting the socket buffer size.
- The value is -1 if the default size hasn't been set, 0 if no size
- should be set, and > 0 if that size should be used */
-static int sockBufSize = -1;
-
-/* Set the socket buffer sizes on fd to the standard values (this is controlled
- by the parameter MPICH_SOCK_BUFSIZE). If "firm" is true, require that the
- sockets actually accept that buffer size. */
-int MPIDU_Sock_SetSockBufferSize( int fd, int firm )
-{
- int mpi_errno = MPI_SUCCESS;
- int rc;
-
- /* Get the socket buffer size if we haven't yet acquired it */
- if (sockBufSize < 0) {
- /* FIXME: Is this the name that we want to use (this was chosen
- to match the original, undocumented name) */
- rc = MPL_env2int( "MPICH_SOCKET_BUFFER_SIZE", &sockBufSize );
- if (rc <= 0) {
- sockBufSize = 0;
- }
- MPL_DBG_MSG_D(MPIDU_DBG_SOCK_CONNECT,TYPICAL,"Sock buf size = %d",sockBufSize);
- }
-
- if (sockBufSize > 0) {
- int bufsz;
- socklen_t bufsz_len;
-
- bufsz = sockBufSize;
- bufsz_len = sizeof(bufsz);
- rc = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, bufsz_len);
- if (rc == -1) {
- MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|setsndbufsz",
- "**sock|poll|setsndbufsz %d %d %s",
- bufsz, errno, MPIR_Strerror(errno));
- }
- bufsz = sockBufSize;
- bufsz_len = sizeof(bufsz);
- rc = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, bufsz_len);
- if (rc == -1) {
- MPIR_ERR_SETANDJUMP3(mpi_errno,MPIDU_SOCK_ERR_FAIL,
- "**sock|poll|setrcvbufsz",
- "**sock|poll|setrcvbufsz %d %d %s",
- bufsz, errno, MPIR_Strerror(errno));
- }
- bufsz_len = sizeof(bufsz);
-
- if (firm) {
- rc = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsz, &bufsz_len);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == 0) {
- if (bufsz < sockBufSize * 0.9) {
- MPL_msg_printf("WARNING: send socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- sockBufSize, bufsz);
- }
- }
- /* --END ERROR HANDLING-- */
-
- bufsz_len = sizeof(bufsz);
- rc = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsz, &bufsz_len);
- /* --BEGIN ERROR HANDLING-- */
- if (rc == 0) {
- if (bufsz < sockBufSize * 0.9) {
- MPL_msg_printf("WARNING: receive socket buffer size differs from requested size (requested=%d, actual=%d)\n",
- sockBufSize, bufsz);
- }
- }
- /* --END ERROR HANDLING-- */
- }
- }
- fn_fail:
- return mpi_errno;
-}
-
-/* This routine provides a string version of the address. */
-int MPIDU_Sock_AddrToStr( MPIDU_Sock_ifaddr_t *ifaddr, char *str, int maxlen )
-{
- int i;
- unsigned char *p = ifaddr->ifaddr;
- for (i=0; i<ifaddr->len && maxlen > 4; i++) {
- snprintf( str, maxlen, "%.3d.", *p++ );
- str += 4;
- maxlen -= 4;
- }
- /* Change the last period to a null; but be careful in case len was zero */
- if (i > 0) *--str = 0;
- else *str = 0;
- return 0;
-}
http://git.mpich.org/mpich.git/commitdiff/ad88e485e8a4cefb96b2924e3aa4f21ff33aa181
commit ad88e485e8a4cefb96b2924e3aa4f21ff33aa181
Author: Pavan Balaji <balaji at anl.gov>
Date: Tue Feb 2 12:48:16 2016 -0600
sock: merge poll into the sock directory.
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/src/mpid/common/sock/Makefile.mk b/src/mpid/common/sock/Makefile.mk
index fc17538..a089d18 100644
--- a/src/mpid/common/sock/Makefile.mk
+++ b/src/mpid/common/sock/Makefile.mk
@@ -16,7 +16,27 @@ AM_CPPFLAGS += \
noinst_HEADERS += src/mpid/common/sock/mpidu_sock.h
-include $(top_srcdir)/src/mpid/common/sock/poll/Makefile.mk
+mpi_core_sources += \
+ src/mpid/common/sock/sock.c
+
+# FIXME these ".i" files are awful and should be fixed somehow. They are
+# cobbled together via "#include" into sock.c. They are not idempotent ".h"
+# files, but rather a giant ".c" file that has been split into several files
+# that should be compiled only once, and only together.
+noinst_HEADERS += \
+ src/mpid/common/sock/sock_init.i \
+ src/mpid/common/sock/sock_set.i \
+ src/mpid/common/sock/sock_post.i \
+ src/mpid/common/sock/sock_immed.i \
+ src/mpid/common/sock/sock_misc.i \
+ src/mpid/common/sock/sock_wait.i \
+ src/mpid/common/sock/socki_util.i \
+ src/mpid/common/sock/mpidu_socki.h
+
+# FIXME is top_builddir the right way to handle VPATH builds?
+AM_CPPFLAGS += \
+ -I${top_srcdir}/src/mpid/common/sock \
+ -I${top_builddir}/src/mpid/common/sock
endif BUILD_MPID_COMMON_SOCK
diff --git a/src/mpid/common/sock/errnames.txt b/src/mpid/common/sock/errnames.txt
index 9a53a35..2a1323b 100644
--- a/src/mpid/common/sock/errnames.txt
+++ b/src/mpid/common/sock/errnames.txt
@@ -45,3 +45,44 @@
**sock|uninit:Sock library has not been initialized
**sock|writes:attempt to perform multiple simultaneous writes
**sock|writes %d %d:attempt to perform multiple simultaneous writes (set=%d,sock=%d)
+
+**sock|poll|accept:accept failed to acquire a new socket
+**sock|poll|accept %d %s:accept failed to acquire a new socket (errno=%d:%s)
+**sock|poll|badbuf %d %d %d %s:the supplied buffer contains invalid memory (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|badhandle %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d)
+**sock|poll|badhandle %d %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d:%d)
+**sock|poll|bind:unable to bind socket to port
+**sock|poll|bind %d %d %s:unable to bind socket to port (port=%d,errno=%d:%s)
+**sock|poll|connclosed %d %d %d %s:connection closed by peer (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|connfailed %d %d %d %s:connection failure (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|connrefused %d %d %s:connection refused (set=%d,sock=%d,host=%s)
+**sock|poll|eqmalloc:MPL_malloc failed to allocate memory for an event queue structure
+**sock|poll|eqfail:fatal error: failed to enqueue an event; event was lost
+**sock|poll|eqfail %d %d %d:fatal error: failed to enqueue an event; event was lost (set=%d,sock=%d,op=%d)
+**sock|poll|getport %d %s:failed to obtain port number of listener (errno=%d:%s)
+**sock|poll|listen:listen() failed
+**sock|poll|listen %d %s:listen() failed (errno=%d:%s)
+**sock|poll|nodelay:unable to set TCP no delay attribute on socket
+**sock|poll|nodelay %d %s:unable to set TCP no delay attribute on socket (errno=%d:%s)
+**sock|poll|nonblock:unable to set socket to nonblocking
+**sock|poll|nonblock %d %s:unable to set socket to nonblocking (errno=%d:%s)
+**sock|poll|oserror %d %s:unexpected operating system error (errno=%d:%s)
+**sock|poll|oserror %d %d %d %s:unexpected operating system error (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|oserror %s %d %d %d %s:unpected operating system error from %s (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|osnomem %d %d %d %s:operating system routine failed due to lack of memory (set=%d,sock=%d,errno=%d:%s)
+**sock|poll|pipe:unable to allocate pipe to wakeup a blocking poll()
+**sock|poll|pipe %d %s:unable to allocate pipe to wakeup a blocking poll() (errno=%d:%s)
+**sock|poll|pipenonblock:unable to set wakeup pipe to nonblocking
+**sock|poll|pipenonblock %d %s:unable to set wakeup pipe to nonblocking (errno=%d:%s)
+**sock|poll|reuseaddr:unable to set reuseaddr attribute on socket
+**sock|poll|reuseaddr %d %s:unable to set reuseaddr attribute on socket (errno=%d:%s)
+**sock|poll|setrcvbufsz: unable to set the receive socket buffer size
+**sock|poll|setrcvbufsz %d %d %s: unable to set the receive socket buffer size (size=%d,errno=%d:%s)
+**sock|poll|setsndbufsz: unable to set the send socket buffer size
+**sock|poll|setsndbufsz %d %d %s: unable to set the send socket buffer size (size=%d,errno=%d:%s)
+**sock|poll|socket:unable to obtain new socket
+**sock|poll|socket %d %s:unable to obtain new socket (errno=%d:%s)
+**sock|poll|unhandledstate:encountered an unexpected state
+**sock|poll|unhandledstate %d:encountered an unexpected state (%d)
+**sock|poll|unhandledtype:encountered an unexpected sock type
+**sock|poll|unhandledtype %d:encountered an unexpected sock type (%d)
diff --git a/src/mpid/common/sock/poll/mpidu_socki.h b/src/mpid/common/sock/mpidu_socki.h
similarity index 100%
rename from src/mpid/common/sock/poll/mpidu_socki.h
rename to src/mpid/common/sock/mpidu_socki.h
diff --git a/src/mpid/common/sock/poll/Makefile.mk b/src/mpid/common/sock/poll/Makefile.mk
deleted file mode 100644
index 9d05f86..0000000
--- a/src/mpid/common/sock/poll/Makefile.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-## -*- Mode: Makefile; -*-
-## vim: set ft=automake :
-##
-## (C) 2011 by Argonne National Laboratory.
-## See COPYRIGHT in top-level directory.
-##
-
-errnames_txt_files += src/mpid/common/sock/poll/errnames.txt
-
-## this whole file is also already guarded by "if BUILD_MPID_COMMON_SOCK"
-if BUILD_MPID_COMMON_SOCK_POLL
-
-mpi_core_sources += \
- src/mpid/common/sock/poll/sock.c
-
-# FIXME these ".i" files are awful and should be fixed somehow. They are
-# cobbled together via "#include" into sock.c. They are not idempotent ".h"
-# files, but rather a giant ".c" file that has been split into several files
-# that should be compiled only once, and only together.
-noinst_HEADERS += \
- src/mpid/common/sock/poll/sock_init.i \
- src/mpid/common/sock/poll/sock_set.i \
- src/mpid/common/sock/poll/sock_post.i \
- src/mpid/common/sock/poll/sock_immed.i \
- src/mpid/common/sock/poll/sock_misc.i \
- src/mpid/common/sock/poll/sock_wait.i \
- src/mpid/common/sock/poll/socki_util.i \
- src/mpid/common/sock/poll/mpidu_socki.h
-
-# FIXME is top_builddir the right way to handle VPATH builds?
-AM_CPPFLAGS += \
- -I${top_srcdir}/src/mpid/common/sock/poll \
- -I${top_builddir}/src/mpid/common/sock/poll
-
-endif BUILD_MPID_COMMON_SOCK_POLL
-
diff --git a/src/mpid/common/sock/poll/errnames.txt b/src/mpid/common/sock/poll/errnames.txt
deleted file mode 100644
index f7b7717..0000000
--- a/src/mpid/common/sock/poll/errnames.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Sock:poll
-#
-**sock|poll|accept:accept failed to acquire a new socket
-**sock|poll|accept %d %s:accept failed to acquire a new socket (errno=%d:%s)
-**sock|poll|badbuf %d %d %d %s:the supplied buffer contains invalid memory (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|badhandle %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d)
-**sock|poll|badhandle %d %d %d %d:sock contains an invalid file descriptor (set=%d,sock=%d,fd=%d:%d)
-**sock|poll|bind:unable to bind socket to port
-**sock|poll|bind %d %d %s:unable to bind socket to port (port=%d,errno=%d:%s)
-**sock|poll|connclosed %d %d %d %s:connection closed by peer (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|connfailed %d %d %d %s:connection failure (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|connrefused %d %d %s:connection refused (set=%d,sock=%d,host=%s)
-**sock|poll|eqmalloc:MPL_malloc failed to allocate memory for an event queue structure
-**sock|poll|eqfail:fatal error: failed to enqueue an event; event was lost
-**sock|poll|eqfail %d %d %d:fatal error: failed to enqueue an event; event was lost (set=%d,sock=%d,op=%d)
-**sock|poll|getport %d %s:failed to obtain port number of listener (errno=%d:%s)
-**sock|poll|listen:listen() failed
-**sock|poll|listen %d %s:listen() failed (errno=%d:%s)
-**sock|poll|nodelay:unable to set TCP no delay attribute on socket
-**sock|poll|nodelay %d %s:unable to set TCP no delay attribute on socket (errno=%d:%s)
-**sock|poll|nonblock:unable to set socket to nonblocking
-**sock|poll|nonblock %d %s:unable to set socket to nonblocking (errno=%d:%s)
-**sock|poll|oserror %d %s:unexpected operating system error (errno=%d:%s)
-**sock|poll|oserror %d %d %d %s:unexpected operating system error (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|oserror %s %d %d %d %s:unpected operating system error from %s (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|osnomem %d %d %d %s:operating system routine failed due to lack of memory (set=%d,sock=%d,errno=%d:%s)
-**sock|poll|pipe:unable to allocate pipe to wakeup a blocking poll()
-**sock|poll|pipe %d %s:unable to allocate pipe to wakeup a blocking poll() (errno=%d:%s)
-**sock|poll|pipenonblock:unable to set wakeup pipe to nonblocking
-**sock|poll|pipenonblock %d %s:unable to set wakeup pipe to nonblocking (errno=%d:%s)
-**sock|poll|reuseaddr:unable to set reuseaddr attribute on socket
-**sock|poll|reuseaddr %d %s:unable to set reuseaddr attribute on socket (errno=%d:%s)
-**sock|poll|setrcvbufsz: unable to set the receive socket buffer size
-**sock|poll|setrcvbufsz %d %d %s: unable to set the receive socket buffer size (size=%d,errno=%d:%s)
-**sock|poll|setsndbufsz: unable to set the send socket buffer size
-**sock|poll|setsndbufsz %d %d %s: unable to set the send socket buffer size (size=%d,errno=%d:%s)
-**sock|poll|socket:unable to obtain new socket
-**sock|poll|socket %d %s:unable to obtain new socket (errno=%d:%s)
-**sock|poll|unhandledstate:encountered an unexpected state
-**sock|poll|unhandledstate %d:encountered an unexpected state (%d)
-**sock|poll|unhandledtype:encountered an unexpected sock type
-**sock|poll|unhandledtype %d:encountered an unexpected sock type (%d)
diff --git a/src/mpid/common/sock/poll/subconfigure.m4 b/src/mpid/common/sock/poll/subconfigure.m4
deleted file mode 100644
index 3617d3b..0000000
--- a/src/mpid/common/sock/poll/subconfigure.m4
+++ /dev/null
@@ -1,138 +0,0 @@
-[#] start of __file__
-dnl MPICH_SUBCFG_AFTER=src/mpid/common/sock
-
-AC_DEFUN([PAC_SUBCFG_PREREQ_]PAC_SUBCFG_AUTO_SUFFIX,[
- AM_CONDITIONAL([BUILD_MPID_COMMON_SOCK_POLL],[test "X$build_mpid_common_sock_poll" = "Xyes"])
-])
-
-dnl _BODY handles the former role of configure in the subsystem
-AC_DEFUN([PAC_SUBCFG_BODY_]PAC_SUBCFG_AUTO_SUFFIX,[
-AM_COND_IF([BUILD_MPID_COMMON_SOCK_POLL],[
-AC_MSG_NOTICE([RUNNING CONFIGURE FOR src/mpid/common/sock/poll])
-
-AC_ARG_ENABLE([sock-debug],
- [--enable-sock-debug - Turn on tests of the socket data structures],
- [],
- [enable_sock_debug=no])
-
-if test "$enable_sock_debug" = yes ; then
- AC_DEFINE(USE_SOCK_VERIFY,1,[Define it the socket verify macros should be enabled])
-fi
-
-AC_CHECK_FUNC([poll],[pac_cv_have_func_poll=yes],[pac_cv_have_func_poll=no])
-if test "X$pac_cv_have_func_poll" = "Xno" ; then
- if test -f /sw/include/sys/poll.h ; then
- dnl This is for Mac OSX (Darwin) which doesn't have a poll function is
- dnl the standard libraries. Instead we use a contributed library found
- dnl off in la la land (/sw).
- dnl
- dnl I don't think the above comment is true for modern Darwin (goodell@ 2010-06-01)
- CFLAGS="$CFLAGS -I/sw/include"
- LIBS="$LIBS -L/sw/lib -lpoll"
- else
- AC_MSG_ERROR([This device requires the poll function])
- fi
-fi
-
-AC_CHECK_HEADERS([assert.h errno.h fcntl.h limits.h netdb.h netinet/in.h netinet/tcp.h])
-AC_CHECK_HEADERS([poll.h stdlib.h sys/param.h sys/poll.h sys/types.h sys/uio.h unistd.h])
-
-AC_MSG_CHECKING([if struct poll is defined]);
-AC_TRY_COMPILE([
-#if defined(HAVE_POLL_H)
-#include <poll.h>
-#endif
-#if defined(HAVE_SYS_POLL_H)
-#include <sys/poll.h>
-#endif
-],[
-struct pollfd pollfd;
-pollfd.fd = -1;
-],[
-AC_MSG_RESULT([yes])
-],[
-AC_MSG_RESULT([no])
-AC_MSG_ERROR([This device requires the poll function])
-])
-
-AC_MSG_CHECKING([if a simple program using poll() can be compiled]);
-AC_TRY_COMPILE([
-#if defined(HAVE_POLL_H)
-#include <poll.h>
-#endif
-#if defined(HAVE_SYS_POLL_H)
-#include <sys/poll.h>
-#endif
-],[
-struct pollfd pollfds[2];
-int n_fds;
-pollfds[0].fd = -1;
-pollfds[1].fd = -1;
-n_fds = poll(pollfds, 2, -1);
-],[
-AC_MSG_RESULT([yes])
-],[
-AC_MSG_RESULT([no])
-AC_MSG_ERROR([This device requires the poll function])
-])
-
-dnl
-dnl needed on AIX
-dnl
-AC_MSG_CHECKING([whether bit fields work in ip.h]);
-AC_TRY_COMPILE([
-#include <netinet/tcp.h>
-],[
-int i;
-],[
-AC_MSG_RESULT([yes])
-bit_fields=yes
-],[
-AC_MSG_RESULT([no])
-bit_fields=no
-])
-if test "$bit_fields" = "no" ; then
- AC_MSG_RESULT([Adding -D_NO_BITFIELDS to CFLAGS])
- CFLAGS="$CFLAGS -D_NO_BITFIELDS"
-fi
-
-
-AC_CHECK_FUNCS([gethostname])
-if test "$ac_cv_func_gethostname" = "yes" ; then
- # Do we need to declare gethostname?
- PAC_FUNC_NEEDS_DECL([#include <unistd.h>],gethostname)
-fi
-
-AC_SEARCH_LIBS([socket],[socket])
-AC_SEARCH_LIBS([gethostbyname],[nsl])
-
-# Check first for sys/socket.h . We check not only for existence but whether
-# it can be compiled (!), as we have seen some problems with this.
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/socket.h>
-],[int a;],ac_cv_header_sys_socket_h=yes,ac_cv_header_sys_socket_h=no)
-if test "$ac_cv_header_sys_socket_h" = yes ; then
- AC_DEFINE(HAVE_SYS_SOCKET_H,1,[Define if you have the <sys/socket.h> header file.])
-fi
-# Check for socklen_t . If undefined, define it as int
-# (note the conditional inclusion of sys/socket.h)
-AC_CACHE_CHECK([whether socklen_t is defined (in sys/socket.h if present)],
-pac_cv_have_socklen_t,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-typedef struct { double a; int b; } socklen_t;],
-[socklen_t a;a.a=1.0;],
-[pac_cv_have_socklen_t=no],
-[pac_cv_have_socklen_t=yes])])
-if test "X$pac_cv_have_socklen_t" = Xno ; then
- AC_DEFINE([socklen_t],[int],[Define if socklen_t is not defined])
-fi
-
-])dnl end AM_COND_IF(BUILD_MPID_COMMON_SOCK_POLL,...)
-])dnl end _BODY
-dnl
-[#] end of __file__
diff --git a/src/mpid/common/sock/poll/sock.c b/src/mpid/common/sock/sock.c
similarity index 100%
rename from src/mpid/common/sock/poll/sock.c
rename to src/mpid/common/sock/sock.c
diff --git a/src/mpid/common/sock/poll/sock_immed.i b/src/mpid/common/sock/sock_immed.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_immed.i
rename to src/mpid/common/sock/sock_immed.i
diff --git a/src/mpid/common/sock/poll/sock_init.i b/src/mpid/common/sock/sock_init.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_init.i
rename to src/mpid/common/sock/sock_init.i
diff --git a/src/mpid/common/sock/poll/sock_misc.i b/src/mpid/common/sock/sock_misc.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_misc.i
rename to src/mpid/common/sock/sock_misc.i
diff --git a/src/mpid/common/sock/poll/sock_post.i b/src/mpid/common/sock/sock_post.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_post.i
rename to src/mpid/common/sock/sock_post.i
diff --git a/src/mpid/common/sock/poll/sock_set.i b/src/mpid/common/sock/sock_set.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_set.i
rename to src/mpid/common/sock/sock_set.i
diff --git a/src/mpid/common/sock/poll/sock_wait.i b/src/mpid/common/sock/sock_wait.i
similarity index 100%
rename from src/mpid/common/sock/poll/sock_wait.i
rename to src/mpid/common/sock/sock_wait.i
diff --git a/src/mpid/common/sock/poll/socki_util.i b/src/mpid/common/sock/socki_util.i
similarity index 100%
rename from src/mpid/common/sock/poll/socki_util.i
rename to src/mpid/common/sock/socki_util.i
diff --git a/src/mpid/common/sock/subconfigure.m4 b/src/mpid/common/sock/subconfigure.m4
index 1013d9a..303659f 100644
--- a/src/mpid/common/sock/subconfigure.m4
+++ b/src/mpid/common/sock/subconfigure.m4
@@ -2,11 +2,6 @@
AC_DEFUN([PAC_SUBCFG_PREREQ_src_mpid_common_sock],[
AM_CONDITIONAL([BUILD_MPID_COMMON_SOCK],[test "X$build_mpid_common_sock" = "Xyes"])
- AM_COND_IF([BUILD_MPID_COMMON_SOCK],[
- # we unconditionally enable the "poll" implementation because we don't
- # use this build system on windows right now
- build_mpid_common_sock_poll=yes
- ])
])
dnl _BODY handles the former role of configure in the subsystem
@@ -19,6 +14,128 @@ AC_MSG_NOTICE([RUNNING CONFIGURE FOR src/mpid/common/sock])
# from the system. [goodell@ 2008-01-10]
AC_CHECK_FUNCS([strerror])
+AC_ARG_ENABLE([sock-debug],
+ [--enable-sock-debug - Turn on tests of the socket data structures],
+ [],
+ [enable_sock_debug=no])
+
+if test "$enable_sock_debug" = yes ; then
+ AC_DEFINE(USE_SOCK_VERIFY,1,[Define it the socket verify macros should be enabled])
+fi
+
+AC_CHECK_FUNC([poll],[pac_cv_have_func_poll=yes],[pac_cv_have_func_poll=no])
+if test "X$pac_cv_have_func_poll" = "Xno" ; then
+ if test -f /sw/include/sys/poll.h ; then
+ dnl This is for Mac OSX (Darwin) which doesn't have a poll function is
+ dnl the standard libraries. Instead we use a contributed library found
+ dnl off in la la land (/sw).
+ dnl
+ dnl I don't think the above comment is true for modern Darwin (goodell@ 2010-06-01)
+ CFLAGS="$CFLAGS -I/sw/include"
+ LIBS="$LIBS -L/sw/lib -lpoll"
+ else
+ AC_MSG_ERROR([This device requires the poll function])
+ fi
+fi
+
+AC_CHECK_HEADERS([assert.h errno.h fcntl.h limits.h netdb.h netinet/in.h netinet/tcp.h])
+AC_CHECK_HEADERS([poll.h stdlib.h sys/param.h sys/poll.h sys/types.h sys/uio.h unistd.h])
+
+AC_MSG_CHECKING([if struct poll is defined]);
+AC_TRY_COMPILE([
+#if defined(HAVE_POLL_H)
+#include <poll.h>
+#endif
+#if defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+],[
+struct pollfd pollfd;
+pollfd.fd = -1;
+],[
+AC_MSG_RESULT([yes])
+],[
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([This device requires the poll function])
+])
+
+AC_MSG_CHECKING([if a simple program using poll() can be compiled]);
+AC_TRY_COMPILE([
+#if defined(HAVE_POLL_H)
+#include <poll.h>
+#endif
+#if defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+],[
+struct pollfd pollfds[2];
+int n_fds;
+pollfds[0].fd = -1;
+pollfds[1].fd = -1;
+n_fds = poll(pollfds, 2, -1);
+],[
+AC_MSG_RESULT([yes])
+],[
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([This device requires the poll function])
+])
+
+dnl
+dnl needed on AIX
+dnl
+AC_MSG_CHECKING([whether bit fields work in ip.h]);
+AC_TRY_COMPILE([
+#include <netinet/tcp.h>
+],[
+int i;
+],[
+AC_MSG_RESULT([yes])
+bit_fields=yes
+],[
+AC_MSG_RESULT([no])
+bit_fields=no
+])
+if test "$bit_fields" = "no" ; then
+ AC_MSG_RESULT([Adding -D_NO_BITFIELDS to CFLAGS])
+ CFLAGS="$CFLAGS -D_NO_BITFIELDS"
+fi
+
+
+AC_CHECK_FUNCS([gethostname])
+if test "$ac_cv_func_gethostname" = "yes" ; then
+ # Do we need to declare gethostname?
+ PAC_FUNC_NEEDS_DECL([#include <unistd.h>],gethostname)
+fi
+
+AC_SEARCH_LIBS([socket],[socket])
+AC_SEARCH_LIBS([gethostbyname],[nsl])
+
+# Check first for sys/socket.h . We check not only for existence but whether
+# it can be compiled (!), as we have seen some problems with this.
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+],[int a;],ac_cv_header_sys_socket_h=yes,ac_cv_header_sys_socket_h=no)
+if test "$ac_cv_header_sys_socket_h" = yes ; then
+ AC_DEFINE(HAVE_SYS_SOCKET_H,1,[Define if you have the <sys/socket.h> header file.])
+fi
+# Check for socklen_t . If undefined, define it as int
+# (note the conditional inclusion of sys/socket.h)
+AC_CACHE_CHECK([whether socklen_t is defined (in sys/socket.h if present)],
+pac_cv_have_socklen_t,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+typedef struct { double a; int b; } socklen_t;],
+[socklen_t a;a.a=1.0;],
+[pac_cv_have_socklen_t=no],
+[pac_cv_have_socklen_t=yes])])
+if test "X$pac_cv_have_socklen_t" = Xno ; then
+ AC_DEFINE([socklen_t],[int],[Define if socklen_t is not defined])
+fi
+
])dnl end AM_COND_IF(BUILD_MPID_COMMON_SOCK,...)
])dnl end _BODY
dnl
http://git.mpich.org/mpich.git/commitdiff/20c70de9358df3eb3ae5ceef3d3c58fc3f14fc69
commit 20c70de9358df3eb3ae5ceef3d3c58fc3f14fc69
Author: Pavan Balaji <balaji at anl.gov>
Date: Tue Feb 2 12:29:40 2016 -0600
sock: delete iocp code.
This is windows-specific and is not supported anymore.
Signed-off-by: Sangmin Seo <sseo at anl.gov>
diff --git a/src/mpid/common/sock/Makefile.mk b/src/mpid/common/sock/Makefile.mk
index 86038c5..fc17538 100644
--- a/src/mpid/common/sock/Makefile.mk
+++ b/src/mpid/common/sock/Makefile.mk
@@ -18,10 +18,5 @@ noinst_HEADERS += src/mpid/common/sock/mpidu_sock.h
include $(top_srcdir)/src/mpid/common/sock/poll/Makefile.mk
-# we don't provide an automake Makefile.mk for the iocp directory because it is
-# a Windows-only subsystem and our Windows build does not use the autotools at
-# this time
-#include $(top_srcdir)/src/mpid/common/sock/iocp/Makefile.mk
-
endif BUILD_MPID_COMMON_SOCK
diff --git a/src/mpid/common/sock/iocp/Makefile.sm b/src/mpid/common/sock/iocp/Makefile.sm
deleted file mode 100644
index baaa4a0..0000000
--- a/src/mpid/common/sock/iocp/Makefile.sm
+++ /dev/null
@@ -1,3 +0,0 @@
-INCLUDES = -I../../../../include -I${master_top_srcdir}/src/include
-lib${MPILIBNAME}_a_SOURCES = sock.c
-sock.o: sock.c mpidu_socki.h ../mpidu_sock.h
diff --git a/src/mpid/common/sock/iocp/mpidu_socki.h b/src/mpid/common/sock/iocp/mpidu_socki.h
deleted file mode 100644
index 6450360..0000000
--- a/src/mpid/common/sock/iocp/mpidu_socki.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-#ifndef MPIDU_SOCKI_H
-#define MPIDU_SOCKI_H
-
-#include <winsock2.h>
-#include <windows.h>
-#include <mswsock.h>
-
-/*
- ws2tcpip.h is a C++ header file. This header file,
- mpidu_socki.h, if included within a extern "C" {}
- block would give an error if ws2tcpip is not
- included in a extern "C++" {} block.
-
- */
-#ifdef __cplusplus
-extern "C++" {
-#endif
- #include <ws2tcpip.h>
-#ifdef __cplusplus
-}
-#endif
-
-#define MPIDU_SOCK_INVALID_SOCK NULL
-#define MPIDU_SOCK_INVALID_SET NULL
-#define MPIDU_SOCK_INFINITE_TIME INFINITE
-#define inline __inline
-
-typedef HANDLE MPIDU_SOCK_NATIVE_FD;
-typedef HANDLE MPIDU_Sock_set_t;
-typedef struct sock_state_t * MPIDU_Sock_t;
-typedef DWORD MPIDU_Sock_size_t;
-
-#include "mpl.h"
-#include "mpi.h"
-
-#endif
diff --git a/src/mpid/common/sock/iocp/sock.c b/src/mpid/common/sock/iocp/sock.c
deleted file mode 100644
index 9ff9311..0000000
--- a/src/mpid/common/sock/iocp/sock.c
+++ /dev/null
@@ -1,2919 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
- * (C) 2001 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
- */
-
-#include "mpiimpl.h"
-#include "mpidu_sock.h"
-
-#define MPL_QUOTE(A) MPL_QUOTE2(A)
-#define MPL_QUOTE2(A) #A
-
-#define SOCKI_TCP_BUFFER_SIZE 32*1024
-#define SOCKI_DESCRIPTION_LENGTH 256
-#define SOCKI_NUM_PREPOSTED_ACCEPTS 32
-
-typedef enum SOCKI_TYPE { SOCKI_INVALID, SOCKI_LISTENER, SOCKI_SOCKET, SOCKI_WAKEUP } SOCKI_TYPE;
-
-typedef int SOCKI_STATE;
-#define SOCKI_ACCEPTING 0x0001
-#define SOCKI_CONNECTING 0x0004
-#define SOCKI_READING 0x0008
-#define SOCKI_WRITING 0x0010
-
-typedef struct sock_buffer
-{
- DWORD num_bytes;
- OVERLAPPED ovl;
- MPL_IOV tiov;
-#ifdef USE_SOCK_IOV_COPY
- MPL_IOV iov[MPL_IOV_MAXLEN];
-#else
- MPL_IOV *iov;
-#endif
- int iovlen;
- int index;
- size_t total;
- MPIDU_Sock_progress_update_func_t progress_update;
-} sock_buffer;
-
-typedef struct sock_state_t
-{
- SOCKI_TYPE type;
- SOCKI_STATE state;
- SOCKET sock;
- MPIDU_Sock_set_t set;
- int closing;
- int pending_operations;
- /* listener/accept structures */
- SOCKET listen_sock;
- char accept_buffer[sizeof(struct sockaddr_in)*2+32];
- /* read and write structures */
- sock_buffer read;
- sock_buffer write;
- /* connect structures */
- char *cur_host;
- char host_description[SOCKI_DESCRIPTION_LENGTH];
- /* user pointer */
- void *user_ptr;
- /* internal list */
- struct sock_state_t *list, *next;
- int accepted;
- int listener_closed;
- /* timing variables for completion notification */
- /*
- double rt1, rt2;
- double wt1, wt2;
- double ct1, ct2;
- */
- struct sock_state_t *next_sock;
-} sock_state_t;
-
-static int g_num_cp_threads = 2;
-static int g_socket_buffer_size = SOCKI_TCP_BUFFER_SIZE;
-static int g_socket_rbuffer_size = SOCKI_TCP_BUFFER_SIZE;
-static int g_socket_sbuffer_size = SOCKI_TCP_BUFFER_SIZE;
-static int g_init_called = 0;
-static int g_num_posted_accepts = SOCKI_NUM_PREPOSTED_ACCEPTS;
-
-static sock_state_t *g_sock_list = NULL;
-
-/* empty structure used to wake up a sock_wait call */
-sock_state_t g_wakeup_state;
-
-static void translate_error(int error, char *msg, char *prepend)
-{
- HLOCAL str;
- int num_bytes;
- num_bytes = FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_ALLOCATE_BUFFER,
- 0,
- error,
- MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
- (LPTSTR) &str,
- 0,0);
- if (num_bytes == 0)
- {
- if (prepend != NULL)
- MPL_strncpy(msg, prepend, 1024);
- else
- *msg = '\0';
- }
- else
- {
- if (prepend == NULL)
- memcpy(msg, str, num_bytes+1);
- else
- MPL_snprintf(msg, 1024, "%s%s", prepend, (const char*)str);
- LocalFree(str);
- strtok(msg, "\r\n");
- }
-}
-
-static char *get_error_string(int error_code)
-{
- /* obviously not thread safe to store a message like this */
- static char error_msg[1024];
- translate_error(error_code, error_msg, NULL);
- return error_msg;
-}
-
-#undef FUNCNAME
-#define FUNCNAME easy_create
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int easy_create_ranged(SOCKET *sock, int port, unsigned long addr)
-{
- int mpi_errno=MPI_SUCCESS;
- /*struct linger linger;*/
- int optval, len;
- SOCKET temp_sock;
- SOCKADDR_IN sockAddr;
- int use_range = 0;
-
- /* create the non-blocking socket */
- temp_sock = WSASocket(PF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (temp_sock == INVALID_SOCKET)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**socket", "**socket %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
-
- MPIR_ERR_CHKANDJUMP(MPIR_CVAR_CH3_PORT_RANGE.low < 0 || MPIR_CVAR_CH3_PORT_RANGE.low > MPIR_CVAR_CH3_PORT_RANGE.high, mpi_errno, MPI_ERR_OTHER, "**badportrange");
- if (port == 0 && MPIR_CVAR_CH3_PORT_RANGE.low != 0 && MPIR_CVAR_CH3_PORT_RANGE.high != 0)
- {
- use_range = 1;
- port = MPIR_CVAR_CH3_PORT_RANGE.low;
- }
-
- memset(&sockAddr,0,sizeof(sockAddr));
-
- sockAddr.sin_family = AF_INET;
- sockAddr.sin_addr.s_addr = addr;
- sockAddr.sin_port = htons((unsigned short)port);
-
- for (;;)
- {
- if (bind(temp_sock, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
- {
- if (use_range)
- {
- port++;
- if (port > MPIR_CVAR_CH3_PORT_RANGE.high)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**socket", 0);
- return mpi_errno;
- }
- sockAddr.sin_port = htons((unsigned short)port);
- }
- else
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**socket", "**socket %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
- }
- else
- {
- break;
- }
- }
-
- /* Set the linger on close option */
- /*
- linger.l_onoff = 1 ;
- linger.l_linger = 60;
- setsockopt(temp_sock, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(linger));
- */
-
- /* set the socket to non-blocking */
- /*
- optval = TRUE;
- ioctlsocket(temp_sock, FIONBIO, &optval);
- */
-
- /* set the socket buffers */
- len = sizeof(int);
- if (!getsockopt(temp_sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, &len))
- {
- optval = g_socket_rbuffer_size;
- setsockopt(temp_sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, sizeof(int));
- }
- len = sizeof(int);
- if (!getsockopt(temp_sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, &len))
- {
- optval = g_socket_sbuffer_size;
- setsockopt(temp_sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, sizeof(int));
- }
-
- /* prevent the socket from being inherited by child processes */
- if (!DuplicateHandle(
- GetCurrentProcess(), (HANDLE)temp_sock,
- GetCurrentProcess(), (HANDLE*)sock,
- 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
- {
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**duphandle", "**duphandle %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
-
- /* Set the no-delay option */
- setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, (char *)&optval, sizeof(optval));
-
- fn_exit:
- return mpi_errno;
- fn_fail:
- goto fn_exit;
-}
-
-#undef FUNCNAME
-#define FUNCNAME easy_create
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static int easy_create(SOCKET *sock, int port, unsigned long addr)
-{
- int mpi_errno;
- /*struct linger linger;*/
- int optval, len;
- SOCKET temp_sock;
- SOCKADDR_IN sockAddr;
-
- /* create the non-blocking socket */
- temp_sock = WSASocket(PF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (temp_sock == INVALID_SOCKET)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**socket", "**socket %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
-
- memset(&sockAddr,0,sizeof(sockAddr));
-
- sockAddr.sin_family = AF_INET;
- sockAddr.sin_addr.s_addr = addr;
- sockAddr.sin_port = htons((unsigned short)port);
-
- if (bind(temp_sock, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**socket", "**socket %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
-
- /* Set the linger on close option */
- /*
- linger.l_onoff = 1 ;
- linger.l_linger = 60;
- setsockopt(temp_sock, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(linger));
- */
-
- /* set the socket to non-blocking */
- /*
- optval = TRUE;
- ioctlsocket(temp_sock, FIONBIO, &optval);
- */
-
- /* set the socket buffers */
- len = sizeof(int);
- if (!getsockopt(temp_sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, &len))
- {
- optval = g_socket_rbuffer_size;
- setsockopt(temp_sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, sizeof(int));
- }
- len = sizeof(int);
- if (!getsockopt(temp_sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, &len))
- {
- optval = g_socket_sbuffer_size;
- setsockopt(temp_sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, sizeof(int));
- }
-
- /* prevent the socket from being inherited by child processes */
- if (!DuplicateHandle(
- GetCurrentProcess(), (HANDLE)temp_sock,
- GetCurrentProcess(), (HANDLE*)sock,
- 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
- {
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**duphandle", "**duphandle %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
-
- /* Set the no-delay option */
- setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, (char *)&optval, sizeof(optval));
-
- return MPI_SUCCESS;
-}
-
-static inline int easy_get_sock_info(SOCKET sock, char *name, int *port)
-{
- struct sockaddr_in addr;
- int name_len = sizeof(addr);
- DWORD len = 100;
-
- getsockname(sock, (struct sockaddr*)&addr, &name_len);
- *port = ntohs(addr.sin_port);
- /*GetComputerName(name, &len);*/
- GetComputerNameEx(ComputerNameDnsFullyQualified, name, &len);
- /*gethostname(name, 100);*/
-
- return 0;
-}
-
-static inline void init_state_struct(sock_state_t *p)
-{
- p->listen_sock = INVALID_SOCKET;
- p->sock = INVALID_SOCKET;
- p->set = INVALID_HANDLE_VALUE;
- p->user_ptr = NULL;
- p->type = 0;
- p->state = 0;
- p->closing = FALSE;
- p->pending_operations = 0;
- p->read.total = 0;
- p->read.num_bytes = 0;
- p->read.tiov.MPL_IOV_BUF = NULL;
-#ifndef USE_SOCK_IOV_COPY
- p->read.iov = NULL;
-#endif
- p->read.iovlen = 0;
- p->read.ovl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- p->read.ovl.Offset = 0;
- p->read.ovl.OffsetHigh = 0;
- p->read.progress_update = NULL;
- p->write.total = 0;
- p->write.num_bytes = 0;
- p->write.tiov.MPL_IOV_BUF = NULL;
-#ifndef USE_SOCK_IOV_COPY
- p->write.iov = NULL;
-#endif
- p->write.iovlen = 0;
- p->write.ovl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- p->write.ovl.Offset = 0;
- p->write.ovl.OffsetHigh = 0;
- p->write.progress_update = NULL;
- p->list = NULL;
- p->next = NULL;
- p->accepted = 0;
- p->listener_closed = 0;
- /*
- p->bogus_t1 = 0;
- p->bogus_t2 = 0;
- */
- p->next_sock = g_sock_list;
- g_sock_list = p;
-}
-
-#undef FUNCNAME
-#define FUNCNAME post_next_accept
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-static inline int post_next_accept(sock_state_t * context)
-{
- int mpi_errno;
- context->state = SOCKI_ACCEPTING;
- context->accepted = 0;
- /*printf("posting an accept.\n");fflush(stdout);*/
- context->sock = WSASocket(PF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (context->sock == INVALID_SOCKET)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
- if (!AcceptEx(
- context->listen_sock,
- context->sock,
- context->accept_buffer,
- 0,
- sizeof(struct sockaddr_in)+16,
- sizeof(struct sockaddr_in)+16,
- &context->read.num_bytes,
- &context->read.ovl))
- {
- mpi_errno = WSAGetLastError();
- if (mpi_errno == ERROR_IO_PENDING)
- return MPI_SUCCESS;
- /*MPL_error_printf("AcceptEx failed with error %d\n", error);fflush(stdout);*/
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- return mpi_errno;
- }
- return MPI_SUCCESS;
-}
-
-/* sock functions */
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_init
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_init()
-{
- int mpi_errno;
- char *szNum, *szRange;
- WSADATA wsaData;
- int err;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_INIT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_INIT);
-
- if (g_init_called)
- {
- g_init_called++;
- /*printf("sock init %d\n", g_init_called);fflush(stdout);*/
- /*
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
- return mpi_errno;
- */
- return MPI_SUCCESS;
- }
-
- /* Start the Winsock dll */
- if ((err = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**wsasock", "**wsasock %s %d", get_error_string(err), err);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
- return mpi_errno;
- }
-
- /* get the socket buffer size */
- szNum = getenv("MPICH_SOCKET_BUFFER_SIZE");
- if (szNum != NULL)
- {
- g_socket_buffer_size = atoi(szNum);
- if (g_socket_buffer_size < 0)
- g_socket_buffer_size = SOCKI_TCP_BUFFER_SIZE;
- }
-
- g_socket_rbuffer_size = g_socket_buffer_size;
- g_socket_sbuffer_size = g_socket_buffer_size;
-
- szNum = getenv("MPICH_SOCKET_RBUFFER_SIZE");
- if (szNum != NULL)
- {
- g_socket_rbuffer_size = atoi(szNum);
- if (g_socket_rbuffer_size < 0)
- g_socket_rbuffer_size = g_socket_buffer_size;
- }
-
- szNum = getenv("MPICH_SOCKET_SBUFFER_SIZE");
- if (szNum != NULL)
- {
- g_socket_sbuffer_size = atoi(szNum);
- if (g_socket_sbuffer_size < 0)
- g_socket_sbuffer_size = g_socket_buffer_size;
- }
-
- /* get the number of accepts to pre-post */
- szNum = getenv("MPICH_SOCKET_NUM_PREPOSTED_ACCEPTS");
- if (szNum != NULL)
- {
- g_num_posted_accepts = atoi(szNum);
- if (g_num_posted_accepts < 1)
- g_num_posted_accepts = SOCKI_NUM_PREPOSTED_ACCEPTS;
- }
-
- init_state_struct(&g_wakeup_state);
- g_wakeup_state.type = SOCKI_WAKEUP;
-
- g_init_called = 1;
- /*printf("sock init %d\n", g_init_called);fflush(stdout);*/
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_INIT);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_finalize
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_finalize()
-{
- int mpi_errno;
- sock_state_t *iter;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_FINALIZE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_FINALIZE);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
- return mpi_errno;
- }
- g_init_called--;
- if (g_init_called == 0)
- {
- iter = g_sock_list;
- while (iter)
- {
- if (iter->sock != INVALID_SOCKET)
- {
- /*printf("sock %d not closed before finalize\n", iter->sock);fflush(stdout);*/
- closesocket(iter->sock);
- iter->sock = INVALID_SOCKET;
- }
- iter = iter->next_sock;
- if (iter == g_sock_list)
- {
- /* catch loops */
- /*printf("sock list has a loop\n");fflush(stdout);*/
- break;
- }
- }
- WSACleanup();
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_FINALIZE);
- return MPI_SUCCESS;
-}
-
-typedef struct socki_host_name_t
-{
- char host[256];
- struct socki_host_name_t *next;
-} socki_host_name_t;
-
-static int already_used_or_add(char *host, socki_host_name_t **list)
-{
- socki_host_name_t *iter, *trailer;
-
- /* check if the host already has been used */
- iter = trailer = *list;
- while (iter)
- {
- if (strcmp(iter->host, host) == 0)
- {
- return 1;
- }
- if (trailer != iter)
- trailer = trailer->next;
- iter = iter->next;
- }
-
- /* the host has not been used so add a node for it */
- iter = (socki_host_name_t*)MPL_malloc(sizeof(socki_host_name_t));
- if (!iter)
- {
- /* if out of memory then treat it as not found */
- return 0;
- }
- MPL_strncpy(iter->host, host, 256);
-
- /* insert new hosts at the end of the list */
- if (trailer != NULL)
- {
- trailer->next = iter;
- iter->next = NULL;
- }
- else
- {
- iter->next = NULL;
- *list = iter;
- }
- /* insert new hosts at the beginning of the list
- iter->next = *list;
- *list = iter;
- */
-
- return 0;
-}
-
-static void socki_free_host_list(socki_host_name_t *list)
-{
- socki_host_name_t *iter;
- while (list)
- {
- iter = list;
- list = list->next;
- MPL_free(iter);
- }
-}
-
-static int socki_get_host_list(char *hostname, socki_host_name_t **listp)
-{
- int mpi_errno;
- struct addrinfo *res, *iter, hint;
- char host[256];
- socki_host_name_t *list = NULL;
-
- /* add the hostname to the beginning of the list */
- already_used_or_add(hostname, &list);
-
- hint.ai_flags = AI_PASSIVE | AI_CANONNAME;
- hint.ai_family = PF_UNSPEC;
- hint.ai_socktype = SOCK_STREAM;
- hint.ai_protocol = 0;
- hint.ai_addrlen = 0;
- hint.ai_canonname = NULL;
- hint.ai_addr = 0;
- hint.ai_next = NULL;
- if (getaddrinfo(hostname, NULL, NULL/*&hint*/, &res))
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**getinfo", "**getinfo %s %d", strerror(errno), errno);
- return mpi_errno;
- }
-
- /* add the host names */
- iter = res;
- while (iter)
- {
- if (iter->ai_canonname)
- {
- already_used_or_add(iter->ai_canonname, &list);
- }
- else
- {
- switch (iter->ai_family)
- {
- case PF_INET:
- case PF_INET6:
- if (getnameinfo(iter->ai_addr, (socklen_t)iter->ai_addrlen, host, 256, NULL, 0, 0) == 0)
- {
- already_used_or_add(host, &list);
- }
- break;
- }
- }
- iter = iter->ai_next;
- }
- /* add the names again, this time as ip addresses */
- iter = res;
- while (iter)
- {
- switch (iter->ai_family)
- {
- case PF_INET:
- case PF_INET6:
- if (getnameinfo(iter->ai_addr, (socklen_t)iter->ai_addrlen, host, 256, NULL, 0, NI_NUMERICHOST) == 0)
- {
- already_used_or_add(host, &list);
- }
- break;
- }
- iter = iter->ai_next;
- }
- if (res)
- {
- freeaddrinfo(res);
- }
-
- *listp = list;
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_hostname_to_host_description
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_hostname_to_host_description(char *hostname, char *host_description, int len)
-{
- int mpi_errno = MPI_SUCCESS;
- int str_errno = MPL_STR_SUCCESS;
- socki_host_name_t *iter, *list = NULL;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
- return mpi_errno;
- }
-
- mpi_errno = socki_get_host_list(hostname, &list);
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**fail", 0);
- goto fn_exit;
- }
-
- iter = list;
- while (iter)
- {
- MPL_DBG_MSG_S(MPIR_DBG_OTHER,TERSE,"adding host: %s\n", iter->host);
- str_errno = MPL_str_add_string(&host_description, &len, iter->host);
- MPIR_ERR_CHKANDJUMP(str_errno, mpi_errno, MPIDU_SOCK_ERR_NOMEM, "**desc_len");
-
- iter = iter->next;
- }
-
- fn_exit:
- socki_free_host_list(list);
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_HOSTNAME_TO_HOST_DESCRIPTION);
- return mpi_errno;
- fn_fail:
- goto fn_exit;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_host_description
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_host_description(int myRank,
- char * host_description, int len)
-{
- int mpi_errno;
- char hostname[100];
- DWORD length = 100;
- char *env;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
-
- MPL_UNREFERENCED_ARG(myRank);
-
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
- return mpi_errno;
- }
-
- env = getenv("MPICH_INTERFACE_HOSTNAME");
- if (env != NULL && *env != '\0')
- {
- MPL_strncpy(hostname, env, sizeof(hostname));
- }
- else
- {
- /*if (gethostname(hostname, 100) == SOCKET_ERROR)*/
- /*if (!GetComputerName(hostname, &length))*/
- if (!GetComputerNameEx(ComputerNameDnsFullyQualified, hostname, &length))
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock_gethost", "**sock_gethost %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
- return mpi_errno;
- }
- }
-
- mpi_errno = MPIDU_Sock_hostname_to_host_description(hostname, host_description, len);
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**fail", 0);
- }
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_HOST_DESCRIPTION);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_create_set
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_create_set(MPIDU_Sock_set_t * set)
-{
- int mpi_errno;
- HANDLE port;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_CREATE_SET);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- return mpi_errno;
- }
- port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, g_num_cp_threads);
- if (port != NULL)
- {
- *set = port;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- return MPI_SUCCESS;
- }
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**iocp", "**iocp %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_CREATE_SET);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_destroy_set
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_destroy_set(MPIDU_Sock_set_t set)
-{
- int mpi_errno;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- return mpi_errno;
- }
- if (!CloseHandle(set))
- {
- mpi_errno = GetLastError();
- if (mpi_errno == ERROR_INVALID_HANDLE)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SET, "**bad_set", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- return mpi_errno;
- }
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- return mpi_errno;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_DESTROY_SET);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_native_to_sock
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_native_to_sock(MPIDU_Sock_set_t set, MPIDU_SOCK_NATIVE_FD fd, void *user_ptr, MPIDU_Sock_t *sock_ptr)
-{
- int mpi_errno;
- /*int ret_val;*/
- sock_state_t *sock_state;
- /*u_long optval;*/
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
- return mpi_errno;
- }
-
- /* setup the structures */
- sock_state = (sock_state_t*)MPL_malloc(sizeof(sock_state_t));
- if (sock_state == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
- return mpi_errno;
- }
- init_state_struct(sock_state);
- sock_state->sock = (SOCKET)fd;
-
- /* set the socket to non-blocking */
- /* leave the native handle in the state passed in?
- optval = TRUE;
- ioctlsocket(sock_state->sock, FIONBIO, &optval);
- */
-
- sock_state->user_ptr = user_ptr;
- sock_state->type = SOCKI_SOCKET;
- sock_state->state = 0;
- sock_state->set = set;
-
- /* associate the socket with the completion port */
- /*printf("CreateIOCompletionPort(%d, %p, %p, %d)\n", sock_state->sock, set, sock_state, g_num_cp_threads);fflush(stdout);*/
- if (CreateIoCompletionPort((HANDLE)sock_state->sock, set, (ULONG_PTR)sock_state, g_num_cp_threads) == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
- return mpi_errno;
- }
-
- *sock_ptr = sock_state;
-
- /*printf("native socket %d\n", sock_state->sock);fflush(stdout);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_NATIVE_TO_SOCK);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_listen
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_listen(MPIDU_Sock_set_t set, void * user_ptr, int * port, MPIDU_Sock_t * sock)
-{
- int mpi_errno;
- char host[100];
- sock_state_t * listen_state, **listener_copies;
- int i;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_LISTEN);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MEMCPY);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_LISTEN);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
- }
-
- listen_state = (sock_state_t*)MPL_malloc(sizeof(sock_state_t));
- init_state_struct(listen_state);
- mpi_errno = easy_create_ranged(&listen_state->listen_sock, *port, INADDR_ANY);
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock_create", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
- }
- if (listen(listen_state->listen_sock, SOMAXCONN) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**listen", "**listen %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
- }
- if (CreateIoCompletionPort((HANDLE)listen_state->listen_sock, set, (ULONG_PTR)listen_state, g_num_cp_threads) == NULL)
- {
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**iocp", "**iocp %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
- }
- easy_get_sock_info(listen_state->listen_sock, host, port);
- listen_state->user_ptr = user_ptr;
- listen_state->type = SOCKI_LISTENER;
- listen_state->set = set;
-
- /* post the accept(s) last to make sure the listener state structure is completely initialized before
- a completion thread has the chance to satisfy the AcceptEx call */
-
- listener_copies = (sock_state_t**)MPL_malloc(g_num_posted_accepts * sizeof(sock_state_t*));
- for (i=0; i<g_num_posted_accepts; i++)
- {
- listener_copies[i] = (sock_state_t*)MPL_malloc(sizeof(sock_state_t));
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MEMCPY);
- memcpy(listener_copies[i], listen_state, sizeof(*listen_state));
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MEMCPY);
- if (i > 0)
- {
- listener_copies[i]->next = listener_copies[i-1];
- }
- mpi_errno = post_next_accept(listener_copies[i]);
- if (mpi_errno != MPI_SUCCESS)
- {
- MPL_free(listener_copies);
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**post_accept", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return mpi_errno;
- }
- }
- listen_state->list = listener_copies[g_num_posted_accepts-1];
- MPL_free(listener_copies);
-
- *sock = listen_state;
- /*printf("listening socket %d\n", listen_state->listen_sock);fflush(stdout);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_LISTEN);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_accept
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_accept(MPIDU_Sock_t listener_sock, MPIDU_Sock_set_t set, void * user_ptr, MPIDU_Sock_t * sock)
-{
- int mpi_errno;
- BOOL b;
- /*struct linger linger;*/
- u_long optval;
- int len;
- sock_state_t *accept_state, *iter;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_ACCEPT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_ACCEPT);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
- }
-
- accept_state = MPL_malloc(sizeof(sock_state_t));
- if (accept_state == NULL)
- {
- *sock = NULL;
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
- }
- init_state_struct(accept_state);
-
- accept_state->type = SOCKI_SOCKET;
-
- /* find the listener copy that satisfied the acceptex call and post another accept */
- iter = listener_sock->list;
- while (iter != NULL && iter->accepted == 0)
- iter = iter->next;
- if (iter == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock_nop_accept", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
- }
- accept_state->sock = iter->sock;
- mpi_errno = post_next_accept(iter);
- if (mpi_errno != MPI_SUCCESS)
- {
- *sock = NULL;
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**post_accept", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
- }
-
- /* finish the accept */
- setsockopt(accept_state->sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (char *)&listener_sock->listen_sock, sizeof(listener_sock->listen_sock));
-
- /* set the socket to non-blocking */
- optval = TRUE;
- ioctlsocket(accept_state->sock, FIONBIO, &optval);
-
- /* set the linger option */
- /*
- linger.l_onoff = 1;
- linger.l_linger = 60;
- setsockopt(accept_state->sock, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(linger));
- */
-
- /* set the socket buffers */
- len = sizeof(int);
- if (!getsockopt(accept_state->sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, &len))
- {
- optval = g_socket_rbuffer_size;
- setsockopt(accept_state->sock, SOL_SOCKET, SO_RCVBUF, (char*)&optval, sizeof(int));
- }
- len = sizeof(int);
- if (!getsockopt(accept_state->sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, &len))
- {
- optval = g_socket_sbuffer_size;
- setsockopt(accept_state->sock, SOL_SOCKET, SO_SNDBUF, (char*)&optval, sizeof(int));
- }
-
- /* set the no-delay option */
- b = TRUE;
- setsockopt(accept_state->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&b, sizeof(BOOL));
-
- /* prevent the socket from being inherited by child processes */
- DuplicateHandle(
- GetCurrentProcess(), (HANDLE)accept_state->sock,
- GetCurrentProcess(), (HANDLE*)&accept_state->sock,
- 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
-
- /* associate the socket with the completion port */
- if (CreateIoCompletionPort((HANDLE)accept_state->sock, set, (ULONG_PTR)accept_state, g_num_cp_threads) == NULL)
- {
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**iocp", "**iocp %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return mpi_errno;
- }
-
- accept_state->user_ptr = user_ptr;
- accept_state->set = set;
- *sock = accept_state;
-
- /*printf("accepted socket %d\n", accept_state->sock);fflush(stdout);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_ACCEPT);
- return MPI_SUCCESS;
-}
-
-static unsigned int GetIP(char *pszIP)
-{
- unsigned int nIP;
- unsigned int a,b,c,d;
- if (pszIP == NULL)
- return 0;
- sscanf(pszIP, "%u.%u.%u.%u", &a, &b, &c, &d);
- /*printf("mask: %u.%u.%u.%u\n", a, b, c, d);fflush(stdout);*/
- nIP = (d << 24) | (c << 16) | (b << 8) | a;
- return nIP;
-}
-
-static unsigned int GetMask(char *pszMask)
-{
- int i, nBits;
- unsigned int nMask = 0;
- unsigned int a,b,c,d;
-
- if (pszMask == NULL)
- return 0;
-
- if (strstr(pszMask, "."))
- {
- sscanf(pszMask, "%u.%u.%u.%u", &a, &b, &c, &d);
- /*printf("mask: %u.%u.%u.%u\n", a, b, c, d);fflush(stdout);*/
- nMask = (d << 24) | (c << 16) | (b << 8) | a;
- }
- else
- {
- nBits = atoi(pszMask);
- for (i=0; i<nBits; i++)
- {
- nMask = nMask << 1;
- nMask = nMask | 0x1;
- }
- }
- /*
- unsigned int a, b, c, d;
- a = ((unsigned char *)(&nMask))[0];
- b = ((unsigned char *)(&nMask))[1];
- c = ((unsigned char *)(&nMask))[2];
- d = ((unsigned char *)(&nMask))[3];
- printf("mask: %u.%u.%u.%u\n", a, b, c, d);fflush(stdout);
- */
- return nMask;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_connect
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_connect(MPIDU_Sock_set_t set, void * user_ptr, char * host_description, int port, MPIDU_Sock_t * sock)
-{
- int mpi_errno;
- int str_errno = MPL_STR_SUCCESS;
- struct hostent *lphost;
- struct sockaddr_in sockAddr;
- sock_state_t *connect_state;
- u_long optval;
- char host[100];
- int i;
- int connected = 0;
- int connect_errno = MPI_SUCCESS;
- char pszNetMask[50];
- char *pEnv, *token;
- unsigned int nNicNet=0, nNicMask=0;
- int use_subnet = 0;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
- if (strlen(host_description) > SOCKI_DESCRIPTION_LENGTH)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
-
- memset(&sockAddr,0,sizeof(sockAddr));
-
- /* setup the structures */
- connect_state = (sock_state_t*)MPL_malloc(sizeof(sock_state_t));
- init_state_struct(connect_state);
- connect_state->cur_host = connect_state->host_description;
- MPL_strncpy(connect_state->host_description, host_description, SOCKI_DESCRIPTION_LENGTH);
-
- /* create a socket */
- mpi_errno = easy_create(&connect_state->sock, ADDR_ANY, INADDR_ANY);
- if (mpi_errno != MPI_SUCCESS)
- {
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_create", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
-
- /* check to see if a subnet was specified through the environment */
- pEnv = getenv("MPICH_NETMASK");
- if (pEnv != NULL)
- {
- MPL_strncpy(pszNetMask, pEnv, 50);
- token = strtok(pszNetMask, "/");
- if (token != NULL)
- {
- token = strtok(NULL, "\n");
- if (token != NULL)
- {
- nNicNet = GetIP(pszNetMask);
- nNicMask = GetMask(token);
- use_subnet = 1;
- }
- }
- }
-
- while (!connected)
- {
- host[0] = '\0';
- str_errno = MPL_str_get_string(&connect_state->cur_host, host, 100);
- /*printf("got <%s> out of <%s>\n", host, connect_state->host_description);fflush(stdout);*/
- if (str_errno != MPL_STR_SUCCESS)
- {
- if (str_errno == MPL_STR_NOMEM)
- mpi_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_NOMEM, "**nomem", 0);
- else
- mpi_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %d", mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
- if (host[0] == '\0')
- {
- mpi_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**sock_connect", "**sock_connect %s %d %s %d", connect_state->host_description, port, "exhausted all endpoints", -1);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
-
- sockAddr.sin_family = AF_INET;
- sockAddr.sin_addr.s_addr = inet_addr(host);
-
- if (sockAddr.sin_addr.s_addr == INADDR_NONE || sockAddr.sin_addr.s_addr == 0)
- {
- lphost = gethostbyname(host);
- if (lphost != NULL)
- sockAddr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
- else
- {
- mpi_errno = WSAGetLastError();
- connect_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**gethostbyname", "**gethostbyname %s %d", get_error_string(mpi_errno), mpi_errno);
- /*
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- */
- continue;
- }
- }
-
- /* if a subnet was specified, make sure the currently extracted ip falls in the subnet */
- if (use_subnet)
- {
- if ((sockAddr.sin_addr.s_addr & nNicMask) != nNicNet)
- {
- /* this ip does not match, move to the next */
- continue;
- }
- }
-
- sockAddr.sin_port = htons((u_short)port);
-
- /* connect */
- for (i=0; i<5; i++)
- {
- /*printf("connecting to %s\n", host);fflush(stdout);*/
- if (connect(connect_state->sock, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
- {
- int random_time;
- int error = WSAGetLastError();
- if ((error != WSAECONNREFUSED && error != WSAETIMEDOUT) || i == 4)
- {
- connect_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_connect", "**sock_connect %s %d %s %d", host, port, get_error_string(error), error);
- /*
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- */
- /* This code assumes that all errors other than WSAECONNREFUSED and WSAETIMEDOUT should not cause a connection retry */
- /* FIXME: Is this correct for resource errors like WSAENOBUFS or an interrupted operation? */
- /* Should all errors cause a retry? or just WSAECONNREFUSED? or a subset of the possible errors? */
- /* The reason for not retrying on all errors is that it slows down connection time for multi-nic
- /* hosts that cannot be contacted on the first address listed. */
- break;
- }
- /* Close the socket with an error and create a new one */
- if (closesocket(connect_state->sock) == SOCKET_ERROR)
- {
- error = WSAGetLastError();
- connect_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_connect", "**sock_connect %s %d %s %d", host, port, get_error_string(error), error);
- /*
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- */
- break;
- }
- connect_state->sock = INVALID_SOCKET;
- mpi_errno = easy_create(&connect_state->sock, ADDR_ANY, INADDR_ANY);
- if (mpi_errno != MPI_SUCCESS)
- {
- /* Warning: Loss of information. We have two error stacks, one in connect_errno and the other in mpi_errno, that cannot be joined given the current error code interface. */
- /*connect_errno = MPIR_Err_create_code(connect_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_create", 0);*/
- mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_create", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
- random_time = (int)((double)rand() / (double)RAND_MAX * 250.0);
- Sleep(random_time);
- }
- else
- {
- /*printf("connect to %s:%d succeeded.\n", host, port);fflush(stdout);*/
- connected = 1;
- break;
- }
- }
- }
-
- /* set the socket to non-blocking */
- optval = TRUE;
- ioctlsocket(connect_state->sock, FIONBIO, &optval);
-
- connect_state->user_ptr = user_ptr;
- connect_state->type = SOCKI_SOCKET;
- connect_state->state = SOCKI_CONNECTING;
- connect_state->set = set;
-
- /* associate the socket with the completion port */
- if (CreateIoCompletionPort((HANDLE)connect_state->sock, set, (ULONG_PTR)connect_state, g_num_cp_threads) == NULL)
- {
- mpi_errno = GetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**iocp", "**iocp %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return mpi_errno;
- }
-
- connect_state->pending_operations++;
-
- /* post a completion event so the sock_post_connect can be notified through sock_wait */
- PostQueuedCompletionStatus(set, 0, (ULONG_PTR)connect_state, &connect_state->write.ovl);
-
- *sock = connect_state;
-
- /*printf("connected socket %d\n", connect_state->sock);fflush(stdout);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CONNECT);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_set_user_ptr
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_set_user_ptr(MPIDU_Sock_t sock, void * user_ptr)
-{
- int mpi_errno;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- return mpi_errno;
- }
- if (sock == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**bad_sock", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- return mpi_errno;
- }
- sock->user_ptr = user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_SET_USER_PTR);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_close
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_close(MPIDU_Sock_t sock)
-{
- int mpi_errno;
- SOCKET s, *sp;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
-
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
-
- if (sock == NULL)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**nullptr", "**nullptr %s", "sock");
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
- if (sock->closing)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**pctwice", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
-
- if (sock->type == SOCKI_LISTENER)
- {
- s = sock->listen_sock;
- sp = &sock->listen_sock;
- }
- else
- {
- s = sock->sock;
- sp = &sock->sock;
- }
- if (s == INVALID_SOCKET)
- {
- if (sock->type == SOCKI_LISTENER)
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**bad_listenersock", 0);
- else
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**bad_sock", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
-
- if (sock->pending_operations != 0)
- {
- /*MPIR_Assert(sock->state != 0);*/ /* The state can be 0 if the operation was aborted */
-#ifdef MPICH_DBG_OUTPUT
- if (sock->state & SOCKI_CONNECTING)
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_post_close(%d) called while sock is connecting.\n", MPIDU_Sock_get_sock_id(sock));
- if (sock->state & SOCKI_READING)
- {
- int i, n = 0;
- for (i=0; i<sock->read.iovlen; i++)
- n += sock->read.iov[i].MPL_IOV_LEN;
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_post_close(%d) called while sock is reading: %d bytes out of %d, index %d, iovlen %d.\n",
- MPIDU_Sock_get_sock_id(sock), sock->read.total, n, sock->read.index, sock->read.iovlen));
- }
- if (sock->state & SOCKI_WRITING)
- {
- int i, n = 0;
- for (i=0; i<sock->write.iovlen; i++)
- n += sock->write.iov[i].MPL_IOV_LEN;
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_post_close(%d) called while sock is writing: %d bytes out of %d, index %d, iovlen %d.\n",
- MPIDU_Sock_get_sock_id(sock), sock->write.total, n, sock->write.index, sock->write.iovlen));
- }
- fflush(stdout);
-#endif
- /*
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return SOCK_ERR_OP_IN_PROGRESS;
- */
- /* posting a close cancels all outstanding operations */
- /* It would be nice to cancel the outstanding reads or writes and then close the socket after handling the cancelled operations */
- /* But it cannot be done because CancelIo only cancels operations started by the current thread. There is no way to cancel all operations. */
- /*CancelIo(sock->sock);*/
- }
-
- sock->closing = TRUE;
- /*sock->ct1 = PMPI_Wtime();*/
- if (sock->type != SOCKI_LISTENER) /* calling shutdown for a listening socket is not valid */
- {
- /* Mark the socket as non-writable */
- if (shutdown(s, SD_SEND) == SOCKET_ERROR)
- {
- sock->pending_operations = 0;
- /*printf("closing socket %d\n", s);fflush(stdout);*/
- if (closesocket(s) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
- *sp = INVALID_SOCKET;
- if (!PostQueuedCompletionStatus(sock->set, 0, (ULONG_PTR)sock, NULL))
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**fail", "**fail %d", GetLastError());
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return MPI_SUCCESS;
- }
- }
- /* Cancel any outstanding operations */
- sock->pending_operations = 0;
-
- if (sock->type == SOCKI_SOCKET)
- {
- static char ch;
- mpi_errno = MPI_SUCCESS;
- if (sock->state ^ SOCKI_READING)
- {
- /* If a read is not already posted, post a bogus one here. */
- mpi_errno = MPIDU_Sock_post_read(sock, &ch, 1, 1, NULL);
- /* ignore this posted read so wait will return an op_close */
- sock->pending_operations = 0;
- }
- if (mpi_errno == MPI_SUCCESS)
- {
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return MPI_SUCCESS;
- }
- }
-
- if (sock->type != SOCKI_LISTENER) /* calling shutdown for a listening socket is not valid */
- {
- /* Mark the socket as non-readable */
- if (shutdown(s, SD_RECEIVE) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
- }
- /* Close the socket and insert a completion status so wait will return an op_close */
- /*printf("closing socket %d\n", s);fflush(stdout);*/
- if (closesocket(s) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
-
- }
- *sp = INVALID_SOCKET;
- if (!PostQueuedCompletionStatus(sock->set, 0, (ULONG_PTR)sock, NULL))
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_BAD_SOCK, "**fail", "**fail %d", GetLastError());
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return mpi_errno;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_CLOSE);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_read
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_read(MPIDU_Sock_t sock, void * buf, size_t minbr, size_t maxbr,
- MPIDU_Sock_progress_update_func_t fn)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READ);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READ);
- MPL_UNREFERENCED_ARG(maxbr);
- sock->read.tiov.MPL_IOV_BUF = (MPL_IOV_BUF_CAST)buf;
- sock->read.tiov.MPL_IOV_LEN = minbr;
- mpi_errno = MPIDU_Sock_post_readv(sock, &sock->read.tiov, 1, fn);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READ);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_readv
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
-{
- int iter;
- int mpi_errno = MPI_SUCCESS;
- int result;
-#ifdef MPICH_DBG_OUTPUT
- int i;
-#endif
- DWORD flags = 0;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_READV);
-#ifdef USE_SOCK_IOV_COPY
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MEMCPY);
-#endif
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_READV);
- if (!g_init_called)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_INIT, "**sock_init", 0);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
- return mpi_errno;
- }
- /*sock->rt1 = PMPI_Wtime();*/
- /* strip any trailing empty buffers */
- while (iov_n && iov[iov_n-1].MPL_IOV_LEN == 0)
- iov_n--;
- sock->read.total = 0;
-#ifdef USE_SOCK_IOV_COPY
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MEMCPY);
- memcpy(sock->read.iov, iov, sizeof(MPL_IOV) * n);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MEMCPY);
-#else
- sock->read.iov = iov;
-#endif
- sock->read.iovlen = iov_n;
- sock->read.index = 0;
- sock->read.progress_update = fn;
- sock->state |= SOCKI_READING;
-#ifdef MPICH_DBG_OUTPUT
- for (i=0; i<iov_n; i++)
- {
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_post_readv - iov[%d].len = %d\n", i, iov[i].MPL_IOV_LEN));
- }
-#endif
- for (iter=0; iter<10; iter++)
- {
- if ((result = WSARecv(sock->sock, sock->read.iov, iov_n, &sock->read.num_bytes, &flags, &sock->read.ovl, NULL)) != SOCKET_ERROR)
- {
- break;
- }
-
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = sock->read.iov[0].buf;
- tmp.len = sock->read.iov[0].len;
- MPIR_Assert(tmp.len > 0);
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] receiving %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if ((result = WSARecv(sock->sock, &tmp, 1, &sock->read.num_bytes, &flags, &sock->read.ovl, NULL)) != SOCKET_ERROR)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- /*printf("[%d] reducing recv length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- tmp.len = tmp.len / 2;
- if (tmp.len == 0 && mpi_errno == WSAENOBUFS)
- {
- break;
- }
- }
- if (mpi_errno == MPI_SUCCESS)
- {
- break;
- }
- }
- if (mpi_errno != WSAEWOULDBLOCK)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- break;
- }
- Sleep(200);
- }
- if (mpi_errno == MPI_SUCCESS)
- sock->pending_operations++;
- else
- sock->state &= ~SOCKI_READING;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_READV);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_write
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_write(MPIDU_Sock_t sock, void * buf, size_t min, size_t max, MPIDU_Sock_progress_update_func_t fn)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITE);
- MPL_UNREFERENCED_ARG(max);
- sock->write.tiov.MPL_IOV_BUF = (MPL_IOV_BUF_CAST)buf;
- sock->write.tiov.MPL_IOV_LEN = min;
- mpi_errno = MPIDU_Sock_post_writev(sock, &sock->write.tiov, 1, fn);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITE);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_post_writev
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_post_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, MPIDU_Sock_progress_update_func_t fn)
-{
- int mpi_errno = MPI_SUCCESS;
- int iter;
-#ifdef MPICH_DBG_OUTPUT
- int i;
-#endif
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
-#ifdef USE_SOCK_IOV_COPY
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MEMCPY);
-#endif
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
- /*sock->wt1 = PMPI_Wtime();*/
- sock->write.total = 0;
-#ifdef USE_SOCK_IOV_COPY
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MEMCPY);
- memcpy(sock->write.iov, iov, sizeof(MPL_IOV) * iov_n);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MEMCPY);
-#else
- sock->write.iov = iov;
-#endif
- sock->write.iovlen = iov_n;
- sock->write.index = 0;
- sock->write.progress_update = fn;
- sock->state |= SOCKI_WRITING;
-#ifdef MPICH_DBG_OUTPUT
- for (i=0; i<iov_n; i++)
- {
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_post_writev - iov[%d].len = %d\n", i, iov[i].MPL_IOV_LEN));
- }
-#endif
- for (iter=0; iter<10; iter++)
- {
- if (WSASend(sock->sock, sock->write.iov, iov_n, &sock->write.num_bytes, 0, &sock->write.ovl, NULL) != SOCKET_ERROR)
- break;
-
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = sock->write.iov[0].buf;
- tmp.len = sock->write.iov[0].len;
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] sending %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if (WSASend(sock->sock, &tmp, 1, &sock->write.num_bytes, 0, &sock->write.ovl, NULL) != SOCKET_ERROR)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- mpi_errno = MPI_SUCCESS;
- break;
- }
- /*printf("[%d] reducing send length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- tmp.len = tmp.len / 2;
- if (tmp.len == 0)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", 0);
- break;
- }
- }
- if (mpi_errno == MPI_SUCCESS)
- {
- break;
- }
- }
- if (mpi_errno != WSAEWOULDBLOCK)
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- break;
- }
- Sleep(200);
- }
- if (mpi_errno == MPI_SUCCESS)
- sock->pending_operations++;
- else
- sock->state &= ~SOCKI_WRITING;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_POST_WRITEV);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wait
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wait(MPIDU_Sock_set_t set, int timeout, MPIDU_Sock_event_t * out)
-{
- /*double t1, t2;*/
- int mpi_errno;
- DWORD num_bytes;
- sock_state_t *sock, *iter;
- OVERLAPPED *ovl;
- DWORD dwFlags = 0;
- char error_msg[1024];
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WAIT);
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_GETQUEUEDCOMPLETIONSTATUS);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WAIT);
-
- for (;;)
- {
-#if defined(MPICH_IS_THREADED)
-# if (MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL)
- {
- int err;
- /* Release the lock so that other threads may make progress while this thread waits for something to do */
- MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Exit global critical section");
- MPIR_THREAD_CHECK_BEGIN;
- MPID_Thread_mutex_unlock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
- MPIR_THREAD_CHECK_END;
- }
-# else
-# error selected multi-threaded implementation is not supported
-# endif
-#endif
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_GETQUEUEDCOMPLETIONSTATUS);
- /* initialize to NULL so we can compare the output of GetQueuedCompletionStatus */
- sock = NULL;
- ovl = NULL;
- num_bytes = 0;
- /*t1 = PMPI_Wtime();*/
- if (GetQueuedCompletionStatus(set, &num_bytes, (PULONG_PTR)&sock, &ovl, timeout))
- {
- /*t2 = PMPI_Wtime();*/
- /*printf("[%d] GetQueuedCompletionStatus took %.3f seconds for sock: %d\n", getpid(), t2-t1, sock->sock);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_GETQUEUEDCOMPLETIONSTATUS);
-#if defined(MPICH_IS_THREADED)
-# if (MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL)
- {
- int err;
- /* Reaquire the lock before processing any of the information returned from GetQueuedCompletionStatus */
- MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Enter global critical section");
- MPIR_THREAD_CHECK_BEGIN;
- MPID_Thread_mutex_lock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
- MPIR_THREAD_CHECK_END;
- }
-# else
-# error selected multi-threaded implementation is not supported
-# endif
-#endif
- if (sock->type == SOCKI_SOCKET)
- {
- if (sock->closing && sock->pending_operations == 0)
- {
- /*sock->ct2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_close to op_close: %.3f - sock %d\n", getpid(), sock->ct2 - sock->ct1, sock->sock);*/
- /*printf("<1>");fflush(stdout);*/
- out->op_type = MPIDU_SOCK_OP_CLOSE;
- out->num_bytes = 0;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- CloseHandle(sock->read.ovl.hEvent);
- CloseHandle(sock->write.ovl.hEvent);
- sock->read.ovl.hEvent = NULL;
- sock->write.ovl.hEvent = NULL;
- if (sock->sock != INVALID_SOCKET)
- {
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- if (ovl == &sock->read.ovl)
- {
- if (num_bytes == 0)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- /* socket closed */
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait readv returning %d bytes and EOF\n", sock->read.total);
- /*printf("sock_wait readv returning %d bytes and EOF\n", sock->read.total);*/
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = sock->read.total;
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_READING; /* remove the SOCKI_READING bit */
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait readv update: %d bytes\n", num_bytes);
- sock->read.total += num_bytes;
- while (num_bytes)
- {
- if (sock->read.iov[sock->read.index].MPL_IOV_LEN <= num_bytes)
- {
- num_bytes -= sock->read.iov[sock->read.index].MPL_IOV_LEN;
- sock->read.index++;
- sock->read.iovlen--;
- }
- else
- {
- sock->read.iov[sock->read.index].MPL_IOV_LEN -= num_bytes;
- sock->read.iov[sock->read.index].MPL_IOV_BUF = (MPL_IOV_BUF_CAST)(
- (char*)(sock->read.iov[sock->read.index].MPL_IOV_BUF) + num_bytes);
- num_bytes = 0;
- }
- }
- if (sock->read.iovlen == 0)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait readv %d bytes\n", sock->read.total);
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = sock->read.total;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_READING; /* remove the SOCKI_READING bit */
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- /* make the user upcall */
- if (sock->read.progress_update != NULL)
- sock->read.progress_update(num_bytes, sock->user_ptr);
- /* post a read of the remaining data */
- /*WSARecv(sock->sock, sock->read.iov, sock->read.iovlen, &sock->read.num_bytes, &dwFlags, &sock->read.ovl, NULL);*/
- if (WSARecv(sock->sock, &sock->read.iov[sock->read.index], sock->read.iovlen, &sock->read.num_bytes, &dwFlags, &sock->read.ovl, NULL) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- if (mpi_errno == 0)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = sock->read.total;
- /*printf("sock_wait returning %d bytes and socket closed\n", sock->read.total);*/
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_READING;
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = sock->read.iov[sock->read.index].buf;
- tmp.len = sock->read.iov[sock->read.index].len;
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] receiving %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if (WSARecv(sock->sock, &tmp, 1, &sock->read.num_bytes, &dwFlags, &sock->read.ovl, NULL) != SOCKET_ERROR)
- {
- mpi_errno = WSA_IO_PENDING;
- break;
- }
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- break;
- }
- /*printf("[%d] reducing recv length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- tmp.len = tmp.len / 2;
- if (tmp.len == 0 && mpi_errno == WSAENOBUFS)
- {
- break;
- }
- }
- }
- if (mpi_errno != WSA_IO_PENDING)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = sock->read.total;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_READING;
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- }
- else if (ovl == &sock->write.ovl)
- {
- if (sock->state & SOCKI_CONNECTING)
- {
- /* insert code here to determine that the connect succeeded */
- /* ... */
- out->op_type = MPIDU_SOCK_OP_CONNECT;
- out->num_bytes = 0;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state ^= SOCKI_CONNECTING; /* remove the SOCKI_CONNECTING bit */
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after connect completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- else
- {
- if (num_bytes == 0)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- /* socket closed */
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait writev returning %d bytes and EOF\n", sock->write.total);
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = sock->write.total;
- /*printf("sock_wait writev returning %d bytes and EOF\n", sock->write.total);*/
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_WRITING; /* remove the SOCKI_WRITING bit */
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov write completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_wait: write update, total = %d + %d = %d\n", sock->write.total, num_bytes, sock->write.total + num_bytes));
- sock->write.total += num_bytes;
- while (num_bytes)
- {
- if (sock->write.iov[sock->write.index].MPL_IOV_LEN <= num_bytes)
- {
- /*MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_wait: write.index %d, len %d\n", sock->write.index,
- sock->write.iov[sock->write.index].MPL_IOV_LEN));*/
- num_bytes -= sock->write.iov[sock->write.index].MPL_IOV_LEN;
- sock->write.index++;
- sock->write.iovlen--;
- }
- else
- {
- /*MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"sock_wait: partial data written [%d].len = %d, num_bytes = %d\n", sock->write.index,
- sock->write.iov[sock->write.index].MPL_IOV_LEN, num_bytes));*/
- sock->write.iov[sock->write.index].MPL_IOV_LEN -= num_bytes;
- sock->write.iov[sock->write.index].MPL_IOV_BUF = (MPL_IOV_BUF_CAST)(
- (char*)(sock->write.iov[sock->write.index].MPL_IOV_BUF) + num_bytes);
- num_bytes = 0;
- }
- }
- if (sock->write.iovlen == 0)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- if (sock->write.total > 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait wrotev %d bytes\n", sock->write.total);
- }
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = sock->write.total;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_WRITING; /* remove the SOCKI_WRITING bit */
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov write completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- /* make the user upcall */
- if (sock->write.progress_update != NULL)
- sock->write.progress_update(num_bytes, sock->user_ptr);
- /* post a write of the remaining data */
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: posting write of the remaining data, vec size %d\n", sock->write.iovlen);
- if (WSASend(sock->sock, sock->write.iov, sock->write.iovlen, &sock->write.num_bytes, 0, &sock->write.ovl, NULL) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- if (mpi_errno == 0)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = sock->write.total;
- /*printf("sock_wait returning %d bytes and socket closed\n", sock->write.total);*/
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_WRITING;
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = sock->write.iov[0].buf;
- tmp.len = sock->write.iov[0].len;
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] sending %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if (WSASend(sock->sock, &tmp, 1, &sock->write.num_bytes, 0, &sock->write.ovl, NULL) != SOCKET_ERROR)
- {
- /* FIXME: does this data need to be handled immediately? */
- mpi_errno = WSA_IO_PENDING;
- break;
- }
- mpi_errno = WSAGetLastError();
- if (mpi_errno == WSA_IO_PENDING)
- {
- break;
- }
- /*printf("[%d] reducing send length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- tmp.len = tmp.len / 2;
- }
- }
- if (mpi_errno != WSA_IO_PENDING)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = sock->write.total;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- out->user_ptr = sock->user_ptr;
- sock->pending_operations--;
- sock->state &= ~SOCKI_WRITING;
- if (sock->closing && sock->pending_operations == 0)
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_wait: closing socket(%d) after iov read completed.\n", MPIDU_Sock_get_sock_id(sock));
- FlushFileBuffers((HANDLE)sock->sock);
- if (shutdown(sock->sock, SD_BOTH) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**shutdown", "**shutdown %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- /*printf("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- }
- }
- else
- {
- if (num_bytes == 0)
- {
- if ((sock->state & SOCKI_READING))/* && sock-sock != INVALID_SOCKET) */
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"EOF with posted read on sock %d\n", sock->sock);
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = sock->read.total;
- /*printf("sock_wait returning %d bytes and EOF\n", sock->read.total);*/
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->state &= ~SOCKI_READING;
- sock->pending_operations--;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- if ((sock->state & SOCKI_WRITING))/* && sock->sock != INVALID_SOCKET) */
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"EOF with posted write on sock %d\n", sock->sock);
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = sock->write.total;
- /*printf("sock_wait returning %d bytes and EOF\n", sock->write.total);*/
- out->error = MPIDU_SOCK_ERR_CONN_CLOSED;
- out->user_ptr = sock->user_ptr;
- sock->state &= ~SOCKI_WRITING;
- sock->pending_operations--;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"ignoring EOF notification on unknown sock %d.\n", MPIDU_Sock_get_sock_id(sock));
- }
-
- if (sock->sock != INVALID_SOCKET)
- {
- MPL_DBG_MSG_FMT(MPIR_DBG_OTHER,TERSE,(MPL_DBG_FDEST,"unmatched ovl: pending: %d, state = %d\n", sock->pending_operations, sock->state));
- /*MPL_error_printf("In sock_wait(), returned overlapped structure does not match the current read or write ovl: 0x%x\n", ovl);*/
- MPL_snprintf(error_msg, 1024, "In sock_wait(), returned overlapped structure does not match the current read or write ovl: 0x%p\n", ovl);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", error_msg);
- }
- else
- {
- MPL_DBG_MSG(MPIR_DBG_OTHER,TERSE,"ignoring notification on invalid sock.\n");
- }
- }
- }
- else if (sock->type == SOCKI_WAKEUP)
- {
- out->op_type = MPIDU_SOCK_OP_WAKEUP;
- out->num_bytes = 0;
- out->error = MPI_SUCCESS;
- out->user_ptr = NULL;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- else if (sock->type == SOCKI_LISTENER)
- {
- if (sock->closing && sock->pending_operations == 0)
- {
- if (!sock->listener_closed)
- {
- /*sock->ct2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_close to op_close: %.3f - sock %d\n", getpid(), sock->ct2 - sock->ct1, sock->sock);*/
- /* signal that the listener has been closed and prevent further posted accept failures from returning extra close_ops */
- sock->listener_closed = 1;
- /*printf("<2>");fflush(stdout);*/
- out->op_type = MPIDU_SOCK_OP_CLOSE;
- out->num_bytes = 0;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- CloseHandle(sock->read.ovl.hEvent);
- CloseHandle(sock->write.ovl.hEvent);
- sock->read.ovl.hEvent = NULL;
- sock->write.ovl.hEvent = NULL;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- else
- {
- /* ignore multiple close operations caused by the outstanding accept operations */
- continue;
- }
- }
- iter = sock->list;
- while (iter && &iter->read.ovl != ovl)
- iter = iter->next;
- if (iter != NULL)
- iter->accepted = 1;
- out->op_type = MPIDU_SOCK_OP_ACCEPT;
- if (sock->listen_sock == INVALID_SOCKET)
- {
- MPL_error_printf("returning MPIDU_SOCK_OP_ACCEPT with an INVALID_SOCKET for the listener\n");
- }
- out->num_bytes = num_bytes;
- out->error = MPI_SUCCESS;
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- else
- {
- /*MPL_error_printf("sock type is not a SOCKET or a LISTENER, it's %d\n", sock->type);*/
- MPL_snprintf(error_msg, 1024, "sock type is not a SOCKET or a LISTENER, it's %d\n", sock->type);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", error_msg);
- }
- }
- else
- {
-#if defined(MPICH_IS_THREADED)
-# if (MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL)
- {
- int err;
- /* Reaquire the lock before processing any of the information returned from GetQueuedCompletionStatus */
- MPL_DBG_MSG(MPIR_DBG_OTHER,TYPICAL,"Enter global critical section");
- MPIR_THREAD_CHECK_BEGIN;
- MPID_Thread_mutex_lock(&MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX, &err);
- MPIR_THREAD_CHECK_END;
- }
-# else
-# error selected multi-threaded implementation is not supported
-# endif
-#endif
- /*MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_GETQUEUEDCOMPLETIONSTATUS);*/ /* Maybe the logging will reset the last error? */
- mpi_errno = GetLastError();
- /*t2 = PMPI_Wtime();*/
- /*printf("[%d] GetQueuedCompletionStatus took %.3f seconds for sock: %d\n", getpid(), t2-t1, sock != NULL ? sock->sock : 0);*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_GETQUEUEDCOMPLETIONSTATUS);
- /* interpret error, return appropriate SOCK_ERR_... macro */
- if (mpi_errno == WAIT_TIMEOUT)
- {
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPIDU_SOCK_ERR_TIMEOUT;
- }
- if (mpi_errno == ERROR_OPERATION_ABORTED)
- {
- /* A thread exited causing GetQueuedCompletionStatus to return prematurely. */
- if (sock != NULL && !sock->closing)
- {
- /* re-post the aborted operation */
- if (sock->type == SOCKI_SOCKET)
- {
- if (ovl == &sock->read.ovl)
- {
- /*printf("repost readv of length %d\n", sock->read.iovlen);fflush(stdout);*/
- mpi_errno = MPIDU_Sock_post_readv(sock, sock->read.iov, sock->read.iovlen, NULL);
- if (mpi_errno != MPI_SUCCESS)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_READ;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Unable to re-post an aborted readv operation");
- out->user_ptr = sock->user_ptr;
- sock->state &= ~SOCKI_READING; /* remove the SOCKI_READING bit */
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else if (ovl == &sock->write.ovl)
- {
- /*printf("repost writev of length %d\n", sock->write.iovlen);fflush(stdout);*/
- mpi_errno = MPIDU_Sock_post_writev(sock, sock->write.iov, sock->write.iovlen, NULL);
- if (mpi_errno != MPI_SUCCESS)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_WRITE;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Unable to re-post an aborted writev operation");
- out->user_ptr = sock->user_ptr;
- sock->state &= ~SOCKI_WRITING; /* remove the SOCKI_WRITING bit */
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else
- {
- /*printf("aborted sock operation\n");fflush(stdout);*/
- out->op_type = -1;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Aborted socket operation");
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else if (sock->type == SOCKI_WAKEUP)
- {
- /*printf("aborted wakeup operation\n");fflush(stdout);*/
- out->op_type = MPIDU_SOCK_OP_WAKEUP;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Aborted wakeup operation");
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- else if (sock->type == SOCKI_LISTENER)
- {
- /*printf("aborted listener operation\n");fflush(stdout);*/
- iter = sock->list;
- while (iter && &iter->read.ovl != ovl)
- iter = iter->next;
- if (iter != NULL)
- {
- mpi_errno = post_next_accept(iter);
- if (mpi_errno != MPI_SUCCESS)
- {
- out->op_type = MPIDU_SOCK_OP_ACCEPT;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Unable to re-post an aborted accept operation");
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else
- {
- /*printf("aborted unknown listener socket operation\n");fflush(stdout);*/
- out->op_type = -1;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Aborted unknown listener socket operation");
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else
- {
- /*printf("aborted unknown socket operation\n");fflush(stdout);*/
- out->op_type = -1;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s", "Aborted unknown socket operation");
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- continue;
- }
- }
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"GetQueuedCompletionStatus failed, GetLastError: %d\n", mpi_errno);
- if (sock != NULL)
- {
- MPL_DBG_MSG(MPIR_DBG_OTHER,TERSE,"GetQueuedCompletionStatus failed, sock != null\n");
- if (sock->type == SOCKI_SOCKET)
- {
- MPL_DBG_MSG(MPIR_DBG_OTHER,TERSE,"GetQueuedCompletionStatus failed, sock == SOCKI_SOCKET \n");
- if (sock->closing)
- {
- /*sock->ct2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_close to op_close: %.3f - sock %d\n", getpid(), sock->ct2 - sock->ct1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_CLOSE;
- if (sock->sock != INVALID_SOCKET)
- {
- /*("closing socket %d\n", sock->sock);fflush(stdout);*/
- if (closesocket(sock->sock) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**closesocket", "**closesocket %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return mpi_errno;
- }
- sock->sock = INVALID_SOCKET;
- }
- }
- else
- {
- if (ovl == &sock->read.ovl)
- {
- /*sock->rt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_read to op_read : %.3f - sock %d\n", getpid(), sock->rt2 - sock->rt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_READ;
- sock->state &= ~SOCKI_READING; /* remove the SOCKI_READING bit */
- }
- else if (ovl == &sock->write.ovl)
- {
- /*sock->wt2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_write to op_write: %.3f - sock %d\n", getpid(), sock->wt2 - sock->wt1, sock->sock);*/
- out->op_type = MPIDU_SOCK_OP_WRITE;
- sock->state &= ~SOCKI_WRITING; /* remove the SOCKI_WRITING bit */
- }
- else
- {
- /* Shoud we reset the state bits? */
- sock->state &= ~SOCKI_READING; /* remove the SOCKI_READING bit */
- sock->state &= ~SOCKI_WRITING; /* remove the SOCKI_WRITING bit */
- out->op_type = -1;
- }
- }
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- if (sock->type == SOCKI_LISTENER)
- {
- MPL_DBG_MSG(MPIR_DBG_OTHER,TERSE,"GetQueuedCompletionStatus failed, sock == SOCKI_LISTENER \n");
- /* this only works if the aborted operation is reported before the close is reported
- because the close will free the sock structure causing these dereferences bogus.
- I need to reference count the sock */
- if (sock->closing)
- {
- if (sock->listener_closed)
- {
- /* only return a close_op once for the main listener, not any of the copies */
- continue;
- }
- else
- {
- /*sock->ct2 = PMPI_Wtime();*/
- /*printf("[%d] time from post_close to op_close: %.3f - sock %d\n", getpid(), sock->ct2 - sock->ct1, sock->sock);*/
- sock->listener_closed = 1;
- /*printf("<3>");fflush(stdout);*/
- out->op_type = MPIDU_SOCK_OP_CLOSE;
- out->num_bytes = 0;
- if (mpi_errno == ERROR_OPERATION_ABORTED)
- out->error = MPI_SUCCESS;
- else
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- else
- {
- /* Should we return a SOCK_OP_ACCEPT with an error if there is a failure on the listener? */
- out->op_type = MPIDU_SOCK_OP_ACCEPT;
- out->num_bytes = 0;
- out->error = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- out->user_ptr = sock->user_ptr;
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- }
- }
- }
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- }
- }
- /* Unreachable code section - all sections exit/return before reaching this segment */
- /*
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WAIT);
- return MPI_SUCCESS;
- */
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_wakeup
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_wakeup(MPIDU_Sock_set_t set)
-{
- /* post a completion event to wake up sock_wait */
- PostQueuedCompletionStatus(set, 0, (ULONG_PTR)&g_wakeup_state, &g_wakeup_state.write.ovl);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_read
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_read(MPIDU_Sock_t sock, void * buf, size_t len, size_t * num_read)
-{
- int mpi_errno = MPI_SUCCESS;
- MPL_IOV iov;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READ);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READ);
- iov.buf = buf;
- iov.len = len;
- mpi_errno = MPIDU_Sock_readv(sock, &iov, 1, num_read);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READ);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_readv
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_readv(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_read)
-{
- int mpi_errno = MPI_SUCCESS;
- DWORD nFlags = 0;
- DWORD num_read_local;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_READV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_READV);
-
- if (WSARecv(sock->sock, iov, iov_n, &num_read_local, &nFlags, NULL/*overlapped*/, NULL/*completion routine*/) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- *num_read = 0;
- if ((mpi_errno == WSAEWOULDBLOCK) || (mpi_errno == 0))
- {
- mpi_errno = MPI_SUCCESS;
- }
- else
- {
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = iov[0].buf;
- tmp.len = iov[0].len;
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] receiving %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if (WSARecv(sock->sock, &tmp, 1, &num_read_local, &nFlags, NULL, NULL) != SOCKET_ERROR)
- {
- /*printf("[%d] read %d bytes\n", __LINE__, num_read_local);fflush(stdout);*/
- *num_read = num_read_local;
- mpi_errno = MPI_SUCCESS;
- break;
- }
- /*printf("[%d] reducing send length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- mpi_errno = WSAGetLastError();
- tmp.len = tmp.len / 2;
- }
- if (mpi_errno != MPI_SUCCESS)
- {
- if (mpi_errno == WSAEWOULDBLOCK)
- {
- mpi_errno = MPI_SUCCESS;
- }
- else
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- }
- }
- }
- else
- {
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- }
- }
- }
- else
- {
- *num_read = num_read_local;
- }
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_readv %d bytes\n", *num_read);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_READV);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_write
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_write(MPIDU_Sock_t sock, void * buf, size_t len, size_t * num_written)
-{
- int mpi_errno;
- MPL_IOV iov;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITE);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITE);
- iov.len = len;
- iov.buf = buf;
- mpi_errno = MPIDU_Sock_writev(sock, &iov, 1, num_written);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITE);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_writev
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_writev(MPIDU_Sock_t sock, MPL_IOV * iov, int iov_n, size_t * num_written)
-{
- int mpi_errno;
- DWORD num_written_local;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_WRITEV);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_WRITEV);
- if (WSASend(sock->sock, iov, iov_n, &num_written_local, 0, NULL/*overlapped*/, NULL/*completion routine*/) == SOCKET_ERROR)
- {
- mpi_errno = WSAGetLastError();
- *num_written = 0;
- if (mpi_errno == WSAENOBUFS)
- {
- WSABUF tmp;
- tmp.buf = iov[0].buf;
- tmp.len = iov[0].len;
- while (mpi_errno == WSAENOBUFS)
- {
- /*printf("[%d] sending %d bytes\n", __LINE__, tmp.len);fflush(stdout);*/
- if (WSASend(sock->sock, &tmp, 1, &num_written_local, 0, NULL, NULL) != SOCKET_ERROR)
- {
- /*printf("[%d] wrote %d bytes\n", __LINE__, num_written_local);fflush(stdout);*/
- *num_written = num_written_local;
- mpi_errno = MPI_SUCCESS;
- break;
- }
- mpi_errno = WSAGetLastError();
- /*printf("[%d] reducing send length from %d to %d\n", __LINE__, tmp.len, tmp.len / 2);fflush(stdout);*/
- tmp.len = tmp.len / 2;
- if (tmp.len == 0 && mpi_errno == WSAENOBUFS)
- {
- break;
- }
- }
- }
- if (mpi_errno && (mpi_errno != WSAEWOULDBLOCK))
- {
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"WSASend failed: error %d\n", mpi_errno);
- mpi_errno = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPIDU_SOCK_ERR_FAIL, "**fail", "**fail %s %d", get_error_string(mpi_errno), mpi_errno);
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
- return mpi_errno;
- }
- }
- else
- {
- *num_written = num_written_local;
- }
- MPL_DBG_MSG_D(MPIR_DBG_OTHER,TERSE,"sock_writev %d bytes\n", *num_written);
-
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_WRITEV);
- return MPI_SUCCESS;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_id
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_id(MPIDU_Sock_t sock)
-{
- int ret_val;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
- if (sock == MPIDU_SOCK_INVALID_SOCK)
- ret_val = -1;
- else
- {
- if (sock->type == SOCKI_LISTENER)
- ret_val = (int)sock->listen_sock;
- else
- ret_val = (int)sock->sock;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_ID);
- return ret_val;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_sock_set_id
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_sock_set_id(MPIDU_Sock_set_t set)
-{
- int ret_val;
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
- ret_val = PtrToInt(set);/*(int)set;*/
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_SOCK_SET_ID);
- return ret_val;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIDU_Sock_get_error_class_string
-#undef FCNAME
-#define FCNAME MPL_QUOTE(FUNCNAME)
-int MPIDU_Sock_get_error_class_string(int error, char *error_string, int length)
-{
- MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
-
- MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
- switch (MPIR_ERR_GET_CLASS(error))
- {
- case MPIDU_SOCK_ERR_FAIL:
- MPL_strncpy(error_string, "generic socket failure", length);
- break;
- case MPIDU_SOCK_ERR_INIT:
- MPL_strncpy(error_string, "socket module not initialized", length);
- break;
- case MPIDU_SOCK_ERR_NOMEM:
- MPL_strncpy(error_string, "not enough memory to complete the socket operation", length);
- break;
- case MPIDU_SOCK_ERR_BAD_SET:
- MPL_strncpy(error_string, "invalid socket set", length);
- break;
- case MPIDU_SOCK_ERR_BAD_SOCK:
- MPL_strncpy(error_string, "invalid socket", length);
- break;
- case MPIDU_SOCK_ERR_BAD_HOST:
- MPL_strncpy(error_string, "host description buffer not large enough", length);
- break;
- case MPIDU_SOCK_ERR_BAD_HOSTNAME:
- MPL_strncpy(error_string, "invalid host name", length);
- break;
- case MPIDU_SOCK_ERR_BAD_PORT:
- MPL_strncpy(error_string, "invalid port", length);
- break;
- case MPIDU_SOCK_ERR_BAD_BUF:
- MPL_strncpy(error_string, "invalid buffer", length);
- break;
- case MPIDU_SOCK_ERR_BAD_LEN:
- MPL_strncpy(error_string, "invalid length", length);
- break;
- case MPIDU_SOCK_ERR_SOCK_CLOSED:
- MPL_strncpy(error_string, "socket closed", length);
- break;
- case MPIDU_SOCK_ERR_CONN_CLOSED:
- MPL_strncpy(error_string, "socket connection closed", length);
- break;
- case MPIDU_SOCK_ERR_CONN_FAILED:
- MPL_strncpy(error_string, "socket connection failed", length);
- break;
- case MPIDU_SOCK_ERR_INPROGRESS:
- MPL_strncpy(error_string, "socket operation in progress", length);
- break;
- case MPIDU_SOCK_ERR_TIMEOUT:
- MPL_strncpy(error_string, "socket operation timed out", length);
- break;
- case MPIDU_SOCK_ERR_INTR:
- MPL_strncpy(error_string, "socket operation interrupted", length);
- break;
- case MPIDU_SOCK_ERR_NO_NEW_SOCK:
- MPL_strncpy(error_string, "no new connection available", length);
- break;
- default:
- MPL_snprintf(error_string, length, "unknown socket error %d", error);
- break;
- }
- MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_SOCK_GET_ERROR_CLASS_STRING);
- return MPI_SUCCESS;
-}
-----------------------------------------------------------------------
Summary of changes:
maint/extracterrmsgs | 2 +-
maint/extractstates.in | 4 +-
.../ch3/channels/nemesis/netmod/tcp/tcp_getip.c | 10 +-
.../ch3/channels/nemesis/netmod/tcp/tcp_impl.h | 10 +-
.../ch3/channels/nemesis/netmod/tcp/tcp_init.c | 4 +-
src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h | 2 +-
src/mpid/ch3/channels/sock/include/mpidu_sock.h | 1130 ++++++
.../channels/sock/include}/mpidu_socki.h | 38 +-
src/mpid/ch3/channels/sock/src/Makefile.mk | 5 +
src/mpid/ch3/channels/sock/src/ch3_isend.c | 12 +-
src/mpid/ch3/channels/sock/src/ch3_isendv.c | 12 +-
src/mpid/ch3/channels/sock/src/ch3_istartmsg.c | 6 +-
src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c | 6 +-
src/mpid/ch3/channels/sock/src/ch3_progress.c | 76 +-
src/mpid/ch3/channels/sock/src/errnames.txt | 86 +
src/mpid/ch3/channels/sock/src/sock.c | 4187 ++++++++++++++++++++
src/mpid/ch3/channels/sock/subconfigure.m4 | 129 +-
src/mpid/ch3/util/sock/ch3u_connect_sock.c | 68 +-
src/mpid/ch3/util/sock/ch3u_getinterfaces.c | 10 +-
src/mpid/ch3/util/sock/ch3u_init_sock.c | 4 +-
src/mpid/ch3/util/sock/ch3usock.h | 12 +-
src/mpid/ch3/util/sock/errnames.txt | 2 +-
src/mpid/common/Makefile.mk | 1 -
src/mpid/common/sock/Makefile.mk | 27 -
src/mpid/common/sock/errnames.txt | 47 -
src/mpid/common/sock/iocp/Makefile.sm | 3 -
src/mpid/common/sock/iocp/mpidu_socki.h | 41 -
src/mpid/common/sock/iocp/sock.c | 2919 --------------
src/mpid/common/sock/mpidu_sock.h | 1130 ------
src/mpid/common/sock/poll/Makefile.mk | 36 -
src/mpid/common/sock/poll/errnames.txt | 43 -
src/mpid/common/sock/poll/sock.c | 220 -
src/mpid/common/sock/poll/sock_immed.i | 701 ----
src/mpid/common/sock/poll/sock_init.i | 60 -
src/mpid/common/sock/poll/sock_misc.i | 344 --
src/mpid/common/sock/poll/sock_post.i | 729 ----
src/mpid/common/sock/poll/sock_set.i | 283 --
src/mpid/common/sock/poll/sock_wait.i | 822 ----
src/mpid/common/sock/poll/socki_util.i | 1059 -----
src/mpid/common/sock/poll/subconfigure.m4 | 138 -
src/mpid/common/sock/subconfigure.m4 | 25 -
41 files changed, 5675 insertions(+), 8768 deletions(-)
create mode 100644 src/mpid/ch3/channels/sock/include/mpidu_sock.h
rename src/mpid/{common/sock/poll => ch3/channels/sock/include}/mpidu_socki.h (56%)
create mode 100644 src/mpid/ch3/channels/sock/src/sock.c
delete mode 100644 src/mpid/common/sock/Makefile.mk
delete mode 100644 src/mpid/common/sock/errnames.txt
delete mode 100644 src/mpid/common/sock/iocp/Makefile.sm
delete mode 100644 src/mpid/common/sock/iocp/mpidu_socki.h
delete mode 100644 src/mpid/common/sock/iocp/sock.c
delete mode 100644 src/mpid/common/sock/mpidu_sock.h
delete mode 100644 src/mpid/common/sock/poll/Makefile.mk
delete mode 100644 src/mpid/common/sock/poll/errnames.txt
delete mode 100644 src/mpid/common/sock/poll/sock.c
delete mode 100644 src/mpid/common/sock/poll/sock_immed.i
delete mode 100644 src/mpid/common/sock/poll/sock_init.i
delete mode 100644 src/mpid/common/sock/poll/sock_misc.i
delete mode 100644 src/mpid/common/sock/poll/sock_post.i
delete mode 100644 src/mpid/common/sock/poll/sock_set.i
delete mode 100644 src/mpid/common/sock/poll/sock_wait.i
delete mode 100644 src/mpid/common/sock/poll/socki_util.i
delete mode 100644 src/mpid/common/sock/poll/subconfigure.m4
delete mode 100644 src/mpid/common/sock/subconfigure.m4
hooks/post-receive
--
MPICH primary repository
More information about the commits
mailing list