I'll answer my on question:
The problem was
rc = close(t->sock);
because on my platform file descriptors are INT32* and socket descriptors are
INT32
I had remapped close() to the function that closes files, which is obviously
different from the one that closes sockets.
Therefore sockets were opened and never closed.
I fixed it and everything works now.
MF
From: Moreno Floris
Sent: giovedì 19 gennaio 2017 10:55
To: net-snmp-coders@lists.sourceforge.net
Subject: How do I eliminate sessions?
Hello,
I tried to run the code at
http://net-snmp.sourceforge.net/wiki/index.php/TUT:Simple_Application
repeatedly inside a function, as well as the main() of snmpget.c also as a
function call.
The problem is that it keeps opening sessions and never closes them.
The following call in snmp_client.c inside snmp_synch_response_cb()
count = select(numfds, &fdset, NULL, NULL, tvp);
crashes after a number of iterations because "numfds" keeps growing. It keeps
growing because of
*numfds = (slp->transport->sock + 1);
inside snmp_sess_select_info2_flags() in snmp_api.c
I can't have as many sockets as I like in my platform, therefore it only works
up to a point then crashes.
It looks like the global variable
struct session_list *Sessions = NULL; /* MT_LIB_SESSION */
is filled but never emptied. How do I do that?
After six calls:
((*((*(Sessions)).session)).sessid) = 6
((*((*(Sessions)).transport)).sock) = 5
I don't want N sessions and N sockets. I want to destroy the session as soon as
I'm done with it and create a new one again on the second call.
Thank you very much for your support
MF
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders