summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2014-04-28 21:13:22 +0200
committerDmitry Kozlov <xeb@mail.ru>2014-04-29 09:50:13 +0400
commit6644c1fee5dfe332a8c303bda85effe501f88524 (patch)
tree9487568d032c6f5f511bde155d2800894a09aa28
parent51210024e9a4149b80b2643f153d5f9d8d45e1f5 (diff)
downloadaccel-ppp-6644c1fee5dfe332a8c303bda85effe501f88524.tar.gz
accel-ppp-6644c1fee5dfe332a8c303bda85effe501f88524.zip
Revert "net-snmp: run snmp in "special" thread"
This reverts commit bf5340291badcc631bd855bb924593cd445ecd26. snmp_thread() needs to be run as regular thread to allow Valgrind analysis. Using a different namespace for file desciptors will be done later on using unshare(). Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
-rw-r--r--accel-pppd/extra/net-snmp/agent.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/accel-pppd/extra/net-snmp/agent.c b/accel-pppd/extra/net-snmp/agent.c
index 2acc6d7..cfeb763 100644
--- a/accel-pppd/extra/net-snmp/agent.c
+++ b/accel-pppd/extra/net-snmp/agent.c
@@ -1,6 +1,5 @@
#include <pthread.h>
#include <signal.h>
-#include <sys/wait.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
@@ -27,8 +26,8 @@ static int conf_master = 0;
static oid* oid_prefix;
static size_t oid_prefix_size;*/
+static pthread_t snmp_thr;
static int snmp_term = 0;
-static int snmp_pid;
/*int accel_ppp_alloc_oid(oid tail, size_t size, oid **oid)
{
@@ -71,7 +70,7 @@ static int agent_log(int major, int minor, void *serv_arg, void *cl_arg)
return 0;
}
-static int snmp_thread(void *a)
+static void *snmp_thread(void *a)
{
sigset_t set;
@@ -108,22 +107,22 @@ static int snmp_thread(void *a)
if (conf_master)
init_master_agent();
- while (!snmp_term)
+ while (!snmp_term) {
agent_check_and_process(1);
+ }
snmp_shutdown(conf_agent_name);
SOCK_CLEANUP;
- return 0;
+ return NULL;
}
static void snmp_ctx_close(struct triton_context_t *ctx)
{
- int status;
snmp_term = 1;
- kill(snmp_pid, 32);
- waitpid(snmp_pid, &status, 0);
+ pthread_cancel(snmp_thr);
+ pthread_join(snmp_thr, NULL);
triton_context_unregister(ctx);
}
@@ -147,8 +146,7 @@ static void init(void)
if (opt)
conf_oid_prefix = opt;*/
- snmp_pid = clone(snmp_thread, malloc(1024*1024) + 1024*1024, CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_THREAD, NULL);
-
+ pthread_create(&snmp_thr, NULL, snmp_thread, NULL);
triton_context_register(&ctx, NULL);
triton_context_wakeup(&ctx);
triton_collect_cpu_usage();