Nathanael Premillieu has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/32994 )

Change subject: base: avoid recreating socket at each call to listen()
......................................................................

base: avoid recreating socket at each call to listen()

A new socket was created each time listen() is called,
which is problematic when the bind or listen operation
on it are not successful (mostly because the associated port is
already in use). It can lead gem5 to open too many files and crash
for multicores configurations, a socket being created
for remote GDB for each core. The other way to deal with
this problem would be to close the socket in the case the
function return false. But I find the proposed solution
simpler.

Change-Id: I848955a10c89e1da033bf773c83556a5dc5ef9a2
---
M src/base/socket.cc
1 file changed, 6 insertions(+), 3 deletions(-)



diff --git a/src/base/socket.cc b/src/base/socket.cc
index adf8315..fce54aa 100644
--- a/src/base/socket.cc
+++ b/src/base/socket.cc
@@ -101,9 +101,12 @@
     if (listening)
         panic("Socket already listening!");

-    fd = ::socket(PF_INET, SOCK_STREAM, 0);
-    if (fd < 0)
-        panic("Can't create socket:%s !", strerror(errno));
+    // only create socket if not already created by a previous call
+    if (fd == -1) {
+        fd = ::socket(PF_INET, SOCK_STREAM, 0);
+        if (fd < 0)
+            panic("Can't create socket:%s !", strerror(errno));
+    }

     if (reuse) {
         int i = 1;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32994
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I848955a10c89e1da033bf773c83556a5dc5ef9a2
Gerrit-Change-Number: 32994
Gerrit-PatchSet: 1
Gerrit-Owner: Nathanael Premillieu <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
  • [gem5-dev] Change in gem5/gem5[... Nathanael Premillieu (Gerrit) via gem5-dev

Reply via email to