File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 5050import com .oracle .graal .python .builtins .objects .PNone ;
5151import com .oracle .graal .python .builtins .objects .object .PythonBuiltinObject ;
5252import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
53+ import com .oracle .truffle .api .CompilerDirectives ;
54+ import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
5355import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
5456
5557public class PSocket extends PythonBuiltinObject implements Channel {
@@ -81,7 +83,14 @@ public class PSocket extends PythonBuiltinObject implements Channel {
8183
8284 public static final int IPPROTO_TCP = 6 ;
8385
84- private static final InetSocketAddress EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
86+ @ CompilationFinal private static InetSocketAddress EPHEMERAL_ADDRESS ;
87+ private static InetSocketAddress getEphemeralAddress () {
88+ if (EPHEMERAL_ADDRESS == null ) {
89+ CompilerDirectives .transferToInterpreterAndInvalidate ();
90+ EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
91+ }
92+ return EPHEMERAL_ADDRESS ;
93+ }
8594
8695 private final int family ;
8796 private final int type ;
@@ -94,7 +103,7 @@ public class PSocket extends PythonBuiltinObject implements Channel {
94103
95104 private double timeout ;
96105
97- private InetSocketAddress address = EPHEMERAL_ADDRESS ;
106+ private InetSocketAddress address = getEphemeralAddress () ;
98107
99108 private SocketChannel socket ;
100109
You can’t perform that action at this time.
0 commit comments