diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-24 21:06:04 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-24 21:06:04 +0000 |
commit | 8302046cb84ddcc9fff9a706804985845b4c25ad (patch) | |
tree | 513e2411c10e6ba0c44fa5070d7800d7d2174631 /apps | |
parent | 733d47afb1e96c07844f0241606ddc5d2b5a9abf (diff) | |
download | ATCD-8302046cb84ddcc9fff9a706804985845b4c25ad.tar.gz |
Fixes related to Purify errors.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/JAWS/server/HTTP_Response.cpp | 2 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Server.cpp | 29 | ||||
-rw-r--r-- | apps/JAWS/server/Parse_Headers.cpp | 33 | ||||
-rw-r--r-- | apps/JAWS/server/main.cpp | 6 | ||||
-rw-r--r-- | apps/JAWS/server/svc.conf | 19 |
5 files changed, 64 insertions, 25 deletions
diff --git a/apps/JAWS/server/HTTP_Response.cpp b/apps/JAWS/server/HTTP_Response.cpp index 233a52ba285..c3d2d1e6bab 100644 --- a/apps/JAWS/server/HTTP_Response.cpp +++ b/apps/JAWS/server/HTTP_Response.cpp @@ -320,7 +320,7 @@ HTTP_Response::build_headers (void) } else { - HTTP_HEADER = new char[BUFSIZ * 4]; + // HTTP_HEADER = new char[BUFSIZ * 4]; // We assume that at this point everything is OK if (! this->request_.cgi ()) diff --git a/apps/JAWS/server/HTTP_Server.cpp b/apps/JAWS/server/HTTP_Server.cpp index 9e8d989f7f3..4f1cc3353e3 100644 --- a/apps/JAWS/server/HTTP_Server.cpp +++ b/apps/JAWS/server/HTTP_Server.cpp @@ -10,6 +10,8 @@ //DONE// James, please make sure that you don't have "free floating" //DONE// enums since they will inevitably cause portability problems. +static int JAWS_THREAD_FLAGS = 0; + class HTTP_Server_Anchor { public: @@ -71,14 +73,15 @@ HTTP_Server::parse_args (int argc, break; case 'f': if (ACE_OS::strcmp (get_opt.optarg, "THR_BOUND") == 0) - { - } + JAWS_THREAD_FLAGS ^= THR_BOUND; else if (ACE_OS::strcmp (get_opt.optarg, "THR_DAEMON") == 0) - { - } + JAWS_THREAD_FLAGS ^= THR_DAEMON; else if (ACE_OS::strcmp (get_opt.optarg, "THR_DETACHED") == 0) - { - } + JAWS_THREAD_FLAGS ^= THR_DETACHED; + else if (ACE_OS::strcmp (get_opt.optarg, "THR_NEW_LWP") == 0) + JAWS_THREAD_FLAGS ^= THR_NEW_LWP; + + break; case 'i': // SYNCH -> synchronous I/O // ASYNCH -> asynchronous I/O @@ -174,7 +177,7 @@ Synch_Thread_Pool_Task::open (void *args) { ACE_UNUSED_ARG (args); - if (this->activate (THR_DETACHED | THR_NEW_LWP) == -1) + if (this->activate (JAWS_THREAD_FLAGS) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Synch_Thread_Pool_Task::open"), -1); @@ -238,7 +241,6 @@ HTTP_Server::thread_per_request (void) this->tm_), -1); - if (t->open (&grp_id) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Per_Request_Task::open"), @@ -252,6 +254,7 @@ HTTP_Server::thread_per_request (void) // This works because each task has only one thread. while (this->tm_.num_tasks_in_group (grp_id) > this->threads_) this->tm_.wait (&wait_time); + } // This stinks, because I am afraid that if I remove this line, some @@ -274,6 +277,7 @@ Thread_Per_Request_Task::Thread_Per_Request_Task (ACE_HANDLE handle, int Thread_Per_Request_Task::open (void *args) { + return this->svc (); int status = -1; int *grp_id = &status; @@ -281,9 +285,9 @@ Thread_Per_Request_Task::open (void *args) grp_id = (int *) args; if (*grp_id == -1) - status = *grp_id = this->activate (THR_DETACHED | THR_NEW_LWP); + status = *grp_id = this->activate (JAWS_THREAD_FLAGS); else - status = this->activate (THR_DETACHED | THR_NEW_LWP, 1, 0, -1, *grp_id, 0); + status = this->activate (JAWS_THREAD_FLAGS, 1, 0, -1, *grp_id, 0); if (status == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Per_Request_Task::open"), @@ -309,7 +313,8 @@ Thread_Per_Request_Task::close (u_long) { ACE_DEBUG ((LM_DEBUG, " (%t) Thread_Per_Request_Task::svc, dying\n")); - delete this; + // delete this; + // ACE_OS::thr_exit (); return 0; } @@ -378,7 +383,7 @@ Asynch_Thread_Pool_Task::Asynch_Thread_Pool_Task (ACE_Proactor &proactor, int Asynch_Thread_Pool_Task::open (void *args) { - if (this->activate () == -1) + if (this->activate (JAWS_THREAD_FLAGS) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Asynch_Thread_Pool_Task::open"), -1); diff --git a/apps/JAWS/server/Parse_Headers.cpp b/apps/JAWS/server/Parse_Headers.cpp index aed3923faf6..151db0f97f4 100644 --- a/apps/JAWS/server/Parse_Headers.cpp +++ b/apps/JAWS/server/Parse_Headers.cpp @@ -183,7 +183,7 @@ Headers_Map::Map_Item::operator const char * (void) const Headers_Map::Map_Item & Headers_Map::Map_Item::operator= (char * value) { - ACE_OS::free ((void *)this->value_); + ACE_OS::free ((void *) this->value_); this->value_ = ACE_OS::strdup (value); return *this; } @@ -191,7 +191,7 @@ Headers_Map::Map_Item::operator= (char * value) Headers_Map::Map_Item & Headers_Map::Map_Item::operator= (const char * value) { - ACE_OS::free ((void *)this->value_); + ACE_OS::free ((void *) this->value_); this->value_ = ACE_OS::strdup (value); return *this; } @@ -199,7 +199,7 @@ Headers_Map::Map_Item::operator= (const char * value) Headers_Map::Map_Item & Headers_Map::Map_Item::operator= (const Headers_Map::Map_Item & mi) { - ACE_OS::free ((void *)this->value_); + ACE_OS::free ((void *) this->value_); this->value_ = ACE_OS::strdup (mi.value_); return *this; } @@ -257,13 +257,26 @@ Headers_Map::find (const char * const header) const Headers_Map::Map_Item * Headers_Map::place (const char *const header) { + ACE_OS::free ((void *) this->map_[this->num_headers_++].header_); this->map_[this->num_headers_++].header_ = ACE_OS::strdup(header); - ::qsort (this->map_, - this->num_headers_, - sizeof (Headers_Map::Map_Item), - Headers_Map::compare); - return this->find (header); + int i = this->num_headers_-1; + Headers_Map::Map_Item temp_item; + + while (i > 0) + { + if (Headers_Map::compare (&(this->map_[i]), &(this->map_[i-1])) > 0) + break; + ACE_OS::memcpy (temp_item, this->map_[i-1], + sizeof (Headers_Map::Map_Item)); + ACE_OS::memcpy (this->map_[i-1], this->map_[i], + sizeof (Headers_Map::Map_Item)); + ACE_OS::memcpy (this->map_[i], temp_item, + sizeof (Headers_Map::Map_Item)); + i--; + } + + return &(this->map_[i]); } int @@ -275,6 +288,6 @@ Headers_Map::compare (const void *item1, a = (Headers_Map::Map_Item *) item1; b = (Headers_Map::Map_Item *) item2; - return ACE_OS::strcasecmp (a->header_, - b->header_); + return ACE_OS::strcasecmp (a->header_ ? a->header_ : "", + b->header_ ? a->header_ : ""); } diff --git a/apps/JAWS/server/main.cpp b/apps/JAWS/server/main.cpp index 6929ecbe35a..505c92026d7 100644 --- a/apps/JAWS/server/main.cpp +++ b/apps/JAWS/server/main.cpp @@ -8,10 +8,14 @@ ACE_STATIC_SVC_REQUIRE(HTTP_Server) extern "C" { - // call exit() so that static destructors get called static void handler (int) { + // reap any threads which have been orphaned. + while (ACE_OS::thr_join (0, 0, 0) ==0) + ; + + // call exit() so that static destructors get called ACE_OS::exit (0); } diff --git a/apps/JAWS/server/svc.conf b/apps/JAWS/server/svc.conf index 267ea1a4b6d..5d1e0d0dec6 100644 --- a/apps/JAWS/server/svc.conf +++ b/apps/JAWS/server/svc.conf @@ -1,6 +1,11 @@ # # -p port number # -n threads in the server +# -f thread activation flags +# = THR_BOUND +# = THR_DAEMON +# = THR_DETACHED +# = THR_NEW_LWP # -t threading strategy # = POOL -> thread pool # = PER_REQUEST -> thread per request @@ -10,6 +15,18 @@ # = ASYNCH # -b backlog value for listen () # -static HTTP_Server "HTTP_Server -p 5432 -n 40 -t POOL -b 50" +# +# Thread Pool, 40 threads +#static HTTP_Server "HTTP_Server -p 5432 -n 40 -i SYNCH -t POOL -b 50 -f THR_NEW_LWP -f THR_BOUND" +# +# +# Thread-per-request, unlimited number of threads +static HTTP_Server "HTTP_Server -p 5432 -i SYNCH -t PER_REQUEST -b 50 -f THR_NEW_LWP" +# +# +# Throttling, 40 threads +#static HTTP_Server "HTTP_Server -p 5432 -n 40 -i SYNCH -t THROTTLE -b 50 -f THR_NEW_LWP" +# +# #dynamic HTTP_Server Service_Object * .shobj/HTTP_Server:jaws "HTTP_Server -p 5432 -s HTTP_Service" |