File tree Expand file tree Collapse file tree 1 file changed +12
-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 +12
-2
lines changed Original file line number Diff line number Diff line change 50
50
import com .oracle .graal .python .builtins .objects .PNone ;
51
51
import com .oracle .graal .python .builtins .objects .object .PythonBuiltinObject ;
52
52
import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
53
+ import com .oracle .truffle .api .CompilerDirectives ;
54
+ import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
53
55
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
54
56
55
57
public class PSocket extends PythonBuiltinObject implements Channel {
@@ -81,7 +83,15 @@ public class PSocket extends PythonBuiltinObject implements Channel {
81
83
82
84
public static final int IPPROTO_TCP = 6 ;
83
85
84
- private static final InetSocketAddress EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
86
+ @ CompilationFinal private static InetSocketAddress EPHEMERAL_ADDRESS ;
87
+
88
+ private static InetSocketAddress getEphemeralAddress () {
89
+ if (EPHEMERAL_ADDRESS == null ) {
90
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
91
+ EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
92
+ }
93
+ return EPHEMERAL_ADDRESS ;
94
+ }
85
95
86
96
private final int family ;
87
97
private final int type ;
@@ -94,7 +104,7 @@ public class PSocket extends PythonBuiltinObject implements Channel {
94
104
95
105
private double timeout ;
96
106
97
- private InetSocketAddress address = EPHEMERAL_ADDRESS ;
107
+ private InetSocketAddress address = getEphemeralAddress () ;
98
108
99
109
private SocketChannel socket ;
100
110
You can’t perform that action at this time.
0 commit comments