Is there a file descriptor leak when using sockets on a linux platform?
Solution 1
If those sockets are all in the TIME_WAIT state, this is normal, at least for a little while. Check that with netstat; it is common for sockets to hang around for a few minutes to ensure that straggling data from the socket is successfully thrown away before reusing the port for a new socket.
Solution 2
You may also want to check /proc/<pid>/fd
, the directory will contain all of your currently opened file descriptors. If a file disappears after you closed the socket you will not run into any problems (at least not with your file descriptors :).
Solution 3
I think it's not your program's problem.
In SUN_Java, when socket related native lib loaded, A MAGIC_SOCK fd will be created.
write on the MAGIC_SOCK will resulted a Connect Rest Exception, and read on the MAGIC_SOCK will resulted a EOF.
the magic_sock's peer has been fully closed, and the magic_sock itself is half_closed, and the state will remain "can't identify protocol".
ebk
Updated on June 24, 2022Comments
-
ebk almost 2 years
When I click on a user in the first list, I want to get all the buildings in the other list that is connected to that user. I am able to get the user id when i click on the user, but I'm having a hard time figuring out how to get that id to the other vue app and to show all buildings depending on the user id.
My HTML file:
<div id="userApp"> <ul class="collection"> <a href="#!" class=" collection-item avatar" v-for="user in users" v-bind:class="" v-on:click="toggleClicked(user)"> <!-- v-bind:class="active: isActive" --> <i class="material-icons circle">folder</i> <span class="name"><strong>{{ user.firstName + " " + user.lastName }}</strong></span> <p> {{ user.phone }} </p> <p> {{ user.email }} </p> <a href="#!" class="secondary-content"></a> </a> </ul> </div> <div id="buildingApp"> <ul class="collection"> <a href="#!" class=" collection-item avatar" v-for="Building in buildings" v-bind:class="" v-on:click="toggleClicked(Building)"> <!-- v-bind:class="active: isActive" --> <i class="material-icons circle">folder</i> <span class="name"><strong>{{ Building.buildingName }}</strong></span> <p> {{ Building.address }} </p> <p>Byggeår: {{ Building.buildingYear }} </p> <a href="#!" class="secondary-content"></a> </a> </ul> </div>
My js file:
new Vue({ el: '#userApp', data: { users: [], newUser: { firstName: '', lastName: '', address: '', phone: '', email: '', password: '', isActive: false, } }, mounted: function() { this.$http.get('/user').then(function(response){ this.users = response.body; }); }, methods: { toggleClicked: function (user) { var changedData = { id: user.id, firstName: user.firstName, lastName: user.lastName, address: user.address, phone: user.phone, email: user.email, password: user.password, isActive: !user.isActive } this.$http.put('/user/' + user.id, changedData).then(function() { user.isActive = !user.isActive; }); }, } }) new Vue({ el: '#buildingApp', data: { buildings: [], newBuilding: { buildingName: '', address: '', buildingYear: '' } }, mounted: function() { this.$http.get('/building/').then(function(response){ this.buildings = response.body; }); }, });
-
Roy J about 7 yearsIs there a compelling reason not to make each of these apps a component and make an app that contains both?
-
ebk about 7 yearsno there's no reason not to make these apps a component. Would that help me show only the elements from the selected element?
-
Roy J about 7 yearsYes: the
selectedUser
should be a data item of the top-level app. It would be passed to thebuilding
component as a prop. Theuser
component would emit an event when a new user is selected, and the top-level app would handle that event by updatingselectedUser
. I'll write this up in more detail as an answer when I have a chance.
-
-
Neil Coffey over 15 yearsAgreed -- this is the first thing to check. And after a few minutes, the sockets should go away, before your program necessarily terminates.
-
Ry4an Brase over 15 yearsThe author states the entries remain until the program closes, though I guess he doesn't specify if that's more than a few minutes.
-
zebeurton over 15 yearsYeah, I saw the "program closes" bit, but wasn't sure.