@@ -743,31 +743,9 @@ static void* listen_thread(opal_object_t *obj)
743
743
(struct sockaddr * )& (pending_connection -> addr ),
744
744
& addrlen );
745
745
746
- /* if we are on a privileged port, we only accept connections
747
- * from other privileged sockets. A privileged port is one
748
- * whose port is less than 1024 on Linux, so we'll check for that. */
749
- if (1024 >= listener -> port ) {
750
- uint16_t inport ;
751
- if (listener -> tcp6 ) {
752
- inport = ntohs (((struct sockaddr_in6 * )& pending_connection -> addr )-> sin6_port );
753
- } else {
754
- inport = ntohs (((struct sockaddr_in * )& pending_connection -> addr )-> sin_port );
755
- }
756
- if (1024 < inport ) {
757
- /* someone tried to cross-connect privileges,
758
- * say something */
759
- orte_show_help ("help-oob-tcp.txt" ,
760
- "privilege failure" ,
761
- true, opal_process_info .nodename ,
762
- listener -> port , inport );
763
- CLOSE_THE_SOCKET (pending_connection -> fd );
764
- OBJ_RELEASE (pending_connection );
765
- continue ;
766
- }
767
- }
768
746
/* check for < 0 as indicating an error upon accept */
769
747
if (pending_connection -> fd < 0 ) {
770
- OBJ_RELEASE (pending_connection ); // this closes the incoming fd
748
+ OBJ_RELEASE (pending_connection );
771
749
772
750
/* Non-fatal errors */
773
751
if (EAGAIN == opal_socket_errno ||
@@ -806,12 +784,33 @@ static void* listen_thread(opal_object_t *obj)
806
784
}
807
785
808
786
opal_output_verbose (OOB_TCP_DEBUG_CONNECT , orte_oob_base_framework .framework_output ,
809
- "%s mca_oob_tcp_listen_thread: new connection: "
787
+ "%s mca_oob_tcp_listen_thread: incoming connection: "
810
788
"(%d, %d) %s:%d\n" ,
811
789
ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ),
812
790
pending_connection -> fd , opal_socket_errno ,
813
791
opal_net_get_hostname ((struct sockaddr * ) & pending_connection -> addr ),
814
792
opal_net_get_port ((struct sockaddr * ) & pending_connection -> addr ));
793
+
794
+ /* if we are on a privileged port, we only accept connections
795
+ * from other privileged sockets. A privileged port is one
796
+ * whose port is less than 1024 on Linux, so we'll check for that. */
797
+ if (1024 >= listener -> port ) {
798
+ uint16_t inport ;
799
+ inport = opal_net_get_port ((struct sockaddr * ) & pending_connection -> addr );
800
+ if (1024 < inport ) {
801
+ /* someone tried to cross-connect privileges,
802
+ * say something */
803
+ orte_show_help ("help-oob-tcp.txt" ,
804
+ "privilege failure" , true,
805
+ opal_process_info .nodename , listener -> port ,
806
+ opal_net_get_hostname ((struct sockaddr * ) & pending_connection -> addr ),
807
+ inport );
808
+ CLOSE_THE_SOCKET (pending_connection -> fd );
809
+ OBJ_RELEASE (pending_connection );
810
+ continue ;
811
+ }
812
+ }
813
+
815
814
/* activate the event */
816
815
opal_event_active (& pending_connection -> ev , OPAL_EV_WRITE , 1 );
817
816
accepted_connections ++ ;
0 commit comments