[Pkg-privacy-commits] [onioncat] 17/340: control commands 'threads' and 'terminate' implemented
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onioncat.
commit c275b0871f475dea83fd23e751b7bf6719667d30
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Mon Feb 11 14:32:57 2008 +0000
control commands 'threads' and 'terminate' implemented
git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@133 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
ocat.h | 3 +++
ocatroute.c | 18 ++++++++++++++++++
ocatthread.c | 12 ++++++++++--
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/ocat.h b/ocat.h
index 4155a6b..eb2add1 100644
--- a/ocat.h
+++ b/ocat.h
@@ -132,6 +132,9 @@ extern char *tun_dev_;
extern uint32_t fhd_key_;
#endif
+extern pthread_mutex_t thread_mutex_;
+extern OcatThread_t *octh_;
+
/* ocatlog.c */
void log_msg(int, const char *, ...);
diff --git a/ocatroute.c b/ocatroute.c
index 0f24bad..f1f0eff 100644
--- a/ocatroute.c
+++ b/ocatroute.c
@@ -800,6 +800,7 @@ void *ocat_controller(void *p)
char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[ONION_NAME_SIZE], timestr[32];
int rlen, i, cfd;
struct tm *tm;
+ OcatThread_t *th;
(void) init_ocat_thread(p);
@@ -874,6 +875,23 @@ void *ocat_controller(void *p)
}
pthread_mutex_unlock(&peer_mutex_);
}
+ else if (!strncmp(buf, "threads", 7))
+ {
+ pthread_mutex_lock(&thread_mutex_);
+ for (th = octh_; th; th = th->next)
+ {
+ sprintf(buf, "%2d: %s\n", th->id, th->name);
+ if (write(fd, buf, strlen(buf)) != strlen(buf))
+ log_msg(L_ERROR, "couldn't write %d bytes to control socket %d", strlen(buf), fd);
+ }
+ pthread_mutex_unlock(&thread_mutex_);
+ }
+ else if (!strncmp(buf, "terminate", 9))
+ {
+ log_msg(L_NOTICE, "terminate request from control port");
+ //FIXME: fds should be closed properly
+ exit(0);
+ }
else
{
strcpy(buf, "unknown command\n");
diff --git a/ocatthread.c b/ocatthread.c
index 54a5432..11eee0e 100644
--- a/ocatthread.c
+++ b/ocatthread.c
@@ -16,8 +16,8 @@
// global thread id var and mutex for thread initializiation
static int thread_id_ = 0;
-static pthread_mutex_t thread_mutex_ = PTHREAD_MUTEX_INITIALIZER;
-static OcatThread_t *octh_ = NULL;
+pthread_mutex_t thread_mutex_ = PTHREAD_MUTEX_INITIALIZER;
+OcatThread_t *octh_ = NULL;
/*
void init_threads(void)
@@ -48,6 +48,14 @@ const OcatThread_t *init_ocat_thread(const char *name)
}
+
+void *thread_run(void *p)
+{
+ (void) init_ocat_thread(p);
+ return NULL;
+}
+
+
int run_ocat_thread(const char *name, void *(*thfunc)(void*))
{
int rc;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list