Vladimir Akkerman
unread,Sep 6, 2017, 2:46:57 AM9/6/17You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I write multithread program, how should I use snmp_async_send? Here is code of every thread. Session is created and destroyed every time thread is running.
struct snmp_session session; //separated in every thread
struct snmp_session *sess_handle;
struct snmp_pdu *pdu;
struct snmp_pdu *response;
oid id_oid[MAX_OID_LEN];
oid serial_oid[MAX_OID_LEN];
size_t id_len = MAX_OID_LEN;
size_t serial_len = MAX_OID_LEN;
struct variable_list *vars;
int status;
snmp_sess_init(&session);
session.peername=this->ip;
session.version=SNMP_VERSION_1;
session.community="public";
session.community_len=strlen(session.community);
sess_handle=snmp_open(&session);
pdu=snmp_pdu_create(SNMP_MSG_GET);
read_objid(oid1, id_oid, &id_len);
snmp_add_null_var(pdu, id_oid, id_len);
read_objid(oid2, id_oid, &id_len);
snmp_add_null_var(pdu, id_oid, id_len);
/* next code gives an error Segmentatio Fault, cause snmp_sync_response should not be used in multithreading code. Help me with snmp_async_send
*/
status=snmp_synch_response(sess_handle, pdu, &response);