Skip to content

Commit 46549d7

Browse files
committed
Pulled up the context field from EmulatedPosixSupport to PosixResources
1 parent bb663cf commit 46549d7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Object socket(VirtualFrame frame, Object cls, Object family, Object type, Object
285285
private Object createSocketInternal(Object cls, int family, int type, int proto) {
286286
if (getContext().getEnv().isNativeAccessAllowed()) {
287287
PSocket newSocket = factory().createSocket(cls, family, type, proto);
288-
int fd = getContext().getResources().openSocket(newSocket, getContext());
288+
int fd = getContext().getResources().openSocket(newSocket);
289289
newSocket.setFileno(fd);
290290
return newSocket;
291291
} else {
@@ -680,7 +680,7 @@ Object close(VirtualFrame frame, int fd) {
680680
} catch (IOException e) {
681681
throw raiseOSError(frame, OSErrorEnum.EBADF);
682682
}
683-
getContext().getResources().closeSocket(socket, getContext());
683+
getContext().getResources().closeSocket(socket);
684684
return PNone.NONE;
685685
}
686686

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Object accept(PSocket socket) {
137137
throw raise(OSError);
138138
}
139139
PSocket newSocket = factory().createSocket(socket.getFamily(), socket.getType(), socket.getProto());
140-
int fd = getContext().getResources().openSocket(newSocket, getContext());
140+
int fd = getContext().getResources().openSocket(newSocket);
141141
newSocket.setFileno(fd);
142142
newSocket.setSocket(acceptSocket);
143143
SocketUtils.setBlocking(newSocket, socket.isBlocking());
@@ -191,7 +191,7 @@ Object close(PSocket socket) {
191191
throw raise(OSError, ErrorMessages.BAD_FILE_DESCRIPTOR);
192192
}
193193
}
194-
getContext().getResources().closeSocket(socket, getContext());
194+
getContext().getResources().closeSocket(socket);
195195
return PNone.NONE;
196196
}
197197
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,12 @@ public final class EmulatedPosixSupport extends PosixResources {
250250
private static final int S_IFDIR = 0040000;
251251
private static final int S_IFREG = 0100000;
252252

253-
private final PythonContext context;
254253
private final ConcurrentHashMap<String, String> environ = new ConcurrentHashMap<>();
255254
private int currentUmask = 0022;
256255
private boolean hasDefaultUmask = true;
257256

258257
public EmulatedPosixSupport(PythonContext context, boolean useNfiForSocketFd) {
259-
super(useNfiForSocketFd);
260-
this.context = context;
258+
super(context, useNfiForSocketFd);
261259
setEnv(context.getEnv());
262260
}
263261

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixResources.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ public class PosixResources extends PosixSupport {
7878
private static final int FD_STDERR = 2;
7979

8080
/** Context-local file-descriptor mappings and PID mappings */
81+
protected final PythonContext context;
8182
private final SortedMap<Integer, ChannelWrapper> files;
8283
protected final Map<Integer, String> filePaths;
8384
private final List<Process> children;
8485
private final Map<String, Integer> inodes;
8586
private int inodeCnt = 0;
86-
private boolean useNfiForSocketFd;
87+
private final boolean useNfiForSocketFd;
8788

8889
private static class ProcessGroup extends Process {
8990
private final List<Process> children;
@@ -187,7 +188,8 @@ void setNewChannel(OutputStream outputStream) {
187188
}
188189
}
189190

190-
public PosixResources(boolean useNfiForSocketFd) {
191+
public PosixResources(PythonContext context, boolean useNfiForSocketFd) {
192+
this.context = context;
191193
files = Collections.synchronizedSortedMap(new TreeMap<>());
192194
filePaths = Collections.synchronizedMap(new HashMap<>());
193195
children = Collections.synchronizedList(new ArrayList<>());
@@ -341,7 +343,7 @@ public void close(int fd) {
341343
private int nativeFdForSockets = -1;
342344

343345
@TruffleBoundary
344-
public int openSocket(PSocket socket, PythonContext context) {
346+
public int openSocket(PSocket socket) {
345347
synchronized (files) {
346348
int fd;
347349
if (!useNfiForSocketFd) {
@@ -369,7 +371,7 @@ public int openSocket(PSocket socket, PythonContext context) {
369371
}
370372

371373
@TruffleBoundary
372-
public void closeSocket(PSocket socket, PythonContext context) {
374+
public void closeSocket(PSocket socket) {
373375
int fd = socket.getFileno();
374376
if (fd < 0) {
375377
return;

0 commit comments

Comments
 (0)