summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bea5daa)
raw | patch | inline | side by side (parent: bea5daa)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Wed, 12 Jul 2017 14:06:22 +0000 (21:06 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Thu, 13 Jul 2017 15:20:45 +0000 (22:20 +0700) |
Lock initialization should be done before starting pthread which uses them.
src/snmp_agent.c | patch | blob | history |
diff --git a/src/snmp_agent.c b/src/snmp_agent.c
index 0908b4eb8449c920b9686e53b7247b2c1e04ad7a..1ea5cc97233c054ee2706cc966b897345caaeddc 100644 (file)
--- a/src/snmp_agent.c
+++ b/src/snmp_agent.c
if (ret != 0)
return ret;
- /* create a second thread to listen for requests from AgentX*/
- ret = pthread_create(&g_agent->thread, NULL, &snmp_agent_thread_run, NULL);
- if (ret != 0) {
- ERROR(PLUGIN_NAME ": Failed to create a separate thread, err %u", ret);
- return ret;
- }
-
ret = pthread_mutex_init(&g_agent->lock, NULL);
if (ret != 0) {
ERROR(PLUGIN_NAME ": Failed to initialize mutex, err %u", ret);
return ret;
}
+ /* create a second thread to listen for requests from AgentX*/
+ ret = pthread_create(&g_agent->thread, NULL, &snmp_agent_thread_run, NULL);
+ if (ret != 0) {
+ ERROR(PLUGIN_NAME ": Failed to create a separate thread, err %u", ret);
+ return ret;
+ }
+
return 0;
}