summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-03-01 01:28:13 +0000
committerjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-03-01 01:28:13 +0000
commita5a4c84e35aa8c0b2b24c15df825adfd3d1434a1 (patch)
tree8f8c65afee2cbe8c0d2a6a049cb58077f17975c2 /apps
parentd89a1bf67b55c4291d550cd6b2fc9227e1d90250 (diff)
downloadATCD-a5a4c84e35aa8c0b2b24c15df825adfd3d1434a1.tar.gz
Added code to make it thread-per request.
Changed HTTP_Server::init(), HTTP_Handler::open().
Diffstat (limited to 'apps')
-rw-r--r--apps/JAWS/HTTP_Handler.cpp28
-rw-r--r--apps/JAWS/HTTP_Handler.h5
-rw-r--r--apps/JAWS/HTTP_Server.cpp32
-rw-r--r--apps/JAWS/HTTP_Server.h1
4 files changed, 53 insertions, 13 deletions
diff --git a/apps/JAWS/HTTP_Handler.cpp b/apps/JAWS/HTTP_Handler.cpp
index ac671a7b73e..39718b7dd19 100644
--- a/apps/JAWS/HTTP_Handler.cpp
+++ b/apps/JAWS/HTTP_Handler.cpp
@@ -2,17 +2,35 @@
#include "HTTP_Handler.h"
-HTTP_Handler::HTTP_Handler(void)
+HTTP_Handler::HTTP_Handler(int strategy)
{
- sockbufp_ = sockbuf_;
- sockbufn_ = 0;
+ this->sockbufp_ = this->sockbuf_;
+ this->sockbufn_ = 0;
+ this->strategy_ = strategy;
}
int
HTTP_Handler::open (void *)
{
- this->svc();
- this->close();
+ if (this->strategy_ == 1) {
+ // Thread-per-request
+
+ switch (this->activate()) {
+ case -1: /* failed to make object active */
+ ACE_ERROR_RETURN((LM_ERROR, "%p\n", "HTTP_Handler::open"), -1);
+ break;
+ case 1: /* already active */
+ ACE_ERROR_RETURN((LM_ERROR, "%p\n", "HTTP_Handler::open"), 1);
+ break;
+ default: /* ok */
+ ;
+ }
+ }
+ else {
+ this->svc();
+ this->close();
+ }
+
return 0;
}
diff --git a/apps/JAWS/HTTP_Handler.h b/apps/JAWS/HTTP_Handler.h
index 27870245668..1a41b2a1f4d 100644
--- a/apps/JAWS/HTTP_Handler.h
+++ b/apps/JAWS/HTTP_Handler.h
@@ -13,7 +13,7 @@ class HTTP_Handler
{
public:
- HTTP_Handler(void);
+ HTTP_Handler(int strategy = 2);
virtual int open (void *);
virtual int svc (void);
@@ -38,6 +38,9 @@ private:
int sockputs(char const *s);
private:
+ int strategy_;
+
+private:
// New HTTP parsing stuff.
enum {METHODSIZ = 10, VERSIONSIZ = 10};
diff --git a/apps/JAWS/HTTP_Server.cpp b/apps/JAWS/HTTP_Server.cpp
index 1211c1a0cd2..2e2df519924 100644
--- a/apps/JAWS/HTTP_Server.cpp
+++ b/apps/JAWS/HTTP_Server.cpp
@@ -25,7 +25,7 @@ HTTP_Server::init (int argc, char *argv[])
this->port_ = 0;
this->threads_ = 0;
- ACE_Get_Opt get_opt(argc, argv, "p:n:");
+ ACE_Get_Opt get_opt(argc, argv, "p:n:s:");
while ((c = get_opt()) != -1)
switch (c) {
case 'p':
@@ -34,6 +34,12 @@ HTTP_Server::init (int argc, char *argv[])
case 'n':
this->threads_ = ACE_OS::atoi(get_opt.optarg);
break;
+ case 's':
+ this->strategy_ = ACE_OS::atoi(get_opt.optarg);
+ // 0 -> single threaded concurrent synchronous (not implemented)
+ // 1 -> thread per request
+ // 2 -> thread pool
+ break;
default:
break;
}
@@ -47,14 +53,27 @@ HTTP_Server::init (int argc, char *argv[])
this->acceptor_.open(ACE_INET_Addr(this->port_));
- for (int i = 0; i < this->threads_; i++) {
- HTTP_Task *t = new HTTP_Task(this->acceptor_, this->tm_);
- if (t->open() != 0) {
- ACE_DEBUG ((LM_DEBUG, "in HTTP_Server::init, open failed\n"));
+ switch(this->strategy_) {
+ case 1: // thread per request
+ for (;;) {
+ this->acceptor_.accept(new HTTP_Handler(1));
+ }
+
+ break;
+
+ case 0: // single threaded concurrent (not implemented)
+ default:
+
+ for (int i = 0; i < this->threads_; i++) {
+ HTTP_Task *t = new HTTP_Task(this->acceptor_, this->tm_);
+ if (t->open(0) != 0) {
+ ACE_DEBUG ((LM_DEBUG, "in HTTP_Server::init, open failed\n"));
+ }
}
+
+ this->tm_.wait();
}
- this->tm_.wait();
return 0;
}
@@ -99,7 +118,6 @@ HTTP_Task::svc (void)
// ACE_Thread::self()));
}
- // NOT REACHED
return 0;
}
diff --git a/apps/JAWS/HTTP_Server.h b/apps/JAWS/HTTP_Server.h
index 72cdd433910..45bbd002a1b 100644
--- a/apps/JAWS/HTTP_Server.h
+++ b/apps/JAWS/HTTP_Server.h
@@ -47,6 +47,7 @@ public:
private:
int port_;
int threads_;
+ int strategy_;
ACE_Thread_Manager tm_;
HTTP_Acceptor acceptor_;
};