diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2008-06-16 20:26:16 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2008-06-16 20:26:16 +0000 |
commit | cc7c6f16011d2ce569363573be80d92c9e245ada (patch) | |
tree | ea680052c264debca54f5156163d70dbc642b100 /ACE/apps/JAWS | |
parent | f1c997dc84b91b1f3eec3927fa275483e117e3e2 (diff) | |
download | ATCD-cc7c6f16011d2ce569363573be80d92c9e245ada.tar.gz |
Mon Jun 16 20:24:45 UTC 2008 Abdullah Sowayan <abdullah.sowayan@lmco.com>
Diffstat (limited to 'ACE/apps/JAWS')
20 files changed, 636 insertions, 640 deletions
diff --git a/ACE/apps/JAWS/clients/Blobby/Options.cpp b/ACE/apps/JAWS/clients/Blobby/Options.cpp index 08f7de4ad8b..cff24935e4e 100644 --- a/ACE/apps/JAWS/clients/Blobby/Options.cpp +++ b/ACE/apps/JAWS/clients/Blobby/Options.cpp @@ -14,7 +14,7 @@ Options * Options::instance (void) { - if (Options::instance_ == 0) + if (Options::instance_ == 0) Options::instance_ = new Options; return Options::instance_; @@ -61,15 +61,16 @@ Options::parse_args (int argc, ACE_TCHAR *argv[]) } if (this->hostname_ == 0 || this->filename_ == 0) { - ACE_DEBUG ((LM_DEBUG, - "%s -h hostname -f filename -[r/w] [-p port] [-l length] [-o offset] [-d]\n", - argv[0])); + ACE_DEBUG ((LM_DEBUG, + "%s -h hostname -f filename -[r/w] [-p port] [-l length] [-o offset] [-d]\n", + argv[0])); + ACE_OS::exit (1); } } -Options::Options (void) +Options::Options (void) : hostname_ (0), port_ (ACE_DEFAULT_HTTP_SERVER_PORT), filename_ (0), diff --git a/ACE/apps/JAWS/clients/Blobby/blobby.cpp b/ACE/apps/JAWS/clients/Blobby/blobby.cpp index e614b049c20..4d6f5802f56 100644 --- a/ACE/apps/JAWS/clients/Blobby/blobby.cpp +++ b/ACE/apps/JAWS/clients/Blobby/blobby.cpp @@ -39,14 +39,14 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) // Explain what is going to happen if (options->debug_) ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("hostname = %C, port = %d, filename = %s, ") + ACE_TEXT ("hostname = %C, port = %d, filename = %s, ") ACE_TEXT ("length = %d, offset = %d, operation = %c\n"), - options->hostname_, - options->port_, - options->filename_, - options->length_, - options->offset_, - options->operation_)); + options->hostname_, + options->port_, + options->filename_, + options->length_, + options->offset_, + options->operation_)); // Create a blob ACE_Blob blob; diff --git a/ACE/apps/JAWS/clients/Caching/ID_Generator.cpp b/ACE/apps/JAWS/clients/Caching/ID_Generator.cpp index 6e868611835..c2bde44f71c 100644 --- a/ACE/apps/JAWS/clients/Caching/ID_Generator.cpp +++ b/ACE/apps/JAWS/clients/Caching/ID_Generator.cpp @@ -22,7 +22,7 @@ ACE_ID_Generator::get_new_id (char *id) ACE_ID_Generator::get_serial_id (t, sn); ACE_NEW_RETURN (id, char [ACE_OFFER_ID_LENGTH], 0); - + ACE_OS::sprintf (id, "%014d%06d", t, sn); return id; } @@ -52,7 +52,7 @@ ACE_ID_Generator::get_lock (void) // Double-checked Locking Optimization. if (ACE_ID_Generator::lock_ == 0) - ACE_NEW_RETURN (ACE_ID_Generator::lock_, ACE_SYNCH_MUTEX, 0); + ACE_NEW_RETURN (ACE_ID_Generator::lock_, ACE_SYNCH_MUTEX, 0); } #endif /* ACE_HAS_THREADS */ return ACE_ID_Generator::lock_; diff --git a/ACE/apps/JAWS/clients/Caching/Local_Locator.cpp b/ACE/apps/JAWS/clients/Caching/Local_Locator.cpp index 2aab4f874d8..1c9df290fbe 100644 --- a/ACE/apps/JAWS/clients/Caching/Local_Locator.cpp +++ b/ACE/apps/JAWS/clients/Caching/Local_Locator.cpp @@ -13,10 +13,10 @@ ACE_RCSID(Caching, Local_Locator, "$Id$") int ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria how, - const ACE_URL_Property_Seq *pseq, - const size_t how_many, - size_t &num_query, - ACE_URL_Offer_Seq *offer) + const ACE_URL_Property_Seq *pseq, + const size_t how_many, + size_t &num_query, + ACE_URL_Offer_Seq *offer) { ACE_URL_Record *item = 0; @@ -41,27 +41,27 @@ ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria // implement this using Hash_Map. Better yet, I think we should // put this in a database and put SQL query here. for (i_query = 0; found == 0 && i_query < pseq->size (); i_query++) - for (i_db = 0; i_db < item->offer_->url_properties ().size (); i_db++) - { - if ((*pseq)[i_query].name () == item->offer_->url_properties ()[i_db].name ()) - if (how == ACE_URL_Locator::SOME) + for (i_db = 0; i_db < item->offer_->url_properties ().size (); i_db++) + { + if ((*pseq)[i_query].name () == item->offer_->url_properties ()[i_db].name ()) + if (how == ACE_URL_Locator::SOME) ; - // if match and Some, copy to <offer>, inc <num_query>, advance iterator + // if match and Some, copy to <offer>, inc <num_query>, advance iterator - // else if All, advance iterator + // else if All, advance iterator - // else if None, check next property in <pseq>. + // else if None, check next property in <pseq>. - if (all properties checked and found and ALL) - copy to <offer>; inc <num_query>; - else if (all properties checked and not found and NONE) - copy to <offer>; inc <num_query>; - else - shouldn't happen, internal error + if (all properties checked and found and ALL) + copy to <offer>; inc <num_query>; + else if (all properties checked and not found and NONE) + copy to <offer>; inc <num_query>; + else + shouldn't happen, internal error if (num_query == how_many) - break; + break; } return 0; @@ -69,7 +69,7 @@ ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria int ACE_URL_Local_Locator::export_offer (ACE_URL_Offer *offer, - ACE_WString &offer_id) + ACE_WString &offer_id) { ACE_URL_Record *item = 0; @@ -79,15 +79,15 @@ ACE_URL_Local_Locator::export_offer (ACE_URL_Offer *offer, iter.advance ()) if (*item->offer_->url () == *offer->url ()) { - errno = ACE_URL_Locator::OFFER_EXIST; - return -1; + errno = ACE_URL_Locator::OFFER_EXIST; + return -1; } ACE_URL_Record *new_offer; // Offer is not in repository, we can add new one in safely. ACE_NEW_RETURN (new_offer, ACE_URL_Record (offer), - ACE_URL_Locator::NOMEM); + ACE_URL_Locator::NOMEM); this->repository_.push (*new_offer); @@ -105,15 +105,15 @@ ACE_URL_Local_Locator::withdraw_offer (const ACE_WString &offer_id) iter.next (item) != 0; iter.advance ()) if (offer_id == *item->id_) - { - if (this->repository_.remove (*item) == 0) - return 0 - else - { - errno = ACE_URL_Locator::UNKNOWN; - return -1; - } - } + { + if (this->repository_.remove (*item) == 0) + return 0 + else + { + errno = ACE_URL_Locator::UNKNOWN; + return -1; + } + } errno = ACE_URL_Locator::NO_SUCH_OFFER; return 0; @@ -121,7 +121,7 @@ ACE_URL_Local_Locator::withdraw_offer (const ACE_WString &offer_id) int ACE_URL_Local_Locator::describe_offer (const ACE_WString &offer_id, - ACE_URL_Offer *offer) + ACE_URL_Offer *offer) { ACE_URL_Record *item = 0; @@ -132,8 +132,8 @@ ACE_URL_Local_Locator::describe_offer (const ACE_WString &offer_id, iter.advance ()) if (offer_id == *item->id_) { - ACE_NEW_RETURN (offer, ACE_URL_Offer (*item->offer_), -1); - return 0; + ACE_NEW_RETURN (offer, ACE_URL_Offer (*item->offer_), -1); + return 0; } errno = ACE_URL_Locator::NO_SUCH_OFFER; @@ -142,9 +142,9 @@ ACE_URL_Local_Locator::describe_offer (const ACE_WString &offer_id, int ACE_URL_Local_Locator::modify_offer (const ACE_WString &offer_id, - const ACE_WString *url, - const ACE_URL_Property_Seq *del, - const ACE_URL_Property_Seq *modify) + const ACE_WString *url, + const ACE_URL_Property_Seq *del, + const ACE_URL_Property_Seq *modify) { ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_); ACE_URL_Record *item = 0; @@ -155,90 +155,90 @@ ACE_URL_Local_Locator::modify_offer (const ACE_WString &offer_id, for (; iter.next (item) != 0; iter.advance ()) { if (url != 0 && *url == item->offer_->url ()) - { - errno = ACE_URL_Locator::OFFER_EXIST; - return -1; - } + { + errno = ACE_URL_Locator::OFFER_EXIST; + return -1; + } if (offer_id == *item->id_) - target = item; + target = item; } if (target != 0) // Aha, we found a target to work on { if (del != 0 && modify != 0) - { - // We need to make a copy of the original property sequence - // so if any error occurs, we can revert our change easily. - - // First we need to calculate the maximum number of perperties. - int psize = target->offer_->url_properties ().size (); - if (del != 0) - if ((psize -= del->size ()) < 0) - { - // If you try to delete more properties than we have, - // you are doomed. No need to proceed. - errno = ACE_URL_Locator::INVALID_ARGUMENT; - return -1; - } - if (modify != 0) - // In the worst case, all properties in <modify> will be added. - psize += modify->size (); - - // Now, create a temporary work space. - ACE_URL_Property_Seq working (psize); - size_t sz = 0; - for (; sz < item->offer_->url_properties ().size ()) - working[sz] = item->offer_->url_properties() [sz]; - - if (del != 0) - { - // Argh, this is really a stupid design. - // Go thru every property we want to delete - for (size_t i = 0; i < del->size () && sz > 0; i++) - // For earch, go thru our property sequence and - // search for the property. - for (size_t j = 0; j < sz; j++) - if ((*del)[i].name () == working[j].name ()) - { - sz -= 1; - working[j] = working[sz]; // pack the array. - break; - } - // Doesn't generate error when we want to delete an - // imaginary property. Is this appropriate? - } - - if (modify != 0) - { - // This is also stupid. - // Go thru every property we want to modify/add - for (size_t i = 0; i < modify->size () && sz > 0; i++) - { - // For each property, go thru our property list - // and search for the matching property - for (size_t j = 0; j < sz; j++) - if ((*modify)[i].name () == working[j].name ()) - { - // A match found. - working[j].value ((*modify)[i].value ().fast_rep ()); - break; - } - - // No matching property name were found, - // We want to add this property into the list. - if (j == sz) - working[sz++] = (*modify)[i]; - } - } - } + { + // We need to make a copy of the original property sequence + // so if any error occurs, we can revert our change easily. + + // First we need to calculate the maximum number of perperties. + int psize = target->offer_->url_properties ().size (); + if (del != 0) + if ((psize -= del->size ()) < 0) + { + // If you try to delete more properties than we have, + // you are doomed. No need to proceed. + errno = ACE_URL_Locator::INVALID_ARGUMENT; + return -1; + } + if (modify != 0) + // In the worst case, all properties in <modify> will be added. + psize += modify->size (); + + // Now, create a temporary work space. + ACE_URL_Property_Seq working (psize); + size_t sz = 0; + for (; sz < item->offer_->url_properties ().size ()) + working[sz] = item->offer_->url_properties() [sz]; + + if (del != 0) + { + // Argh, this is really a stupid design. + // Go thru every property we want to delete + for (size_t i = 0; i < del->size () && sz > 0; i++) + // For earch, go thru our property sequence and + // search for the property. + for (size_t j = 0; j < sz; j++) + if ((*del)[i].name () == working[j].name ()) + { + sz -= 1; + working[j] = working[sz]; // pack the array. + break; + } + // Doesn't generate error when we want to delete an + // imaginary property. Is this appropriate? + } + + if (modify != 0) + { + // This is also stupid. + // Go thru every property we want to modify/add + for (size_t i = 0; i < modify->size () && sz > 0; i++) + { + // For each property, go thru our property list + // and search for the matching property + for (size_t j = 0; j < sz; j++) + if ((*modify)[i].name () == working[j].name ()) + { + // A match found. + working[j].value ((*modify)[i].value ().fast_rep ()); + break; + } + + // No matching property name were found, + // We want to add this property into the list. + if (j == sz) + working[sz++] = (*modify)[i]; + } + } + } // Yes, all operations passed. We can now copy the working version back. item->offer_->url_properties (ACE_URL_Property_Seq (sz)); for (size_t i = 0; i < sz; i ++) - item->offer_->url_properties ()[i] = working[i]; + item->offer_->url_properties ()[i] = working[i]; if (url != 0) - item->offer_->url (url->fast_rep ()); // replace URL location. + item->offer_->url (url->fast_rep ()); // replace URL location. return 0; } errno = ACE_URL_Locator::NO_SUCH_OFFER; diff --git a/ACE/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp b/ACE/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp index 6c3f052aedc..7a0aa391b34 100644 --- a/ACE/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp +++ b/ACE/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp @@ -18,8 +18,8 @@ ACE_RCSID(Caching, Locator_Request_Reply, "$Id$") int ACE_URL_Locator_Request::url_query (const int how, - const ACE_URL_Property_Seq &pseq, - const int how_many) + const ACE_URL_Property_Seq &pseq, + const int how_many) { ACE_TRACE ("ACE_URL_Locator_Request::url_query"); @@ -29,19 +29,19 @@ ACE_URL_Locator_Request::url_query (const int how, this->how_ = how; this->how_many_ = how_many; this->code_ = ACE_URL_Locator::QUERY; - return 0; + return 0; } int ACE_URL_Locator_Request::export_offer (const ACE_URL_Offer &offer) { ACE_TRACE ("ACE_URL_Locator_Request::export_offer"); - + ACE_NEW_RETURN (this->offer_, ACE_URL_Offer (offer), -1); this->code_ = ACE_URL_Locator::EXPORT; return 0; } - + int ACE_URL_Locator_Request::withdraw_offer (const ACE_WString &offer_id) { @@ -56,7 +56,7 @@ int ACE_URL_Locator_Request::describe_offer (const ACE_WString &offer_id) { ACE_TRACE ("ACE_URL_Locator_Request::describe_offer"); - + this->id_ = offer_id; this->code_ = ACE_URL_Locator::DESCRIBE; return 0; @@ -64,9 +64,9 @@ ACE_URL_Locator_Request::describe_offer (const ACE_WString &offer_id) int ACE_URL_Locator_Request::modify_offer (const ACE_WString &offer_id, - const ACE_WString *url, - const ACE_URL_Property_Seq &del, - const ACE_URL_Property_Seq &modify) + const ACE_WString *url, + const ACE_URL_Property_Seq &del, + const ACE_URL_Property_Seq &modify) { ACE_TRACE ("ACE_URL_Locator_Request::modify_offer"); @@ -107,7 +107,7 @@ ACE_URL_Locator_Request::encode (void) ENCODE_UINT32 (this->buffer_, total_length, this->how_); // Encode selection criteria. - + ENCODE_UINT32 (this->buffer_, total_length, this->how_many_); // Encode number of offers interested. @@ -128,9 +128,9 @@ ACE_URL_Locator_Request::encode (void) total_length += this->offer_->encode (this->buffer_ + total_length); total_length += ACE_WString_Helper::encode (this->buffer_ + total_length, - this->id_); + this->id_); total_length += ACE_WString_Helper::encode (this->buffer_ + total_length, - this->url_); + this->url_); ACE_ASSERT (total_length == buf_size); return total_length; @@ -149,16 +149,16 @@ ACE_URL_Locator_Request::decode (void *buffer) size_t buf_size; size_t total_length = 0; - + DECODE_UINT32 (cbuffer, total_length, buf_size); // Decode length of buffer size first. DECODE_UINT32 (cbuffer, total_length, this->code_); // Get the operation code. - + DECODE_UINT32 (cbuffer, total_length, this->how_); // Decode selection criteria. - + DECODE_UINT32 (cbuffer, total_length, this->how_many_); // Decode number of offers interested. @@ -184,7 +184,7 @@ ACE_URL_Locator_Request::decode (void *buffer) ACE_NEW_RETURN (this->offer_, ACE_URL_Offer, 0); total_length += this->offer_->decode (cbuffer + total_length); } - + this->id_ = ACE_WString ((ACE_USHORT16 *) (cbuffer + total_length)); total_length += ACE_WString_Helper::decode (cbuffer + total_length); this->url_ = ACE_WString ((ACE_USHORT16 *) (cbuffer + total_length)); @@ -223,7 +223,7 @@ ACE_URL_Locator_Request::size (void) this->valid_ptr_ |= VALID_OFFER; total_length += this->offer_->size (); } - + total_length += ACE_WString_Helper::size (this->id_); total_length += ACE_WString_Helper::size (this->url_); @@ -269,16 +269,16 @@ ACE_URL_Locator_Request::dump (void) const if (this->id_.length () > 0) ACE_DEBUG ((LM_DEBUG, "Offer ID: %s\n", - ACE_Auto_Basic_Array_Ptr<char> (this->id_.char_rep ()).get ())); + ACE_Auto_Basic_Array_Ptr<char> (this->id_.char_rep ()).get ())); else ACE_DEBUG ((LM_DEBUG, "Offer ID: \"\"\n")); if (this->url_.length () > 0) ACE_DEBUG ((LM_DEBUG, "URL: %s\n", - ACE_Auto_Basic_Array_Ptr<char> (this->url_.char_rep ()).get ())); + ACE_Auto_Basic_Array_Ptr<char> (this->url_.char_rep ()).get ())); else ACE_DEBUG ((LM_DEBUG, "URL: \"\"\n")); - + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } @@ -294,10 +294,10 @@ ACE_URL_Locator_Reply::status_reply (u_int op, int result) int ACE_URL_Locator_Reply::query_reply (int result, size_t num, - const ACE_URL_Offer_Seq &offers) + const ACE_URL_Offer_Seq &offers) { ACE_TRACE ("ACE_URL_Locator_Reply::query_reply"); - + this->code_ = ACE_URL_Locator::QUERY; this->status_ = result; ACE_NEW_RETURN (this->offers_, ACE_URL_Offer_Seq (offers), -1); @@ -306,7 +306,7 @@ ACE_URL_Locator_Reply::query_reply (int result, size_t num, int ACE_URL_Locator_Reply::describe_reply (int result, - const ACE_URL_Offer &offer) + const ACE_URL_Offer &offer) { ACE_TRACE ("ACE_URL_Locator_Reply::describe_reply"); @@ -353,7 +353,7 @@ ACE_URL_Locator_Reply::encode (void) ACE_ASSERT (total_length == buf_size); return 0; } - + size_t ACE_URL_Locator_Reply::decode (void *buffer) { @@ -396,11 +396,11 @@ ACE_URL_Locator_Reply::decode (void *buffer) ACE_NEW_RETURN (this->offers_, ACE_URL_Offer_Seq (n), 0); total_length += ace_array_decode (cbuffer + total_length, *this->offers_); } - + ACE_ASSERT (total_length ==buf_size); return 0; } - + size_t ACE_URL_Locator_Reply::size (void) { diff --git a/ACE/apps/JAWS/clients/Caching/URL_Properties.inl b/ACE/apps/JAWS/clients/Caching/URL_Properties.inl index 768ad967d94..c32484dbb5c 100644 --- a/ACE/apps/JAWS/clients/Caching/URL_Properties.inl +++ b/ACE/apps/JAWS/clients/Caching/URL_Properties.inl @@ -17,7 +17,7 @@ ACE_URL_Property::ACE_URL_Property (const char *name, const char *value) ACE_INLINE ACE_URL_Property::ACE_URL_Property (const ACE_USHORT16 *name, - const ACE_USHORT16 *value) + const ACE_USHORT16 *value) : name_ (name), value_ (value) { diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/bench.c b/ACE/apps/JAWS/clients/WebSTONE/src/bench.c index ace35460a1d..7139bcf040d 100644 --- a/ACE/apps/JAWS/clients/WebSTONE/src/bench.c +++ b/ACE/apps/JAWS/clients/WebSTONE/src/bench.c @@ -44,7 +44,7 @@ void *ptr; return ptr; } -/* +/* * Receive n bytes from a socket */ int @@ -53,18 +53,18 @@ recvdata(SOCKET sock, char *ptr, int nbytes) { int nleft, nread; nleft = nbytes; - while (nleft > 0) + while (nleft > 0) { D_PRINTF( "In recvdata(%d, %d)\n", sock, nleft ); nread = NETREAD(sock, ptr, nleft); D_PRINTF( "NETREAD() returned %d\n", nread ); if (BADSOCKET(nread) || nread == 0) - { - /* return error value NETWRITE */ + { + /* return error value NETWRITE */ D_PRINTF( "Error in recvdata(): %s\n",neterrstr() ); - return(nread); - } - + return(nread); + } + D_PRINTF( "NETREAD() data: \"%.*s\"\n", nread, ptr); nleft -= nread; ptr += nread; @@ -90,11 +90,11 @@ senddata(SOCKET sock, char *ptr, int nbytes) { nwritten = NETWRITE(sock, ptr, nleft); D_PRINTF( "senddata() returned %d\n", nwritten ); if (BADSOCKET(nwritten)) - { - /* return error value from NETWRITE */ + { + /* return error value from NETWRITE */ D_PRINTF( "Error in senddata(): %s\n", neterrstr() ); - return(nwritten); - } + return(nwritten); + } nleft -= nwritten; ptr += nwritten; } @@ -110,7 +110,7 @@ senddata(SOCKET sock, char *ptr, int nbytes) { char * timeval_to_text(const struct timeval *the_timeval) { - /* + /* * given a timeval (seconds and microseconds), put the text * "seconds.microseconds" into timeval_as_text */ @@ -120,8 +120,8 @@ timeval_to_text(const struct timeval *the_timeval) { seconds = the_timeval->tv_sec; microseconds = the_timeval->tv_usec; - returnval = sprintf(timeval_as_text, - "%10d.%6.6d\t", seconds, microseconds); + returnval = sprintf(timeval_as_text, + "%10d.%6.6d\t", seconds, microseconds); return timeval_as_text; } @@ -139,14 +139,14 @@ double_to_text(const double the_double) { } struct timeval -text_to_timeval(char *timeval_as_text) { +text_to_timeval(char *timeval_as_text) { int returnval = 0; long int seconds, microseconds; struct timeval the_timeval; D_PRINTF("T/%d %s\n", (int)timeval_as_text, timeval_as_text); - returnval = sscanf(timeval_as_text, "%ld.%ld", - &seconds, µseconds); + returnval = sscanf(timeval_as_text, "%ld.%ld", + &seconds, µseconds); the_timeval.tv_sec = seconds; the_timeval.tv_usec = microseconds; return the_timeval; @@ -160,7 +160,7 @@ text_to_double(char *double_as_text) { D_PRINTF("D/%d %s\n", (int)double_as_text, double_as_text); returnval = sscanf(double_as_text, "%lf", &the_double); return(the_double); -} +} rqst_stats_t * @@ -168,61 +168,61 @@ text_to_rqst_stats(char *rqst_stats_as_text) { THREAD static rqst_stats_t rqst_stats; rqst_stats_t *the_rqst_stats = &rqst_stats; - the_rqst_stats->totalresponsetime = + the_rqst_stats->totalresponsetime = text_to_timeval(strtok(rqst_stats_as_text, "\t")); - - the_rqst_stats->totalresponsetimesq = - text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->minresponsetime = + + the_rqst_stats->totalresponsetimesq = + text_to_double(strtok((char *)0, "\t")); + + the_rqst_stats->minresponsetime = text_to_timeval(strtok((char *)0, "\t")); - - the_rqst_stats->maxresponsetime = + + the_rqst_stats->maxresponsetime = text_to_timeval(strtok((char *)0, "\t")); - - the_rqst_stats->totalconnecttime = + + the_rqst_stats->totalconnecttime = text_to_timeval(strtok((char *)0, "\t")); - - the_rqst_stats->totalconnecttimesq = + + the_rqst_stats->totalconnecttimesq = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->minconnecttime = + + the_rqst_stats->minconnecttime = text_to_timeval(strtok((char *)0, "\t")); - - the_rqst_stats->maxconnecttime = + + the_rqst_stats->maxconnecttime = text_to_timeval(strtok((char *)0, "\t")); - + the_rqst_stats->totalconnects = (unsigned long) text_to_double(strtok((char *)0, "\t")); - + the_rqst_stats->totalerrs = (unsigned long) text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->totalerrortime = + + the_rqst_stats->totalerrortime = text_to_timeval(strtok((char *)0, "\t")); - - the_rqst_stats->totalbytes = + + the_rqst_stats->totalbytes = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->totalbytessq = + + the_rqst_stats->totalbytessq = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->minbytes = + + the_rqst_stats->minbytes = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->maxbytes = + + the_rqst_stats->maxbytes = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->totalbody = + + the_rqst_stats->totalbody = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->totalbodysq = + + the_rqst_stats->totalbodysq = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->minbody = + + the_rqst_stats->minbody = text_to_double(strtok((char *)0, "\t")); - - the_rqst_stats->maxbody = + + the_rqst_stats->maxbody = text_to_double(strtok((char *)0, "\t")); return(the_rqst_stats); @@ -293,15 +293,15 @@ rqst_stats_to_text(rqst_stats_t *the_rqst_stats) { tmpbuf = double_to_text((the_rqst_stats->maxbody)); strcat(rqst_stats_as_text, tmpbuf); - D_PRINTF( "rqst_stats_to_text returning %d: %s\n", - strlen(rqst_stats_as_text), - rqst_stats_as_text ); + D_PRINTF("rqst_stats_to_text returning %d: %s\n", + strlen(rqst_stats_as_text), + rqst_stats_as_text ); return(rqst_stats_as_text); } -stats_t * +stats_t * text_to_stats(char *stats_as_text) { int i; rqst_stats_t *the_rqst_stats; @@ -314,13 +314,13 @@ text_to_stats(char *stats_as_text) { the_stats->rs = *the_rqst_stats; /* grab main structure */ - the_stats->starttime = text_to_timeval(strtok((char *)0, "\t")); - the_stats->endtime = text_to_timeval(strtok((char *)0, "\t")); - the_stats->datatime = text_to_timeval(strtok((char *)0, "\t")); - the_stats->totalpages = (unsigned long) text_to_double(strtok((char *)0, "\t")); - the_stats->total_num_of_files = (unsigned int) text_to_double(strtok((char *)0, "\t")); - for (i = 0; i < number_of_pages; i++) - { + the_stats->starttime = text_to_timeval(strtok((char *)0, "\t")); + the_stats->endtime = text_to_timeval(strtok((char *)0, "\t")); + the_stats->datatime = text_to_timeval(strtok((char *)0, "\t")); + the_stats->totalpages = (unsigned long) text_to_double(strtok((char *)0, "\t")); + the_stats->total_num_of_files = (unsigned int) text_to_double(strtok((char *)0, "\t")); + for (i = 0; i < number_of_pages; i++) + { the_stats->page_numbers[i] = (unsigned int) text_to_double(strtok((char *)0, "\t")); } /* return bytes read */ @@ -330,7 +330,7 @@ text_to_stats(char *stats_as_text) { -char * +char * stats_to_text(const stats_t *the_stats) { int i; THREAD static char stats_as_text[SIZEOF_STATSTEXT]; @@ -346,24 +346,24 @@ stats_to_text(const stats_t *the_stats) { /* main structure */ - tmpbuf = timeval_to_text(&(the_stats->starttime)); + tmpbuf = timeval_to_text(&(the_stats->starttime)); strcat(stats_as_text, tmpbuf); - tmpbuf = timeval_to_text(&(the_stats->endtime)); + tmpbuf = timeval_to_text(&(the_stats->endtime)); strcat(stats_as_text, tmpbuf); - - tmpbuf = timeval_to_text(&(the_stats->datatime)); + + tmpbuf = timeval_to_text(&(the_stats->datatime)); strcat(stats_as_text, tmpbuf); - tmpbuf = double_to_text((the_stats->totalpages)); + tmpbuf = double_to_text((the_stats->totalpages)); strcat(stats_as_text, tmpbuf); - tmpbuf = double_to_text((the_stats->total_num_of_files)); + tmpbuf = double_to_text((the_stats->total_num_of_files)); strcat(stats_as_text, tmpbuf); - for (i = 0; i < number_of_pages; i++) - { - tmpbuf = double_to_text((the_stats->page_numbers[i])); + for (i = 0; i < number_of_pages; i++) + { + tmpbuf = double_to_text((the_stats->page_numbers[i])); strcat(stats_as_text, tmpbuf); } @@ -384,12 +384,12 @@ text_to_page_stats(char *page_stats_as_text) { the_rqst_stats = text_to_rqst_stats(page_stats_as_text); /* grab main structure */ - pagestats->totalpages = (unsigned long) text_to_double(strtok((char *)0, "\t")); - - pagestats->page_size = (unsigned int) text_to_double(strtok((char *)0, "\t")); - - pagestats->page_valid = (int) text_to_double(strtok((char *)0, "\t")); - + pagestats->totalpages = (unsigned long) text_to_double(strtok((char *)0, "\t")); + + pagestats->page_size = (unsigned int) text_to_double(strtok((char *)0, "\t")); + + pagestats->page_valid = (int) text_to_double(strtok((char *)0, "\t")); + pagestats->rs = *the_rqst_stats; /* return bytes read */ @@ -398,7 +398,7 @@ text_to_page_stats(char *page_stats_as_text) { -char * +char * page_stats_to_text(const page_stats_t *pagestats) { THREAD static char page_stats_as_text[SIZEOF_PAGESTATSTEXT]; char *tmpbuf; @@ -412,13 +412,13 @@ page_stats_to_text(const page_stats_t *pagestats) { strcat(page_stats_as_text, tmpbuf); /* main structure */ - tmpbuf = double_to_text(pagestats->totalpages); + tmpbuf = double_to_text(pagestats->totalpages); strcat(page_stats_as_text, tmpbuf); - tmpbuf = double_to_text(pagestats->page_size); + tmpbuf = double_to_text(pagestats->page_size); strcat(page_stats_as_text, tmpbuf); - tmpbuf = double_to_text(pagestats->page_valid); + tmpbuf = double_to_text(pagestats->page_valid); strcat(page_stats_as_text, tmpbuf); strcat(page_stats_as_text, "\n"); @@ -479,7 +479,7 @@ rqstat_times(rqst_stats_t *rs, rqst_timer_t *rt) double t; compdifftime(&(rt->exittime), &(rt->entertime), - &(rs->totalresponsetime)); + &(rs->totalresponsetime)); t = timevaldouble(&(rs->totalresponsetime)); rs->totalresponsetimesq = t * t; @@ -487,7 +487,7 @@ rqstat_times(rqst_stats_t *rs, rqst_timer_t *rt) rs->maxresponsetime = rs->totalresponsetime; compdifftime(&(rt->afterconnect), &(rt->beforeconnect), - &(rs->totalconnecttime)); + &(rs->totalconnecttime)); t = timevaldouble(&(rs->totalconnecttime)); rs->totalconnecttimesq = t * t; @@ -556,80 +556,77 @@ rqstat_fprint(FILE *f, rqst_stats_t *stats) struct timeval meantime, /*vartime,*/ stdtime; fprintf(f, "%d connection(s) to server, %d errors\n", - stats->totalconnects, stats->totalerrs); + stats->totalconnects, stats->totalerrs); if (stats->totalconnects == 0) { - fprintf(f,"NO CONNECTIONS, THEREFORE NO STATISTICS\n" - "IS YOUR WEBSERVER RUNNING?\n" - "DO THE PAGES EXIST ON THE SERVER?\n"); - return; + fprintf(f,"NO CONNECTIONS, THEREFORE NO STATISTICS\n" + "IS YOUR WEBSERVER RUNNING?\n" + "DO THE PAGES EXIST ON THE SERVER?\n"); + return; } /* title */ fprintf(f, "\n\t\t\t Average Std Dev Minimum Maximum\n\n"); /* first line (connect time) */ - avgtime(&(stats->totalconnecttime), - stats->totalconnects, &meantime); + avgtime(&(stats->totalconnecttime), + stats->totalconnects, &meantime); /* variancetime(&(stats->totalconnecttime), - stats->totalconnecttimesq, - stats->totalconnects, &vartime); */ + stats->totalconnecttimesq, + stats->totalconnects, &vartime); */ stddevtime(&(stats->totalconnecttime), - stats->totalconnecttimesq, - stats->totalconnects, &stdtime); + stats->totalconnecttimesq, + stats->totalconnects, &stdtime); fprintf(f, "Connect time (sec) \t%3d.%6.6d %3d.%6.6d %3d.%6.6d %3d.%6.6d\n", - meantime.tv_sec, - meantime.tv_usec, - stdtime.tv_sec, - stdtime.tv_usec, - stats->minconnecttime.tv_sec, - stats->minconnecttime.tv_usec, - stats->maxconnecttime.tv_sec, - stats->maxconnecttime.tv_usec); + meantime.tv_sec, + meantime.tv_usec, + stdtime.tv_sec, + stdtime.tv_usec, + stats->minconnecttime.tv_sec, + stats->minconnecttime.tv_usec, + stats->maxconnecttime.tv_sec, + stats->maxconnecttime.tv_usec); /* second line (response time) */ - avgtime(&(stats->totalresponsetime), - stats->totalconnects, &meantime); + avgtime(&(stats->totalresponsetime), + stats->totalconnects, &meantime); /* variancetime(&(stats->totalresponsetime), - stats->totalresponsetimesq, - stats->totalconnects, &vartime); */ + stats->totalresponsetimesq, + stats->totalconnects, &vartime); */ stddevtime(&(stats->totalresponsetime), - stats->totalresponsetimesq, - stats->totalconnects, &stdtime); + stats->totalresponsetimesq, + stats->totalconnects, &stdtime); fprintf(f, "Response time (sec) \t%3d.%6.6d %3d.%6.6d %3d.%6.6d %3d.%6.6d\n", - meantime.tv_sec, - meantime.tv_usec, - stdtime.tv_sec, - stdtime.tv_usec, - stats->minresponsetime.tv_sec, - stats->minresponsetime.tv_usec, - stats->maxresponsetime.tv_sec, - stats->maxresponsetime.tv_usec); + meantime.tv_sec, + meantime.tv_usec, + stdtime.tv_sec, + stdtime.tv_usec, + stats->minresponsetime.tv_sec, + stats->minresponsetime.tv_usec, + stats->maxresponsetime.tv_sec, + stats->maxresponsetime.tv_usec); /* 3rd-5th lines (response size, body size, # bytes moved */ fprintf(f, "Response size (bytes) \t%10.0lf %10.0lf %10.0lf %10.0lf\n", - mean(stats->totalbytes, stats->totalconnects), - stddev(stats->totalbytes, stats->totalbytessq, - stats->totalconnects), - stats->minbytes, - stats->maxbytes); + mean(stats->totalbytes, stats->totalconnects), + stddev(stats->totalbytes, stats->totalbytessq, stats->totalconnects), + stats->minbytes, + stats->maxbytes); fprintf(f, "Body size (bytes) \t%10.0lf %10.0lf %10.0lf %10.0lf\n\n", - mean(stats->totalbody, stats->totalconnects), - stddev(stats->totalbody, stats->totalbodysq, - stats->totalconnects), - stats->minbody, - stats->maxbody); + mean(stats->totalbody, stats->totalconnects), + stddev(stats->totalbody, stats->totalbodysq, stats->totalconnects), + stats->minbody, + stats->maxbody); fprintf(f, "%.0lf body bytes moved + %.0lf header bytes moved = %.0lf total\n", - stats->totalbody, - stats->totalbytes - stats->totalbody, - stats->totalbytes); - + stats->totalbody, + stats->totalbytes - stats->totalbody, + stats->totalbytes); } diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/cgi-send.c b/ACE/apps/JAWS/clients/WebSTONE/src/cgi-send.c index f1474d34c28..5626836f650 100644 --- a/ACE/apps/JAWS/clients/WebSTONE/src/cgi-send.c +++ b/ACE/apps/JAWS/clients/WebSTONE/src/cgi-send.c @@ -15,34 +15,34 @@ int main() { - int filesize; - char *str_filesize; - char *buffer; - int index; + int filesize; + char *str_filesize; + char *buffer; + int index; - printf("Content-type: text/plain\r\n\r\n"); + printf("Content-type: text/plain\r\n\r\n"); - if ( !(str_filesize = getenv("QUERY_STRING")) ) - filesize = FILE_SIZE; - else { - if ( !strncmp(str_filesize, "size=", 5) ) - filesize = atoi(&(str_filesize[5])); - else - filesize = FILE_SIZE; - } + if ( !(str_filesize = getenv("QUERY_STRING")) ) + filesize = FILE_SIZE; + else { + if ( !strncmp(str_filesize, "size=", 5) ) + filesize = atoi(&(str_filesize[5])); + else + filesize = FILE_SIZE; + } - if ( !(buffer = (char *)malloc(filesize)) ) { - fwrite(MALLOC_FAILURE, strlen(MALLOC_FAILURE), 1, stdout); - return -1; - } + if ( !(buffer = (char *)malloc(filesize)) ) { + fwrite(MALLOC_FAILURE, strlen(MALLOC_FAILURE), 1, stdout); + return -1; + } - for (index=0; index< filesize; index++) - /* generate random characters from A-Z */ - buffer[index] = rand() %26 + 63; + for (index=0; index< filesize; index++) + /* generate random characters from A-Z */ + buffer[index] = rand() %26 + 63; - fwrite(buffer, filesize, 1, stdout); + fwrite(buffer, filesize, 1, stdout); - free(buffer); + free(buffer); - return 0; + return 0; } diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/get.c b/ACE/apps/JAWS/clients/WebSTONE/src/get.c index 8a6d9232deb..1fd5a31942c 100644 --- a/ACE/apps/JAWS/clients/WebSTONE/src/get.c +++ b/ACE/apps/JAWS/clients/WebSTONE/src/get.c @@ -1,15 +1,15 @@ /* $Id$ */ /************************************************************************** - * * - * Copyright (C) 1995 Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs were * - * developed by SGI for public use. If any changes are made to this code* - * please try to get the changes back to the author. Feel free to make * - * modifications and changes to the code and release it. * - * * + * + * Copyright (C) 1995 Silicon Graphics, Inc. + * + * These coded instructions, statements, and computer programs were + * developed by SGI for public use. If any changes are made to this code + * please try to get the changes back to the author. Feel free to make + * modifications and changes to the code and release it. + * **************************************************************************/ - + /* THIS IS WHERE WE GO OUT AND FETCH A URL */ #include <stdio.h> @@ -51,13 +51,13 @@ /* compare two strings with max length, ignoring case */ int mystrincmp(const char *str1, const char *str2, int len) { -register int diff; + register int diff; while (*str1 && *str2 && len--) { - if (diff = UPPER(*str1) - UPPER(*str2)) - return diff < 0 ? -1 : 1; - str1++; - str2++; + if (diff = UPPER(*str1) - UPPER(*str2)) + return diff < 0 ? -1 : 1; + str1++; + str2++; } return 0; } @@ -85,52 +85,51 @@ get(char *loc, NETPORT port, char *url, rqst_timer_t *timer) #ifdef ABORTIVE_CLOSE #error don't enable this option struct linger { - int l_onoff; - int l_linger; + int l_onoff; + int l_linger; } linger_opt; #endif /* ABORTIVE_CLOSE */ /* can you really get an error from gettimeofday?? */ if(GETTIMEOFDAY(&timer->entertime, &timer->entertimezone) != 0) { - returnerr("Error retrieving entertime\n"); - goto error; + returnerr("Error retrieving entertime\n"); + goto error; } timer->valid = 1; if(GETTIMEOFDAY(&timer->beforeconnect, &timer->beforeconnectzone) != 0) { - returnerr("Error retrieving beforeconnect\n"); - goto error; + returnerr("Error retrieving beforeconnect\n"); + goto error; } sock = connectsock(loc, port, "tcp"); if (BADSOCKET(sock)) { - D_PRINTF( "Call to connectsock returned %d (%s)\n", sock, neterrstr() ); - returnerr("Couldn't connect to WWW server: %s\n", neterrstr()); - goto error; + D_PRINTF( "Call to connectsock returned %d (%s)\n", sock, neterrstr() ); + returnerr("Couldn't connect to WWW server: %s\n", neterrstr()); + goto error; } -#ifdef ABORTIVE_CLOSE +#ifdef ABORTIVE_CLOSE #error don't enable this option /* set up for abortive close */ linger_opt.l_onoff = 1; linger_opt.l_linger = 0; - if (setsockopt(sock, SOL_SOCKET, SO_LINGER, - (char *) &linger_opt, sizeof(linger_opt)) < 0) { - fprintf(stderr, "Can't set sockopt SO_LINGER"); - returnerr("Couldn't set SO_LINGER = 0\n"); - goto error; + if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *) &linger_opt, sizeof(linger_opt)) < 0) { + fprintf(stderr, "Can't set sockopt SO_LINGER"); + returnerr("Couldn't set SO_LINGER = 0\n"); + goto error; } #endif /* ABORTIVE_CLOSE */ if(GETTIMEOFDAY(&timer->afterconnect, &timer->afterconnectzone) != 0) { - NETCLOSE(sock); - GETTIMEOFDAY(&timer->exittime, &timer->exittimezone); - returnerr("Error retrieving afterconnect\n"); - goto error; + NETCLOSE(sock); + GETTIMEOFDAY(&timer->exittime, &timer->exittimezone); + returnerr("Error retrieving afterconnect\n"); + goto error; } /* @@ -143,19 +142,19 @@ get(char *loc, NETPORT port, char *url, rqst_timer_t *timer) status = NETWRITE(sock, getcommand, writelen); if(status != writelen) { - returnerr("Error sending command line to server: %s\n", - neterrstr()); - goto error; + returnerr("Error sending command line to server: %s\n", + neterrstr()); + goto error; } - /* - * WE HAVE NOW SENT THE REQUEST SUCCESSFULLY. - * WAIT FOR THE REPLY AND FIND THE HEADER + /* + * WE HAVE NOW SENT THE REQUEST SUCCESSFULLY. + * WAIT FOR THE REPLY AND FIND THE HEADER */ - + if(GETTIMEOFDAY(&timer->beforeheader, &timer->beforeheaderzone) != 0) { - returnerr("Error retrieving beforeheader\n"); - goto error; + returnerr("Error retrieving beforeheader\n"); + goto error; } /* read the header and part of the file */ @@ -166,57 +165,57 @@ get(char *loc, NETPORT port, char *url, rqst_timer_t *timer) bytesread = NETREAD(sock, headerbuffer+totalbytesread, HEADERBUFSIZ-totalbytesread); if (BADSOCKET(bytesread)) { - D_PRINTF( "Did not receive full header\n" ); - D_PRINTF( "NETREAD returned %d\n", bytesread ); - returnerr("Did not receive full header: %s\n", - neterrstr()); - goto error; + D_PRINTF( "Did not receive full header\n" ); + D_PRINTF( "NETREAD returned %d\n", bytesread ); + returnerr("Did not receive full header: %s\n", + neterrstr()); + goto error; } totalbytesread += bytesread; - /* search for end of header */ - headerbuffer[totalbytesread] = 0; - if (offset = strstr(headerbuffer, "\n\n")) { - headerlen = offset - headerbuffer + 2; - break; - } else if (offset = strstr(headerbuffer, "\n\r\n")) { - headerlen = offset - headerbuffer + 3; - break; - } + /* search for end of header */ + headerbuffer[totalbytesread] = 0; + if (offset = strstr(headerbuffer, "\n\n")) { + headerlen = offset - headerbuffer + 2; + break; + } else if (offset = strstr(headerbuffer, "\n\r\n")) { + headerlen = offset - headerbuffer + 3; + break; + } } if (headerlen == 0) { - returnerr("Can't find the end of the header in \"%s\"\n", headerbuffer); - goto error; + returnerr("Can't find the end of the header in \"%s\"\n", headerbuffer); + goto error; } /* get and check status code from the first line of the header */ count = sscanf(headerbuffer, "HTTP/%s %d", version, &status); if (count != 2) { - returnerr("Bad status line in get(): %s\n", headerbuffer); - goto error; + returnerr("Bad status line in get(): %s\n", headerbuffer); + goto error; } if (status < 200 || status > 300) { - returnerr("Bad status (%d) in get() for url %s\n", status, url); - goto error; + returnerr("Bad status (%d) in get() for url %s\n", status, url); + goto error; } /* get the content length line from the header */ offset = headerbuffer; while (offset < headerbuffer+headerlen && *offset) { - if (*offset++ != '\n') - continue; + if (*offset++ != '\n') + continue; - if (mystrincmp(offset, CONTENT_LENGTH_STRING, strlen(CONTENT_LENGTH_STRING)) == 0) { - sscanf(offset+strlen(CONTENT_LENGTH_STRING), "%d", &contentlength); - D_PRINTF( "Content-Length: %d\n", contentlength ); - } + if (mystrincmp(offset, CONTENT_LENGTH_STRING, strlen( CONTENT_LENGTH_STRING)) == 0) { + sscanf(offset+strlen(CONTENT_LENGTH_STRING), "%d", &contentlength); + D_PRINTF( "Content-Length: %d\n", contentlength ); + } } if(GETTIMEOFDAY(&timer->afterheader, &timer->afterheaderzone) != 0) { - returnerr("Error retrieving afterheader\n"); - goto error; + returnerr("Error retrieving afterheader\n"); + goto error; } if(savefile) @@ -224,57 +223,56 @@ get(char *loc, NETPORT port, char *url, rqst_timer_t *timer) sprintf(outputfilename,"/tmp/webstone.data.%d", (int)getpid()); if((outputfile = open(outputfilename,(O_WRONLY|O_CREAT),0777)) < 0) { - D_PRINTF( "outputfile %d %d\n", outputfile, errno ); - returnerr("Error saving file: %s\n", strerror(errno)); - goto error; + D_PRINTF( "outputfile %d %d\n", outputfile, errno ); + returnerr("Error saving file: %s\n", strerror(errno)); + goto error; } - lseek(outputfile,1,SEEK_END); /* this is odd... JEF */ + lseek(outputfile,1,SEEK_END); /* this is odd... JEF */ - /* if we have part of the file already, save that part */ - if(totalbytesread > headerlen) - { - write(outputfile, headerbuffer+headerlen, totalbytesread-headerlen); - } + /* if we have part of the file already, save that part */ + if(totalbytesread > headerlen) + { + write(outputfile, headerbuffer+headerlen, totalbytesread-headerlen); + } } /* read the body of the file */ do { - bytesread = NETREAD(sock, headerbuffer, HEADERBUFSIZ); - D_PRINTF( "Read %d bytes from socket %d\n", bytesread, sock ); + bytesread = NETREAD(sock, headerbuffer, HEADERBUFSIZ); + D_PRINTF( "Read %d bytes from socket %d\n", bytesread, sock ); - if (BADSOCKET(bytesread)) - { - D_PRINTF( "Read returns %d, error: %s\n", bytesread, - neterrstr() ); + if (BADSOCKET(bytesread)) + { + D_PRINTF("Read returns %d, error: %s\n", bytesread, + neterrstr() ); returnerr("Error during read of page body. Read " - "returns %d on socket %d, error: %s\n", - bytesread, sock, neterrstr()); - goto error; - } - - totalbytesread += bytesread; + "returns %d on socket %d, error: %s\n", + bytesread, sock, neterrstr()); + goto error; + } - if (outputfile != -1 && bytesread) - { - write(outputfile, headerbuffer, bytesread); - } + totalbytesread += bytesread; + if (outputfile != -1 && bytesread) + { + write(outputfile, headerbuffer, bytesread); + } } while (bytesread); - + /* done reading body */ if ( contentlength && (totalbytesread - headerlen) != contentlength) { - D_PRINTF( "Warning: file length (%d) doesn't match Content-length (%d)\n", - totalbytesread - headerlen, contentlength); + D_PRINTF( "Warning: file length (%d) doesn't match Content-length (%d)\n", + totalbytesread - headerlen, contentlength); } - + bodylength = totalbytesread - headerlen; if(GETTIMEOFDAY(&timer->afterbody, &timer->afterbodyzone) != 0) { - returnerr("Error retrieving afterbody\n"); - goto error; + returnerr("Error retrieving afterbody\n"); + goto error; } NETCLOSE(sock); @@ -283,28 +281,28 @@ get(char *loc, NETPORT port, char *url, rqst_timer_t *timer) close(outputfile); } - D_PRINTF( "Read %d bytes, %d of that being body\n", - totalbytesread, bodylength ); + D_PRINTF("Read %d bytes, %d of that being body\n", + totalbytesread, bodylength ); if(GETTIMEOFDAY(&timer->exittime, &timer->exittimezone) != 0) { - D_PRINTF( "Error retrieving exit time: %s\n", strerror(errno) ); - returnerr("Error retrieving exit time\n"); - goto error; + D_PRINTF( "Error retrieving exit time: %s\n", strerror(errno) ); + returnerr("Error retrieving exit time\n"); + goto error; } timer->valid = 2; timer->totalbytes = totalbytesread; timer->bodybytes = bodylength; - D_PRINTF( "get returning totalbytes %d body %d valid %d\n", - timer->totalbytes, timer->bodybytes, timer->valid ); + D_PRINTF("get returning totalbytes %d body %d valid %d\n", + timer->totalbytes, timer->bodybytes, timer->valid ); - D_PRINTF( "get returning start %d, end %d\n", - timer->entertime.tv_sec, timer->exittime.tv_sec ); + D_PRINTF("get returning start %d, end %d\n", + timer->entertime.tv_sec, timer->exittime.tv_sec ); - D_PRINTF( "get returning connect %d, request %d, header %d, body %d\n", - timer->afterconnect.tv_sec, timer->beforeheader.tv_sec, - timer->afterheader.tv_sec, timer->afterbody.tv_sec ); + D_PRINTF("get returning connect %d, request %d, header %d, body %d\n", + timer->afterconnect.tv_sec, timer->beforeheader.tv_sec, + timer->afterheader.tv_sec, timer->afterbody.tv_sec ); return 0; @@ -312,7 +310,7 @@ error: if (!BADSOCKET(sock)) NETCLOSE(sock); if (outputfile != -1) - close(outputfile); + close(outputfile); GETTIMEOFDAY(&timer->exittime, &timer->exittimezone); /* needed? */ return -1; -} +} diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/getopt.c b/ACE/apps/JAWS/clients/WebSTONE/src/getopt.c index d04ea469aa6..a57064531ad 100644 --- a/ACE/apps/JAWS/clients/WebSTONE/src/getopt.c +++ b/ACE/apps/JAWS/clients/WebSTONE/src/getopt.c @@ -6,62 +6,62 @@ #include <string.h> #define MYNULL 0 -#define ERR(s, c) if(opterr){\ - extern size_t strlen();\ - extern int write();\ - char errbuf[2];\ - errbuf[0] = c; errbuf[1] = '\n';\ - (void) write(2, argv[0], strlen(argv[0]));\ - (void) write(2, s, strlen(s));\ - (void) write(2, errbuf, 2);} +#define ERR(s, c) if(opterr){\ + extern size_t strlen();\ + extern int write();\ + char errbuf[2];\ + errbuf[0] = c; errbuf[1] = '\n';\ + (void) write(2, argv[0], strlen(argv[0]));\ + (void) write(2, s, strlen(s));\ + (void) write(2, errbuf, 2);} -int opterr = 1; -int optind = 1; -int optopt; -char *optarg; +int opterr = 1; +int optind = 1; +int optopt; +char *optarg; int getopt(argc, argv, opts) -int argc; -char **argv, *opts; +int argc; +char **argv, *opts; { - static int sp = 1; - register int c; - register char *cp; + static int sp = 1; + register int c; + register char *cp; - if(sp == 1) - if(optind >= argc || - argv[optind][0] != '-' || argv[optind][1] == '\0') - return(EOF); - else if(strcmp(argv[optind], "--") == MYNULL) { - optind++; - return(EOF); - } - optopt = c = argv[optind][sp]; - if(c == ':' || (cp=strchr(opts, c)) == 0) { - ERR(": unknown option, -", c); - if(argv[optind][++sp] == '\0') { - optind++; - sp = 1; - } - return('?'); - } - if(*++cp == ':') { - if(argv[optind][sp+1] != '\0') - optarg = &argv[optind++][sp+1]; - else if(++optind >= argc) { - ERR(": argument missing for -", c); - sp = 1; - return('?'); - } else - optarg = argv[optind++]; - sp = 1; - } else { - if(argv[optind][++sp] == '\0') { - sp = 1; - optind++; - } - optarg = 0; - } - return(c); + if(sp == 1) + if(optind >= argc || + argv[optind][0] != '-' || argv[optind][1] == '\0') + return(EOF); + else if(strcmp(argv[optind], "--") == MYNULL) { + optind++; + return(EOF); + } + optopt = c = argv[optind][sp]; + if(c == ':' || (cp=strchr(opts, c)) == 0) { + ERR(": unknown option, -", c); + if(argv[optind][++sp] == '\0') { + optind++; + sp = 1; + } + return('?'); + } + if(*++cp == ':') { + if(argv[optind][sp+1] != '\0') + optarg = &argv[optind++][sp+1]; + else if(++optind >= argc) { + ERR(": argument missing for -", c); + sp = 1; + return('?'); + } else + optarg = argv[optind++]; + sp = 1; + } else { + if(argv[optind][++sp] == '\0') { + sp = 1; + optind++; + } + optarg = 0; + } + return(c); } diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/nsapi-send.c b/ACE/apps/JAWS/clients/WebSTONE/src/nsapi-send.c index 70e99d33a87..e87514934d9 100644 --- a/ACE/apps/JAWS/clients/WebSTONE/src/nsapi-send.c +++ b/ACE/apps/JAWS/clients/WebSTONE/src/nsapi-send.c @@ -48,7 +48,7 @@ #define HEADERS "HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n" #ifdef WIN32 -__declspec(dllexport) +__declspec(dllexport) #endif int nsapi_send(pblock *pb, Session *sn, Request *rq) @@ -63,9 +63,9 @@ int nsapi_send(pblock *pb, Session *sn, Request *rq) * file size was specified. */ if ( !(query_string = pblock_findval("query", rq->reqpb)) ) - filesize = FILE_SIZE; + filesize = FILE_SIZE; else { - filesize = atoi(&(query_string[5])); + filesize = atoi(&(query_string[5])); } memcpy(&buffer, HEADERS, sizeof(HEADERS)-1); @@ -73,16 +73,16 @@ int nsapi_send(pblock *pb, Session *sn, Request *rq) /* Generate the output */ maxindex = sizeof(HEADERS) + filesize; for (index=sizeof(HEADERS); index < (maxindex); index++) - /* generate random characters from A-Z */ + /* generate random characters from A-Z */ #ifdef IRIX - buffer[index] = rand_r() % 26 + 63; + buffer[index] = rand_r() % 26 + 63; #else buffer[index] = rand() %26 + 63; #endif /* Send the output */ if (net_write(sn->csd, buffer, sizeof(HEADERS)-1+filesize, 0) == IO_ERROR) - return REQ_EXIT; + return REQ_EXIT; return REQ_PROCEED; } diff --git a/ACE/apps/JAWS/server/HTTP_Config.cpp b/ACE/apps/JAWS/server/HTTP_Config.cpp index 11890037d3c..5ba338f655c 100644 --- a/ACE/apps/JAWS/server/HTTP_Config.cpp +++ b/ACE/apps/JAWS/server/HTTP_Config.cpp @@ -80,7 +80,7 @@ HTTP_Config_Info::document_root (const char *dr_string) { this->document_root_ = ACE_OS::getenv ("JAWS_DOCUMENT_ROOT"); if (!this->document_root_) - this->document_root_ = "."; + this->document_root_ = "."; } return this->document_root_; @@ -96,7 +96,7 @@ HTTP_Config_Info::cgi_path (const char *cp_string) this->cgi_path_ = ACE_OS::getenv ("JAWS_CGI_PATH"); if (!this->cgi_path_) - this->cgi_path_ = "cgi-bin"; + this->cgi_path_ = "cgi-bin"; } return this->cgi_path_; @@ -111,7 +111,7 @@ HTTP_Config_Info::user_dir (const char *ud_string) { this->user_dir_ = ACE_OS::getenv ("JAWS_USER_DIR"); if (!this->user_dir_) - this->user_dir_ = ".www"; + this->user_dir_ = ".www"; } return this->user_dir_; @@ -126,7 +126,7 @@ HTTP_Config_Info::dir_index (const char *di_string) { this->dir_index_ = ACE_OS::getenv ("JAWS_DIR_INDEX"); if (!this->dir_index_) - this->dir_index_ = "index.html"; + this->dir_index_ = "index.html"; } return this->dir_index_; diff --git a/ACE/apps/JAWS/server/HTTP_Handler.cpp b/ACE/apps/JAWS/server/HTTP_Handler.cpp index a4e4ad31b23..340d4773c3f 100644 --- a/ACE/apps/JAWS/server/HTTP_Handler.cpp +++ b/ACE/apps/JAWS/server/HTTP_Handler.cpp @@ -14,7 +14,7 @@ ACE_RCSID(server, HTTP_Handler, "$Id$") HTTP_Handler::HTTP_Handler (JAWS_IO &io, - HTTP_Handler_Factory &factory) + HTTP_Handler_Factory &factory) : factory_ (factory), request_data_ (0), handle_ (ACE_INVALID_HANDLE), @@ -32,7 +32,7 @@ HTTP_Handler::~HTTP_Handler (void) void HTTP_Handler::open (ACE_HANDLE handle, - ACE_Message_Block &initial_data) + ACE_Message_Block &initial_data) { ACE_DEBUG ((LM_DEBUG, "(%t) New connection \n")); @@ -171,7 +171,7 @@ void HTTP_Handler::transmit_file_error (int result) { ACE_DEBUG ((LM_DEBUG, - " (%t) %s error in transmitting file\n", + " (%t) %s error in transmitting file\n", request_.uri ())); int status_code; @@ -276,7 +276,7 @@ No_Cache_Synch_HTTP_Handler_Factory::create_http_handler (void) void No_Cache_Synch_HTTP_Handler_Factory::destroy_http_handler (HTTP_Handler &handler, - JAWS_IO &io) + JAWS_IO &io) { delete &io; delete &handler; @@ -288,7 +288,7 @@ No_Cache_Synch_HTTP_Handler_Factory::destroy_http_handler (HTTP_Handler &handler #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) void Asynch_HTTP_Handler_Factory::open (ACE_HANDLE handle, - ACE_Message_Block &mb) + ACE_Message_Block &mb) { JAWS_Asynch_IO *io; ACE_NEW (io, JAWS_Asynch_IO); @@ -299,7 +299,7 @@ Asynch_HTTP_Handler_Factory::open (ACE_HANDLE handle, void Asynch_HTTP_Handler_Factory::destroy_http_handler (HTTP_Handler &handler, - JAWS_IO &io) + JAWS_IO &io) { delete &handler; delete &io; diff --git a/ACE/apps/JAWS/server/HTTP_Helpers.cpp b/ACE/apps/JAWS/server/HTTP_Helpers.cpp index 4bbaa6ee498..083199e49b1 100644 --- a/ACE/apps/JAWS/server/HTTP_Helpers.cpp +++ b/ACE/apps/JAWS/server/HTTP_Helpers.cpp @@ -44,9 +44,9 @@ HTTP_Helper::HTTP_mktime (const char *httpdate) do { if (*ptr1 == ' ') - *ptr2++ = ';'; + *ptr2++ = ';'; else - *ptr2++ = *ptr1; + *ptr2++ = *ptr1; } while (*ptr1++ != '\0'); @@ -70,11 +70,11 @@ HTTP_Helper::HTTP_mktime (const char *httpdate) if (::sscanf(buf, "%3s,;%2d;%3s;%4d;%2d:%2d:%2d;GMT", // RFC-1123 date format weekday, &tms.tm_mday, - month, - &tms.tm_year, + month, + &tms.tm_year, &tms.tm_hour, - &tms.tm_min, - &tms.tm_sec) == 7) + &tms.tm_min, + &tms.tm_sec) == 7) ; else if (::sscanf(buf, "%s,;%2d-%3s-%2d;%2d:%2d:%2d;GMT", // RFC-850 date format weekday, @@ -192,14 +192,14 @@ HTTP_Helper::HTTP_decode_string (char *path) for (i = j = 0; path[i] != '\0'; i++, j++) { if (path[i] == '%') - { - percentcode[0] = path[++i]; - percentcode[1] = path[++i]; - percentcode[2] = '\0'; - path[j] = (char) ACE_OS::strtol (percentcode, (char **) 0, 16); - } + { + percentcode[0] = path[++i]; + percentcode[1] = path[++i]; + percentcode[2] = '\0'; + path[j] = (char) ACE_OS::strtol (percentcode, (char **) 0, 16); + } else - path[j] = path[i]; + path[j] = path[i]; } path[j] = path[i]; @@ -248,7 +248,7 @@ HTTP_Helper::HTTP_decode_base64 (char *data) char_count = 0; } else - bits <<= 6; + bits <<= 6; } if (c == '\0') @@ -360,23 +360,23 @@ HTTP_Helper::fixyear (int year) time_t tloc; if (ACE_OS::time (&tloc) != (time_t) -1) - { - ACE_OS::gmtime_r (&tloc, &tms); + { + ACE_OS::gmtime_r (&tloc, &tms); - if (tms.tm_year % 100 == year) - year = tms.tm_year; + if (tms.tm_year % 100 == year) + year = tms.tm_year; // The last two cases check boundary conditions, in case the // year just changed at the moment we checked to see if we // need to fix it. - if ((year+1) % 100 == tms.tm_year % 100) - year = tms.tm_year - 1; + if ((year+1) % 100 == tms.tm_year % 100) + year = tms.tm_year - 1; - if (year == (tms.tm_year + 1) % 100) - year = tms.tm_year + 1; + if (year == (tms.tm_year + 1) % 100) + year = tms.tm_year + 1; - // What to do if none of the above? - } + // What to do if none of the above? + } } return year; @@ -390,50 +390,50 @@ HTTP_Status_Code::instance (void) ACE_MT (ACE_Guard<ACE_SYNCH_MUTEX> g (lock_)); if (HTTP_Status_Code::instance_ == 0) - { - for (size_t i = 0; - i < HTTP_Status_Code::MAX_STATUS_CODE + 1; - i++) - { - switch (i) - { - case STATUS_OK: - HTTP_Status_Code::Reason[i] = "OK"; break; - case STATUS_CREATED: - HTTP_Status_Code::Reason[i] = "Created"; break; - case STATUS_ACCEPTED: - HTTP_Status_Code::Reason[i] = "Accepted"; break; - case STATUS_NO_CONTENT: - HTTP_Status_Code::Reason[i] = "No Content"; break; - case STATUS_MOVED_PERMANENTLY: - HTTP_Status_Code::Reason[i] = "Moved Permanently"; break; - case STATUS_MOVED_TEMPORARILY: - HTTP_Status_Code::Reason[i] = "Moved Temporarily"; break; - case STATUS_NOT_MODIFIED: - HTTP_Status_Code::Reason[i] = "Not Modified"; break; - case STATUS_BAD_REQUEST: - HTTP_Status_Code::Reason[i] = "Bad Request"; break; - case STATUS_UNAUTHORIZED: - HTTP_Status_Code::Reason[i] = "Unauthorized"; break; - case STATUS_FORBIDDEN: - HTTP_Status_Code::Reason[i] = "Forbidden"; break; - case STATUS_NOT_FOUND: - HTTP_Status_Code::Reason[i] = "Not Found"; break; - case STATUS_INTERNAL_SERVER_ERROR: - HTTP_Status_Code::Reason[i] = "Internal Server Error"; break; - case STATUS_NOT_IMPLEMENTED: - HTTP_Status_Code::Reason[i] = "Not Implemented"; break; - case STATUS_BAD_GATEWAY: - HTTP_Status_Code::Reason[i] = "Bad Gateway"; break; - case STATUS_SERVICE_UNAVAILABLE: - HTTP_Status_Code::Reason[i] = "Service Unavailable"; break; - default: - HTTP_Status_Code::Reason[i] = "Unknown"; - } - } - - HTTP_Status_Code::instance_ = 1; - } + { + for (size_t i = 0; + i < HTTP_Status_Code::MAX_STATUS_CODE + 1; + i++) + { + switch (i) + { + case STATUS_OK: + HTTP_Status_Code::Reason[i] = "OK"; break; + case STATUS_CREATED: + HTTP_Status_Code::Reason[i] = "Created"; break; + case STATUS_ACCEPTED: + HTTP_Status_Code::Reason[i] = "Accepted"; break; + case STATUS_NO_CONTENT: + HTTP_Status_Code::Reason[i] = "No Content"; break; + case STATUS_MOVED_PERMANENTLY: + HTTP_Status_Code::Reason[i] = "Moved Permanently"; break; + case STATUS_MOVED_TEMPORARILY: + HTTP_Status_Code::Reason[i] = "Moved Temporarily"; break; + case STATUS_NOT_MODIFIED: + HTTP_Status_Code::Reason[i] = "Not Modified"; break; + case STATUS_BAD_REQUEST: + HTTP_Status_Code::Reason[i] = "Bad Request"; break; + case STATUS_UNAUTHORIZED: + HTTP_Status_Code::Reason[i] = "Unauthorized"; break; + case STATUS_FORBIDDEN: + HTTP_Status_Code::Reason[i] = "Forbidden"; break; + case STATUS_NOT_FOUND: + HTTP_Status_Code::Reason[i] = "Not Found"; break; + case STATUS_INTERNAL_SERVER_ERROR: + HTTP_Status_Code::Reason[i] = "Internal Server Error"; break; + case STATUS_NOT_IMPLEMENTED: + HTTP_Status_Code::Reason[i] = "Not Implemented"; break; + case STATUS_BAD_GATEWAY: + HTTP_Status_Code::Reason[i] = "Bad Gateway"; break; + case STATUS_SERVICE_UNAVAILABLE: + HTTP_Status_Code::Reason[i] = "Service Unavailable"; break; + default: + HTTP_Status_Code::Reason[i] = "Unknown"; + } + } + + HTTP_Status_Code::instance_ = 1; + } // GUARD released } diff --git a/ACE/apps/JAWS/server/HTTP_Response.cpp b/ACE/apps/JAWS/server/HTTP_Response.cpp index 9750a1a6482..2f67a49c873 100644 --- a/ACE/apps/JAWS/server/HTTP_Response.cpp +++ b/ACE/apps/JAWS/server/HTTP_Response.cpp @@ -204,7 +204,7 @@ HTTP_Response::normal_response (void) = HTTP_Helper::HTTP_decode_base64 (ACE_OS::strcpy (buf, hvv)); if (mmapfile.map (ACE_TEXT ("jaws.auth")) != -1 - && auth != 0 + && auth != 0 && ACE_OS::strstr((const char *) mmapfile.addr (), auth) != 0) this->io_.receive_file (this->request_.path (), this->request_.data (), @@ -231,8 +231,8 @@ HTTP_Response::cgi_response (void) if (this->request_.cgi_args ()) cgi_options.command_line ("%s %s", - this->request_.path (), - this->request_.cgi_args ()); + this->request_.path (), + this->request_.cgi_args ()); else cgi_options.command_line ("%s", this->request_.path ()); @@ -252,27 +252,27 @@ HTTP_Response::cgi_response (void) if (this->request_.path_info ()) { cgi_options.setenv ("PATH_INFO", "%s", - this->request_.path_info ()); + this->request_.path_info ()); cgi_options.setenv ("PATH_TRANSLATED", - "%s/%s", + "%s/%s", HTTP_Config::instance ()->document_root (), this->request_.path_info ()); } cgi_options.setenv ("SCRIPT_NAME", - "%s", - this->request_.uri ()); + "%s", + this->request_.uri ()); if (this->request_.query_string ()) cgi_options.setenv ("QUERY_STRING", - "%s", - this->request_.query_string ()); + "%s", + this->request_.query_string ()); if (this->request_.cgi_env ()) for (size_t i = 0; this->request_.cgi_env ()[i]; i += 2) cgi_options.setenv (this->request_.cgi_env ()[i], - "%s", - this->request_.cgi_env ()[i+1]); + "%s", + this->request_.cgi_env ()[i+1]); char buf[BUFSIZ]; char *p, *q; @@ -345,12 +345,12 @@ HTTP_Response::build_headers (void) if (HTTP_Helper::HTTP_date (date_ptr) != 0) HTTP_HEADER_LENGTH += - ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, + ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, "Date: %s\r\n", date_ptr); if (! this->request_.cgi ()) { - HTTP_HEADER_LENGTH += - ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, + HTTP_HEADER_LENGTH += + ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, "Content-type: %s\r\n", "text/html"); @@ -362,9 +362,9 @@ HTTP_Response::build_headers (void) if ((this->request_.type () == HTTP_Request::GET) && (ACE_OS::stat (this->request_.path (), &file_stat) == 0)) { - HTTP_HEADER_LENGTH += - ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, - "Content-length: %u\r\n", file_stat.st_size); + HTTP_HEADER_LENGTH += + ACE_OS::sprintf (HTTP_HEADER+HTTP_HEADER_LENGTH, + "Content-length: %u\r\n", file_stat.st_size); } // Complete header with empty line and adjust header length. diff --git a/ACE/apps/JAWS/server/HTTP_Server.cpp b/ACE/apps/JAWS/server/HTTP_Server.cpp index dcaf1858cd4..42cb6618241 100644 --- a/ACE/apps/JAWS/server/HTTP_Server.cpp +++ b/ACE/apps/JAWS/server/HTTP_Server.cpp @@ -143,10 +143,10 @@ HTTP_Server::init (int argc, ACE_TCHAR *argv[]) HTTP_Handler_Factory *f = 0; if (this->strategy_ != (JAWS::JAWS_POOL | JAWS::JAWS_ASYNCH)) - if (this->caching_) - ACE_NEW_RETURN (f, Synch_HTTP_Handler_Factory (), -1); - else - ACE_NEW_RETURN (f, No_Cache_Synch_HTTP_Handler_Factory (), -1); + if (this->caching_) + ACE_NEW_RETURN (f, Synch_HTTP_Handler_Factory (), -1); + else + ACE_NEW_RETURN (f, No_Cache_Synch_HTTP_Handler_Factory (), -1); //NOTE: At this point f better not be a NULL pointer, //so please do not change the ACE_NEW_RETURN macros unless @@ -198,10 +198,10 @@ HTTP_Server::synch_thread_pool (HTTP_Handler_Factory &factory) Synch_Thread_Pool_Task::Synch_Thread_Pool_Task (HTTP_Acceptor &acceptor, ACE_Thread_Manager &tm, int threads, - HTTP_Handler_Factory &factory) + HTTP_Handler_Factory &factory) : ACE_Task<ACE_NULL_SYNCH> (&tm), acceptor_ (acceptor), - factory_ (factory) + factory_ (factory) { if (this->activate (THR_DETACHED | THR_NEW_LWP, threads) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -271,36 +271,36 @@ HTTP_Server::thread_per_request (HTTP_Handler_Factory &factory) ACE_NEW_RETURN (t, Thread_Per_Request_Task (stream.get_handle (), this->tm_, grp_id, - factory), + factory), -1); if (t->open () != 0) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Thread_Per_Request_Task::open")), -1); // Throttling is not allowing too many threads to run away. // Should really use some sort of condition variable here. if (!this->throttle_) - continue; + continue; // 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->tm_.wait (&wait_time); } ACE_NOTREACHED(return 0); } Thread_Per_Request_Task::Thread_Per_Request_Task (ACE_HANDLE handle, - ACE_Thread_Manager &tm, + ACE_Thread_Manager &tm, int &grp_id, - HTTP_Handler_Factory &factory) + HTTP_Handler_Factory &factory) : ACE_Task<ACE_NULL_SYNCH> (&tm), handle_ (handle), grp_id_ (grp_id), - factory_ (factory) + factory_ (factory) { } @@ -343,7 +343,7 @@ int Thread_Per_Request_Task::close (u_long) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" (%t) Thread_Per_Request_Task::svc, dying\n"))); + ACE_TEXT (" (%t) Thread_Per_Request_Task::svc, dying\n"))); delete this; return 0; } @@ -376,7 +376,7 @@ HTTP_Server::asynch_thread_pool (void) // Tell the acceptor to listen on this->port_, which makes an // asynchronous I/O request to the OS. if (acceptor.open (ACE_INET_Addr (this->port_), - HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1) + HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Asynch_Acceptor::open")), -1); diff --git a/ACE/apps/JAWS/server/HTTP_Server.h b/ACE/apps/JAWS/server/HTTP_Server.h index c7afbf729e0..942b1575d77 100644 --- a/ACE/apps/JAWS/server/HTTP_Server.h +++ b/ACE/apps/JAWS/server/HTTP_Server.h @@ -98,7 +98,7 @@ public: Synch_Thread_Pool_Task (HTTP_Acceptor &acceptor, ACE_Thread_Manager &tm, int threads, - HTTP_Handler_Factory &factory); + HTTP_Handler_Factory &factory); virtual int svc (void); private: @@ -121,7 +121,7 @@ public: Thread_Per_Request_Task (ACE_HANDLE handle, ACE_Thread_Manager &tm, int &grp_id, - HTTP_Handler_Factory &factory); + HTTP_Handler_Factory &factory); virtual int open (void *args = 0); virtual int close (u_long); virtual int svc (void); diff --git a/ACE/apps/JAWS/stress_testing/benchd.cpp b/ACE/apps/JAWS/stress_testing/benchd.cpp index da657813e09..02209a12a13 100644 --- a/ACE/apps/JAWS/stress_testing/benchd.cpp +++ b/ACE/apps/JAWS/stress_testing/benchd.cpp @@ -36,9 +36,9 @@ class Handle_Events : public ACE_Event_Handler { public: Handle_Events (u_short udp_port, - const char *ip_addr, - const char *interface_, - ACE_Reactor &reactor); + const char *ip_addr, + const char *interface_, + ACE_Reactor &reactor); ~Handle_Events (void); virtual int handle_input (ACE_HANDLE); @@ -59,16 +59,16 @@ Handle_Events::handle_input (ACE_HANDLE h) { int readresult = ACE_OS::read (h, buf, BUFSIZ); if (readresult > 0) - { - if (this->mcast_.send (buf, readresult) != readresult) - { - ACE_OS::perror ("send error"); - return -1; - } - return 0; - } + { + if (this->mcast_.send (buf, readresult) != readresult) + { + ACE_OS::perror ("send error"); + return -1; + } + return 0; + } else if (readresult == -1) - ACE_OS::perror ("can't read from STDIN"); + ACE_OS::perror ("can't read from STDIN"); return -1; } @@ -80,15 +80,15 @@ Handle_Events::handle_input (ACE_HANDLE h) int retcode = this->mcast_.recv (buf, sizeof buf, remote_addr); if (retcode != -1) - { + { /* cout << "received datagram from host " << remote_addr.get_host_name () << " on port " << remote_addr.get_port_number () << " bytes = " << retcode << endl; */ serve (buf); - return 0; - } + return 0; + } ACE_OS::perror ("Something amiss."); return -1; @@ -114,9 +114,9 @@ Handle_Events::~Handle_Events (void) } Handle_Events::Handle_Events (u_short udp_port, - const char *ip_addr, - const char *interface_, - ACE_Reactor &reactor) + const char *ip_addr, + const char *interface_, + ACE_Reactor &reactor) { // Create multicast address to listen on. @@ -138,8 +138,8 @@ Handle_Events::Handle_Events (u_short udp_port, // Register callbacks with the ACE_Reactor. if (reactor.register_handler (this->handle_set_, - this, - ACE_Event_Handler::READ_MASK) == -1) + this, + ACE_Event_Handler::READ_MASK) == -1) ACE_OS::perror ("can't register events"), ACE_OS::exit (1); } @@ -185,13 +185,13 @@ parse_args (int argc, char *argv[]) case 'q': QUIET = 1; case 'i': - INTERFACE = get_opt.opt_arg (); - break; + INTERFACE = get_opt.opt_arg (); + break; case 'u': - // Usage fallthrough. + // Usage fallthrough. default: ACE_DEBUG ((LM_DEBUG, "%s -i interface\n", argv[0])); - ACE_OS::exit (1); + ACE_OS::exit (1); } } @@ -235,7 +235,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_ERROR ((LM_ERROR, "error: %s must be run on a platform that support IP multicast\n", - argv[0])); + argv[0])); return 0; } #endif /* ACE_HAS_IP_MULTICAST */ diff --git a/ACE/apps/JAWS/stress_testing/connection.cpp b/ACE/apps/JAWS/stress_testing/connection.cpp index c81ae2fba53..5089fe987ac 100644 --- a/ACE/apps/JAWS/stress_testing/connection.cpp +++ b/ACE/apps/JAWS/stress_testing/connection.cpp @@ -8,22 +8,22 @@ ACE_RCSID(stress_testing, connection, "$Id$") int connection::connect(char *hostname_opt_port, int tcp_nodelay, int sockbufsiz) { if(!hostname_opt_port) return 1; - + char *hostname_with_port; // Check to see if portnumber is specified in the hostnameport // If not, append :80 if(!ACE_OS::strchr(hostname_opt_port,':')) { - hostname_with_port = new char[ACE_OS::strlen(hostname_opt_port) + 3]; - ACE_OS::sprintf(hostname_with_port, "%s:%d", hostname_opt_port, 80); + hostname_with_port = new char[ACE_OS::strlen(hostname_opt_port) + 3]; + ACE_OS::sprintf(hostname_with_port, "%s:%d", hostname_opt_port, 80); } else { hostname_with_port = hostname_opt_port; } - + // Beyond this point, hostname_with_port is of the form hostname:port ACE_INET_Addr server_addr(hostname_with_port); - + // Connect to server ACE_SOCK_Connector con; @@ -33,34 +33,34 @@ int connection::connect(char *hostname_opt_port, int tcp_nodelay, int sockbufsiz return 1; } - + // tcp_nodelay processing. // turn off weird ack things if(tcp_nodelay) { - struct protoent *p = ACE_OS::getprotobyname ("tcp"); + struct protoent *p = ACE_OS::getprotobyname ("tcp"); int one = 1; - + if (p && stream_.set_option (p->p_proto, - TCP_NODELAY, - (char *)& one, - sizeof (one))) + TCP_NODELAY, + (char *)& one, + sizeof (one))) { ACE_OS::perror("tcp_nodelay"); return 1; } } - - if(sockbufsiz) + + if(sockbufsiz) if (stream_.set_option (SOL_SOCKET, - SO_RCVBUF, - (char *) &sockbufsiz, - sizeof sockbufsiz) == -1) + SO_RCVBUF, + (char *) &sockbufsiz, + sizeof sockbufsiz) == -1) { ACE_OS::perror("socket_queue_size"); return 1; } - + return 0; } @@ -94,7 +94,7 @@ int connection::close(void) { stream_.close(); return 0; } - + connection::~connection(void) { this->close(); } diff --git a/ACE/apps/JAWS/stress_testing/http_tester.cpp b/ACE/apps/JAWS/stress_testing/http_tester.cpp index 199bfa33e19..b86dda0605d 100644 --- a/ACE/apps/JAWS/stress_testing/http_tester.cpp +++ b/ACE/apps/JAWS/stress_testing/http_tester.cpp @@ -160,11 +160,11 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) while(!feof(fp)) { - fscanf(fp,"%s %d %f %s %f %s %f %s %f %d %d\n", id, &total_num, &rate, url1, &p1, url2, &p2, url3, &p3, &tcp, &sock); - if (id[0] == '#') continue; - ACE_OS::fprintf(stderr,"----\n"); - ACE_OS::fprintf(stderr,"\tNow performing experiment:%s\n\tSending %d requests at %f requests/second\n", id, total_num, rate); - driver(id, total_num, rate, url1, p1, url2, p2, url3, p3, tcp, sock); + fscanf(fp,"%s %d %f %s %f %s %f %s %f %d %d\n", id, &total_num, &rate, url1, &p1, url2, &p2, url3, &p3, &tcp, &sock); + if (id[0] == '#') continue; + ACE_OS::fprintf(stderr,"----\n"); + ACE_OS::fprintf(stderr,"\tNow performing experiment:%s\n\tSending %d requests at %f requests/second\n", id, total_num, rate); + driver(id, total_num, rate, url1, p1, url2, p2, url3, p3, tcp, sock); } ACE_OS::fclose(fp); ACE_OS::close(fd); |