diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-28 13:15:55 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-28 13:15:55 +0000 |
commit | c4303cadb6348da1f5a0b0f91515f4b80edf69fd (patch) | |
tree | 6e69a5fef2a833cd0cc018e3cb35b28fb7381c03 | |
parent | 72af31ee073fef94f8ea7b10726bda2c36163f03 (diff) | |
download | ATCD-c4303cadb6348da1f5a0b0f91515f4b80edf69fd.tar.gz |
merged main trunk (V 4.2.3) changes
80 files changed, 1917 insertions, 1453 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a index 50e89471d5d..d0bdd281964 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,3 +1,277 @@ +Tue May 27 18:26:51 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + + * ace/config-hpux-10.x-decthreads.h: Added support for HP/UX 10.10 + with DCE threads. Thanks to Shankar Krishnamoorthy + <kshankar@lucent.com> for these fixes. + + * ace/Local_Tokens_T.h: #if def'd out all of this file since it + doesn't seem to be used anymore. Thanks to Shankar + Krishnamoorthy <kshankar@lucent.com> for reporting this. + + * ace/Makefile (TEMPLATE_FILES): Removed Local_Tokens_T since it + doesn't appear to be used anywhere. + +Tue May 27 18:47:34 1997 James C Hu <jxh@lambada.cs.wustl.edu> + + * tests/*.cpp: Various changes for EBCIDIC compatibility. + Thanks to Chuck Gehr for pointing out the need for this! + + * tests/test_config.h: Added ACE_ALPHABET to aid a-z sending and + comparing. + +Tue May 27 15:03:25 1997 David L. Levine <levine@cs.wustl.edu> + + * tests/Future_Test.cpp: added ACE_Future{_Rep}<int> template + specializations. + +Tue May 27 07:49:03 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Future.cpp: Made a few minor reformatting changes to Per's + new Future enhancements. + +Tue May 27 14:19:14 1997 Per Andersson <Per.Andersson@hfera.ericsson.se> + + * ace/Future: Fixed self assignment bug in ACE_Future<>::operator=(). + Fixed bug in ACE_Future<>::set(). It is now possible to do a + ACE_Future<>::set() followed by a ACE_Future<>::get() without + hanging forever. + + Moved all handling of the ACE_Future_Rep<> reference count + into three new static ACE_Future_Rep<> member functions, + create, attach, assign and detach. + + Removed one mutex from ACE_Future_Rep<> by changing the + reference count from an ACE_Atomic_Op<int> into a plain + int. The ACE_Future_Rep<>::value_ready_mutex_ mutex is + instead used for serializing changes to the reference count. + (ACE_Future_Rep<>::attach, ACE_Future_Rep<>::detach()) + + Removed mutex from ACE_Future<> the serialization is + performed by the ACE_Future_Rep<>::attach, + ACE_Future_Rep<>::detach() and ACE_Future_Rep<>::assign() + functions. + + Changed the ACE_Future<> default constructor to always + create a ACE_Future_Rep<> + + * tests/Future_Test.cpp: Added test case for + ACE_Future<>::set() followed by ACE_Future<>::get(). Added + test for working ACE_Future::operator=(). The test is not + fool proof but it crashes or hangs the test process with the + old ACE_Future<> implementation. + +Mon May 26 14:19:14 1997 James C Hu <jxh@polka.cs.wustl.edu> + + * ace/OS.{h,i}: Fixed difftime implementation for cases where + systems implement it as a macro. Fixed tempnam by adding + ACE_LACKS_TEMPNAM. + +Sun May 25 11:36:22 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + + * examples/Reactor/Misc: Removed test_handle_set.cpp since it + is now completed subsumed by tests/Handle_Set_Test.cpp. + + * tests/Handle_Set_Test.cpp: Updated the test of + the ACE_Handle_Set so that it shows how fast the iterator works. + + * ace/Reactor.cpp: Updated the Reactor to use the new + ACE_Handle_Set_Iterator (whic no longer requires calling + operator++ to advance the iterator). + + * ace/Handle_Set: Rewrote the ACE_Handle_Set_Iterator to speed it up. + The result seems to be about 15% faster than the original. + + * ace/OS.h: Changed the MSB_MASK static constant into a macro and + moved it from Handle_Set.cpp into OS.h, changing its name to + ACE_MSB_MASK. + + * ace/Sched_Params.cpp (priority_max): Added another #ifdef for + Chorus. Thanks to Wei Chiang for reporting this. + + * include/makeinclude/platform_sunos5_sunc++_orbix.GNU: added -l + in front of orbixmt. Thanks to Wei Chiang for pointing this + out. + + * ace/ACE.cpp: Changed the default port for NT so that it starts + at 65279 rather than 65535. Hopefully, this will fix that + annoying bug that has been plaguing us on NT 4.0 for months. + Thanks to Goran Lowkrantz <Goran.Lowkrantz@Infologigruppen.se> + for reporting this. + +Sat May 24 23:42:32 1997 David L. Levine <levine@cs.wustl.edu> + + * performance-tests/Misc/test_naming.cpp (do_testing): replaced + strlen () calls in character array size with constant expression. + +Sat May 24 12:07:48 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + + * Released version 4.2.1 for testing. + + * ace/Reactor.cpp (bind): Fixed a stupid typo where I was using + the ACE_REACTOR_EVENT_HANDLER macro instead of the + ACE_REACTOR_HANDLE macro. Thanks to Detlef for reporting this. + + * ace/OS.i: Added a new macro called ACE_HAS_THR_MINSTACK to deal + with weirdo mangling of names by Tandem. Thanks to Jan Perman + <uabjjpp@osd.ericsson.se> for reporting this. + + * ace/OS.h: Added a new macro ACE_LACKS_PRI_T for those platforms + using STHREADS (e.g., Tandem NonStop OS) that don't have pri_t + defined. Thanks to Jan Perman <uabjjpp@osd.ericsson.se> for + reporting this. + + * ace/Connector.cpp (connect): Make sure to save/restore errno + since svc_handler->close() may change it. Thanks to Michael + Hartman <c62nt57@ibx.com> for reporting this. + + * include/makeinclude/platform_chorus.GNU: Added a new platform + macros file for Chorus. Thanks to Wei Chang for this. + + * ace/OS.cpp (sched_params): Reordered the #ifdefs so that Chorus + comes first. + + * ace/OS.i (sleep): If the platform defines ACE_HAS_CLOCK_GETTIME + then we'll use the nanosleep() method rather than sleep(). + + * ace/OS.h: disabled THR_NEW_LWP for Chorus. Thanks to Wei Chang + for reporting this. + + * ace/Sched_Params.cpp: ACE_SCHED_OTHER and ACE_SCHED_RR have the + same value on Chorus. Thanks to Wei Chang for reporting this. + +Sat May 24 09:21:08 1997 David L. Levine <levine@cs.wustl.edu> + + * netsvcs/lib/Server_Logging_Handler.cpp: protected second + ACE_Svc_Handler specialization for case that ACE_HAS_THREADS, + when ACE_HAS_TLI. It had gotten lost in the last pass of + that module. Thanks to Sandro Doro <doros@aureus.sublink.org> + for reporting this problem. + +Sat May 24 03:19:38 1997 Nanbor Wang <nw1@dingo.wolfpack.cs.wustl.edu> + + * ace/OS.i (sigaddset, sigdelset, sigemptyset, sigfillset, + sigismember): Modified the implementation of these function so + as to conform with POSIX standard. Basically all functions do + the same things they did but more conservative protections are + added. The modified semantic becomes, + + sigemptyset, sigfillset, sigaddset, sigdelset: return 0 if + succeed, -1 otherwise. + sigismember: returns 0 if signum is not in the set, 1 if signum + is in the set, and -1 if error occurs. + + If error occured, errno will be set to one of the following + value: + EFAULT: sigset is not a valid address. + EINVAL: signum is not a valid signal number. + + Notice that, so far, this is for NT only. + +Sat May 24 01:53:22 1997 James C Hu <jxh@polka.cs.wustl.edu> + + * performance-tests/Misc/test_naming.cpp (do_testing): Thanks to + Sandro Doro, squashed a bug where we were trying to concatenate + onto a string constant. + +Fri May 23 01:01:01 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/config-hpux-9.x.h: Added + + #define ACE_HAS_BROKEN_ENUMS + #define ACE_HAS_IP_MULTICAST + #define ACE_LACKS_GETPGID + + Thanks to Neil Cohen for reporting these. + + * ace/Thread_Manager.h: Made the private methods and data members + protected so that subclasses can extend it. Thanks to Hamutal + Yanay for this suggestion. + +Fri May 23 21:27:05 1997 David L. Levine <levine@cs.wustl.edu> + + * ace/Process.{h,cpp} (env_argv): added "const" to char * type in + return type, for argument compatibility in call to ACE_OS::execve (). + + * ace/Process.cpp (spawn): removed unreachable return statement at + end of function. + + Thanks to Dave Mayerhoefer <mayerhoefer@svappl36.mdc.com> for + reporting the above two problems. + + * ace/{IOStream*,Makefile}: Split out templates into + ace/IOStream_T.{h,cpp} files. This way, automatic template + instantiation systems that require templates to be in separate + files, such as on Irix 6.2, will be able to build IOStream_Test + and the ACE_IOStream examples without warnings. (The + ACE_IOSTREAM_BUILDING_TEMPLATE macro that did this only worked + if ACE_TEMPLATES_REQUIRE_SOURCE was defined. It's no longer + needed with the separate template files.) + + * tests/IOStream_Test.cpp, + examples/IOStream/client/iostream_client.cpp, + examples/IOStream/server/iostream_server.cpp: + swapped ACE_Streambuf and ACE_Streambuf_T class names so that + the template class has the "_T". And renamed ACE_IOStream_T + for consistency. + + * ace/{IOStream.*,README}, + tests/IOStream_Test.cpp, + examples/IOStream/client/iostream_client.cpp, + examples/IOStream/server/iostream_server.cpp, + config-hpux-9.x*.h: + Added ACE_LACKS_ACE_IOSTREAM protection + so that these can easily be built on platforms that have + trouble with ACE_IOStream. + + * Priority_Task_Test.cpp: removed close () because it didn't really + close the Task, and added printout to main () after all tasks have + been spawned to help debug non-termination. + + * ace/OS.cpp: (thr_create, with STHREADS only): *thr_handle was + used but *thr_id had been set by ::thr_create, so threads never + got activated. Fixed by using *thr_id instead of *thr_handle + in the calls to ACE_OS::thr_setprio and ACE_OS::continue. + Thanks to Jan Perman <uabjjpp@osd.ericsson.se> for reporting + this problem. + +Fri May 23 20:12:33 1997 James C Hu <jxh@polka.cs.wustl.edu> + + * tests/SV_Shared_Memory_Test.cpp: Thanks to Chuck Gehr, fixed + ASCII dependent code in the parent and child routines. + +Fri May 23 02:58:28 1997 Nanbor Wang <nw1@siesta.cs.wustl.edu> + + * ace/OS.i (dlsym): Added ACE_USES_ASM_SYMBOL_IN_DLSYM, support + for platforms (FreeBSD) which use assembly symbols instead of C + symbols in dlsym (). + + * ace/config-freebsd[-pthread].h: Added flag ACE_HAS_CHARPTR_DL + and ACE_USES_ASM_SYMBOL_IN_DLSYM. + +Thu May 22 08:14:21 1997 David L. Levine <levine@cs.wustl.edu> + + * tests/Tokens_Test.cpp: added deletes to avoid memory leaks. + +Wed May 21 16:15:48 1997 David L. Levine <levine@cs.wustl.edu> + + * ace/{config-irix6.2*.h,README}: removed ACE_LACKS_IOSTREAM_SETGET + because tests won't build with it. Also, added + ACE_LACKS_SIGNED_CHAR. + + * ace/IOStream.h: removed "const" from PUT_PROT of + u_char * and void *. This should allow the IOStream test + and examples to build and run on Irix platforms. Thanks + to Torbjorn Lindgren <tl@funcom.com> and Amos Shapira + <amos@dsi.co.il> for reporting this, and to James Hu for + helping fix it. + + * ace/{OS.cpp,Sched_Params.cp} (Solaris only): use 0 min priority + again, with workaround in ACE_OS::thr_create to not use + ::pthread_attr_setschedparam () if the priority is 0. Instead, + the priority of the newly created thread is set to 0 (if it + wasn't created with 0) after the thread is created, with + ::pthread_setschedparam (). + Wed May 21 15:23:37 1997 Chris Cleeland <cleeland@cs.wustl.edu> * ace/Strategies_T.* (ACE_Hash_Addr): Eliminated the ADDR_T @@ -490,7 +490,6 @@ Scott Halstead <scott.halstead@gs.com> Jean-Marc Strauss <strauss@club-internet.fr> Adam Porter <aporter@cs.umd.edu> Hakan Kallberg <hk@simulina.se> -Carlos O'Ryan <coryan@mat.puc.cl> Eric Dean Russell <edrusse@somnet.sandia.gov> Daniel Montalibet <daniel_montalibet@stortek.com> Norbert Rapp <norbert.rapp@nexus-informatics.de> @@ -515,6 +514,8 @@ Satoshi Ueno <satoshi.ueno@gs.com> Eugene R. Somdahl <gene@endo.com> Robert Head <rhead@mail.virtc.com> Ivan Murphy <Ivan.Murphy@med.siemens.de> +Jan Perman <uabjjpp@osd.ericsson.se> +Shankar Krishnamoorthy <kshankar@lucent.com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 24de03dbd1f..be704168457 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,61 @@ +Wed May 23 14:39:01 1997 Brian Mendel <bmendel@mdc.com> + + * IIOP/lib/objtable.{h,cpp}: Added template specialization of + ACE_Hash_Map_Manager for char*'s. + + * IIOP/test/cubitS.cpp: Fixed type_id to be of type CORBA_String_var. + Also, added a debug msg to print the object address to show the + object for which the request is made. + + * IIOP/test/svr.cpp: Added capability to create multiple Cubit + objects via command line options. Added -n for number of objects and + -k for specifying a base name. For instance, -k Beevis -n 2 creates + Beevis1 and Beevis2 objects. The clnt can then specify a specific + object for the request as usual. + +Wed May 22 12:28:45 1997 Brian Mendel <bmendel@mdc.com> + + * IIOP/test/clnt.cpp: Deleted VxWorks specific sections. Command + line is now working for VxWorks. + * IIOP/test/svr.cpp: Deleted VxWOrks specific sections. Command line + is now working for VxWorks. + +Wed May 22 11:31:42 1997 Chris Cleeland <cleeland@cs.wustl.edu> + + * IIOP/test/svr.cpp: Added better error checking and messages, and + performed general re-formatting. + + * IIOP/test/method_db.i (initialize_method_db): Changed arg type + to use a pointer to the abstract class TAO_Operation_Table. + + * IIOP/test/cubitS.cpp (_skel_Cubit::_skel_Cubit): Added better + error checking and messages. Also defaulted to use the linear + object table implementation rather than the hashed to simplify + debugging. + + * IIOP/test/clnt.cpp: Moved some code around so that more of the + code is common is less is specific to VxWorks and other platforms. + Also did general re-formatting. + + * IIOP/lib/optable.cpp (TAO_Linear_OpTable::find): Initialization + of the loop variable makes the loop work properly. + + * IIOP/lib/objtable.cpp (TAO_Dynamic_Hash_ObjTable::find): + Explicitly specified length of object key in CTOR for ACE_CString + because object keys are not zero-terminated. + + * IIOP/lib/giop.cpp: Added newlines to the end of all ACE_DEBUG() + messages. + + * IIOP/lib/factories.cpp: Added template specializations for + ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>. + +Tue May 22 09:32:41 1997 Brian Mendel <bmendel@mdc.com> + + * IIOP/lib/cdr.h: Deleted #define old_value ACE_INLINE and + #define ACE_INLINE old_value lines. Added #undefs for ACE_INLINE + prior to redefines. Changes required to compile on Windows NT. + Tue May 20 14:47:46 1997 Chris Cleeland <cleeland@cs.wustl.edu> * IIOP/test/cubitS.h: Removed forward decl of diff --git a/TAO/IIOP/lib/cdr.h b/TAO/IIOP/lib/cdr.h index 00cf5597d4d..1b48b18f2be 100644 --- a/TAO/IIOP/lib/cdr.h +++ b/TAO/IIOP/lib/cdr.h @@ -275,7 +275,6 @@ struct ACE_Svc_Export CDR // at creating typecode interpreters as well as to the ACE convention // of placing inline functions into separate files. # if !defined(__ACE_INLINE__) -# define old_value ACE_INLINE # undef ACE_INLINE # define ACE_INLINE inline # define do_undef_on_ACE_INLINE @@ -286,9 +285,7 @@ struct ACE_Svc_Export CDR # if defined(do_undef_on_ACE_INLINE) # undef do_undef_on_ACE_INLINE # undef ACE_INLINE -# define ACE_INLINE old_value -# undef old_value -# undef do_undef_on_ACE_INLINE +# define ACE_INLINE # endif #endif /* TAO_CDR_H */ diff --git a/TAO/IIOP/lib/factories.cpp b/TAO/IIOP/lib/factories.cpp index 98795912434..93b46e84fe0 100644 --- a/TAO/IIOP/lib/factories.cpp +++ b/TAO/IIOP/lib/factories.cpp @@ -4,6 +4,22 @@ # include "factories.i" #endif +// Template specializations which allow the cached connection manager +// to work better. + +size_t +ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>::hash_i (const ACE_INET_Addr &addr) const +{ + return addr.get_ip_address () + addr.get_port_number (); +} + +int +ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>::compare_i (const ACE_INET_Addr &a1, + const ACE_INET_Addr &a2) const +{ + return a1 != a2; +} + int TAO_Client_Connection_Handler::open(void *) { diff --git a/TAO/IIOP/lib/giop.cpp b/TAO/IIOP/lib/giop.cpp index 536c9ae023e..3d37e3a19f0 100644 --- a/TAO/IIOP/lib/giop.cpp +++ b/TAO/IIOP/lib/giop.cpp @@ -115,7 +115,7 @@ dump_msg (const char *label, (ptr[7] <= GIOP::MessageError) ? names [ptr[7]] : "UNKNOWN TYPE")); if (TAO_debug_level >= 4) - ACE_HEX_DUMP ((LM_DEBUG, (const char*)ptr, len, "(%P|%t) data bytes")); + ACE_HEX_DUMP ((LM_DEBUG, (const char*)ptr, len, "(%P|%t) data bytes\n")); } } @@ -188,15 +188,15 @@ GIOP::send_message (CDR &stream, if (writelen == -1) { - ACE_DEBUG ((LM_ERROR, "(%P|%t) OutgoingMessage::writebuf() $p")); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) closing conn %d after fault", connection)); + ACE_DEBUG ((LM_ERROR, "(%P|%t) OutgoingMessage::writebuf() $p\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) closing conn %d after fault\n", connection)); ACE_OS::closesocket (connection); connection = ACE_INVALID_HANDLE; return CORBA_B_FALSE; } else if (writelen == 0) { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) OutgoingMessage::writebuf () ... EOF, closing conn %d", connection)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) OutgoingMessage::writebuf () ... EOF, closing conn %d\n", connection)); ACE_OS::closesocket (connection); connection = ACE_INVALID_HANDLE; return CORBA_B_FALSE; @@ -265,7 +265,7 @@ GIOP::close_connection (ACE_HANDLE &handle, (void) ACE::send (handle, close_message, TAO_GIOP_HEADER_LEN); (void) ACE_OS::shutdown (handle, 2); (void) ACE_OS::closesocket (handle); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) shut down socket %d", handle)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) shut down socket %d\n", handle)); handle = ACE_INVALID_HANDLE; } @@ -293,7 +293,7 @@ send_error (ACE_HANDLE &handle) (void) ACE::send (handle, error_message, TAO_GIOP_HEADER_LEN); (void) ACE_OS::shutdown (handle, 2); (void) ACE_OS::closesocket (handle); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) aborted socket %d", handle)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) aborted socket %d\n", handle)); handle = ACE_INVALID_HANDLE; } @@ -400,7 +400,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection, { if (len == 0) { // EOF - ACE_DEBUG ((LM_DEBUG, "(%P|%t) Header EOF ... peer probably aborted connection %d", + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Header EOF ... peer probably aborted connection %d\n", connection.get_handle())); return EndOfFile; // XXX should probably find some way to report this without @@ -409,9 +409,9 @@ GIOP::read_message (ACE_SOCK_Stream &connection, // } else if (len < 0) // error - ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header socket error %p")); + ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header socket error %p\n")); else // short read ... - ACE_DEBUG ((LM_ERROR, "(%P|%t) read message header failed (short)")); + ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header failed (short)\n")); env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE)); return MessageError; @@ -429,7 +429,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection, && msg.buffer [3] == 'P')) { env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); // header - ACE_DEBUG((LM_DEBUG, "bad header, magic word")); + ACE_DEBUG((LM_DEBUG, "bad header, magic word\n")); return MessageError; } @@ -439,7 +439,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection, if (!(msg.buffer [4] == MY_MAJOR && msg.buffer [5] <= MY_MINOR)) { env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); // header - ACE_DEBUG((LM_DEBUG, "bad header, version")); + ACE_DEBUG((LM_DEBUG, "bad header, version\n")); return MessageError; } @@ -476,15 +476,15 @@ GIOP::read_message (ACE_SOCK_Stream &connection, if (len != (int) message_size) { if (len == 0) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) read message body, EOF on handle %d", connection.get_handle())); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) GIOP::read_message body, EOF on handle %d\n", connection.get_handle())); else if (len < 0) - ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message () body %p")); + ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message () body %p\n")); else - ACE_DEBUG ((LM_ERROR, "(%P|%t) short read, only %d of %d bytes", len, message_size)); + ACE_DEBUG ((LM_ERROR, "(%P|%t) short read, only %d of %d bytes\n", len, message_size)); // clean up, and ... env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE)); // body - ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message")); + ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message\n")); return MessageError; } @@ -880,7 +880,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions, // be indicative of client bugs (lost track of input stream) or // server bugs; maybe the request was acted on, maybe not, we // can't tell. - ACE_DEBUG((LM_DEBUG, "(%P|%t) illegal message in response to my Request!")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) illegal message in response to my Request!\n")); env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE)); // FALLTHROUGH ... @@ -935,7 +935,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions, { send_error (handler_->peer()); env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE)); - ACE_DEBUG((LM_DEBUG, "(%P|%t) bad Response header")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) bad Response header\n")); return SYSTEM_EXCEPTION; } @@ -1038,7 +1038,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions, != CORBA_TypeCode::TRAVERSE_CONTINUE) { delete exception; - ACE_DEBUG((LM_ERROR, "(%P|%t) invoke, unmarshal %s exception %s", + ACE_DEBUG((LM_ERROR, "(%P|%t) invoke, unmarshal %s exception %s\n", (reply_status == USER_EXCEPTION) ? "user" : "system", exception_id)); send_error (handler_->peer()); @@ -1163,7 +1163,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, case LocateReply: case CloseConnection: default: // Unknown message - ACE_DEBUG((LM_DEBUG, "(%P|%t) Illegal message received by server")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) Illegal message received by server\n")); env.exception (new CORBA_COMM_FAILURE (COMPLETED_NO)); // FALLTHROUGH @@ -1229,20 +1229,20 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, #ifdef DEBUG if (TAO_debug_level >= 3) { - ACE_DEBUG((LM_DEBUG, "(%P|%t) %sRequest ID %#lx from FD %d", + ACE_DEBUG((LM_DEBUG, "(%P|%t) %sRequest ID %#lx from FD %d\n", req.response_expected ? "" : "Oneway ", req.request_id, peer.get_handle ())); if (TAO_debug_level >= 4) { ACE_HEX_DUMP((LM_DEBUG, (char*)req.object_key.buffer, - req.object_key.length, "(%P|%t) object key")); - ACE_DEBUG((LM_DEBUG, "(%P|%t) opname '%s'", req.operation)); + req.object_key.length, "(%P|%t) object key\n")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) opname '%s'\n", req.operation)); if (req.requesting_principal) ACE_HEX_DUMP((LM_DEBUG, (char*)req.requesting_principal->id.buffer, req.requesting_principal->id.length, - "(%P|%t) client principal")); + "(%P|%t) client principal\n")); else - ACE_DEBUG((LM_DEBUG, "(%P|%t) client principal (EMPTY)")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) client principal (EMPTY)\n")); } // NOTE: describe any service context, and how many bytes @@ -1287,7 +1287,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, } else if (status == OBJECT_FORWARD) { - ACE_DEBUG((LM_DEBUG, "(%P|%t) forwarding Request message")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) forwarding Request message\n")); response.put_ulong (LOCATION_FORWARD); CDR::encoder (_tc_CORBA_Object, &fwd_ref, @@ -1375,7 +1375,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, if (check_forward == 0) { response.put_ulong (OBJECT_HERE); - ACE_DEBUG((LM_DEBUG, "(%P|%t) LocateRequest response: object is (always) here!")); + ACE_DEBUG((LM_DEBUG, "(%P|%t) LocateRequest response: object is (always) here!\n")); } else { @@ -1386,14 +1386,14 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer, if (status == OBJECT_FORWARD) { - ACE_DEBUG((LM_DEBUG, "LocateRequest response: forward requests")); + ACE_DEBUG((LM_DEBUG, "LocateRequest response: forward requests\n")); CDR::encoder (_tc_CORBA_Object, &fwd_ref, 0, &response, env); } else if (status == OBJECT_HERE) - ACE_DEBUG((LM_DEBUG, "LocateRequest response: object is here!")); + ACE_DEBUG((LM_DEBUG, "LocateRequest response: object is here!\n")); else - ACE_DEBUG((LM_DEBUG, "LocateRequest response: no such object")); + ACE_DEBUG((LM_DEBUG, "LocateRequest response: no such object\n")); } (void) send_message (response, peer); } diff --git a/TAO/IIOP/lib/objtable.cpp b/TAO/IIOP/lib/objtable.cpp index 132c3032bf1..c1d4a805cf2 100644 --- a/TAO/IIOP/lib/objtable.cpp +++ b/TAO/IIOP/lib/objtable.cpp @@ -1,5 +1,18 @@ #include "objtable.h" +// Template Specialization for char* +int ACE_Hash_Map_Manager<const char*, CORBA_Object_ptr,ACE_SYNCH_RW_MUTEX>::equal(const char* const&id1, + const char* const&id2) +{ + return strcmp(id1, id2) == 0; +} + +// Template Specialization for char* +size_t ACE_Hash_Map_Manager<const char*, CORBA_Object_ptr,ACE_SYNCH_RW_MUTEX>::hash(const char* const&ext_id) +{ + return ACE::hash_pjw (ext_id); +} + TAO_Dynamic_Hash_ObjTable::TAO_Dynamic_Hash_ObjTable (CORBA_ULong size) { if (size > 0) @@ -16,16 +29,17 @@ int TAO_Dynamic_Hash_ObjTable::bind (const CORBA_OctetSeq &key, CORBA_Object_ptr obj) { - ACE_CString objkey ((char *) key.buffer); - return this->hash_.bind (objkey, obj); + ACE_CString objkey ((char *) key.buffer, key.length); + + return this->hash_.bind (objkey.rep(), obj); } int TAO_Dynamic_Hash_ObjTable::find (const CORBA_OctetSeq &key, CORBA_Object_ptr &obj) { - ACE_CString objkey ((char *) key.buffer); - return this->hash_.find (objkey, obj); + ACE_CString objkey ((char *) key.buffer, key.length); + return this->hash_.find (objkey.rep(), obj); } // Linear search strategy. diff --git a/TAO/IIOP/lib/objtable.h b/TAO/IIOP/lib/objtable.h index 0b22086a8f2..d3a7902bcf5 100644 --- a/TAO/IIOP/lib/objtable.h +++ b/TAO/IIOP/lib/objtable.h @@ -26,7 +26,8 @@ # include "orb.h" // Dynamic Hashing scheme. -typedef ACE_Hash_Map_Manager<ACE_CString, CORBA_Object_ptr, ACE_SYNCH_RW_MUTEX> OBJ_MAP_MANAGER; +//typedef ACE_Hash_Map_Manager<ACE_CString, CORBA_Object_ptr, ACE_SYNCH_RW_MUTEX> OBJ_MAP_MANAGER; +typedef ACE_Hash_Map_Manager<const char*, CORBA_Object_ptr, ACE_SYNCH_RW_MUTEX> OBJ_MAP_MANAGER; class TAO_Object_Table // = TITLE diff --git a/TAO/IIOP/lib/optable.cpp b/TAO/IIOP/lib/optable.cpp index 3766fbcf578..d78817b8a47 100644 --- a/TAO/IIOP/lib/optable.cpp +++ b/TAO/IIOP/lib/optable.cpp @@ -70,9 +70,7 @@ TAO_Linear_OpTable::find (const CORBA_String &opname, { ACE_ASSERT (this->next_ <= this->tablesize_); - for (CORBA_ULong i; - i < this->next_; - i++) + for (CORBA_ULong i = 0; i < this->next_; i++) if (!ACE_OS::strncmp (opname, this->tbl_[i].opname, ACE_OS::strlen (opname))) { skel_ptr = this->tbl_[i].skel_ptr; diff --git a/TAO/IIOP/test/clnt.cpp b/TAO/IIOP/test/clnt.cpp index 7a4211d4521..f0249489889 100644 --- a/TAO/IIOP/test/clnt.cpp +++ b/TAO/IIOP/test/clnt.cpp @@ -47,10 +47,8 @@ static void cube_union_dii(unsigned &, unsigned &, CORBA_Object_ptr, CORBA_Environment &); // Global variables -CORBA_ORB_ptr orb_ptr; +const char* TAO_arg_ior = 0; unsigned loop_count = 1; -CORBA_Object_ptr objref = CORBA_Object::_nil(); -CORBA_Environment env; int exit_later = 0; // = TITLE @@ -76,12 +74,7 @@ int parse_args(int argc, char *argv[]) case 'O': // stringified objref { - objref = orb_ptr->string_to_object ( - (CORBA_String)opts.optarg, env); - if (env.exception () != 0) { - print_exception (env.exception (), "string2object"); - return 1; - } + TAO_arg_ior = ACE_OS::strdup(opts.optarg); } continue; @@ -106,258 +99,269 @@ int parse_args(int argc, char *argv[]) int main (int argc, char *argv[]) - { - -#if defined (VXWORKS) - // Work around VxWorks' lack of command line +{ + CORBA_ORB_ptr orb_ptr; + CORBA_Object_ptr objref = CORBA_Object::_nil(); + CORBA_Environment env; - loop_count = 50; - int dummy = 1; - orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env); - if (env.exception() != 0) + orb_ptr = CORBA_ORB_init(argc, argv, "internet", env); + if (env.exception() != 0) { - print_exception(env.exception(), "ORB initialization"); - return 1; + print_exception(env.exception(), "ORB initialization"); + return 1; } - hostAdd( "mv2604d", "130.38.183.132" ); + // + // Parse command line and verify parameters. + // + parse_args(argc, argv); - objref = orb_ptr->string_to_object ( - (CORBA_String)"iiop:1.0//mv2604d:1000/key0", env); -#else + if (TAO_arg_ior == 0) + ACE_ERROR_RETURN((LM_ERROR, "%s: must specify an object reference using -O <ior>\n", argv[0]), 1); - orb_ptr = CORBA_ORB_init(argc, argv, "internet", env); - if (env.exception() != 0) - { - print_exception(env.exception(), "ORB initialization"); - return 1; - } + objref = orb_ptr->string_to_object ((CORBA_String)TAO_arg_ior, env); - // - // Parse command line and verify parameters. - // - parse_args(argc, argv); - -#endif + ACE_OS::free((void*)TAO_arg_ior); + TAO_arg_ior = 0; - if (CORBA_is_nil (objref) == CORBA_B_TRUE) { - ACE_OS::fprintf (stderr, "%s: must identify non-null target objref\n", - argv [0]); - return 1; + if (env.exception () != 0) + { + print_exception (env.exception (), "string2object"); + return 1; } - // Narrow the CORBA_Object reference to the stub object, checking - // the type along the way using _is_a - Cubit_ptr aCubit = Cubit::_narrow(objref); + if (CORBA_is_nil (objref) == CORBA_B_TRUE) + ACE_ERROR_RETURN((LM_ERROR, "%s: must identify non-null target objref\n", argv [0]), 1); - // - // Make the calls in a loop. - // - unsigned i; - unsigned call_count, error_count; + // Narrow the CORBA_Object reference to the stub object, checking + // the type along the way using _is_a + Cubit_ptr aCubit = Cubit::_narrow(objref); + if (aCubit == 0) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"), 1); - call_count = 0; - error_count = 0; + // + // Make the calls in a loop. + // + unsigned i; + unsigned call_count, error_count; - ACE_Time_Value before, after; + call_count = 0; + error_count = 0; - before = ACE_OS::gettimeofday(); + ACE_Time_Value before, after; - for (i = 0; i < loop_count; i++) { - // - // Cube an octet. - // - CORBA_Octet arg_octet, ret_octet; + before = ACE_OS::gettimeofday(); + + for (i = 0; i < loop_count; i++) + { + // + // Cube an octet. + // + CORBA_Octet arg_octet, ret_octet; - call_count++; - ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env); - if (env.exception () != 0) { + call_count++; + ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env); + if (env.exception () != 0) + { print_exception (env.exception (), "from cube_octet"); error_count++; - } else { + } + else + { dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet); arg_octet = arg_octet * arg_octet * arg_octet; if (arg_octet != ret_octet) { - ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n", - (CORBA_Octet) func (i), ret_octet); - error_count++; + ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n", + (CORBA_Octet) func (i), ret_octet); + error_count++; } - } + } - // - // Cube a short. - // - CORBA_Short arg_short, ret_short; + // + // Cube a short. + // + CORBA_Short arg_short, ret_short; - call_count++; - ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env); - if (env.exception () != 0) { + call_count++; + ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env); + if (env.exception () != 0) + { print_exception (env.exception (), "from cube_short"); error_count++; - } else { + } + else + { dmsg2 ("cube short: %d --> %d\n", arg_short, ret_short); arg_short = arg_short * arg_short * arg_short; - if (arg_short != ret_short) { - ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n", - (CORBA_Short) func (i), ret_short); - error_count++; - } - } + if (arg_short != ret_short) + { + ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n", + (CORBA_Short) func (i), ret_short); + error_count++; + } + } - // - // Cube a long. - // - CORBA_Long arg_long, ret_long; + // + // Cube a long. + // + CORBA_Long arg_long, ret_long; - call_count++; - ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env); - if (env.exception () != 0) { + call_count++; + ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env); + if (env.exception () != 0) + { print_exception (env.exception (), "from cube_long"); error_count++; - } else { + } + else + { dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long); arg_long = arg_long * arg_long * arg_long; if (arg_long != ret_long) { - ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n", - (CORBA_Long) func (i), ret_long); - error_count++; + ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n", + (CORBA_Long) func (i), ret_long); + error_count++; } - } + } - // - // Cube a "struct" ... - // - Cubit_Many arg_struct, *ret_struct; + // + // Cube a "struct" ... + // + Cubit_Many arg_struct, *ret_struct; - call_count++; + call_count++; - arg_struct.l = func (i); - arg_struct.s = func (i); - arg_struct.o = func (i); + arg_struct.l = func (i); + arg_struct.s = func (i); + arg_struct.o = func (i); - ret_struct = aCubit->Cubit_cube_struct (arg_struct, env); - if (env.exception () != 0) { + ret_struct = aCubit->Cubit_cube_struct (arg_struct, env); + if (env.exception () != 0) + { print_exception (env.exception (), "from cube_struct"); error_count++; - } else { + } + else + { dmsg ("cube struct ..."); arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l; arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s; arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o; if (arg_struct.l != ret_struct->l - || arg_struct.s != ret_struct->s - || arg_struct.o != ret_struct->o) { - ACE_OS::printf ("** cube_struct ERROR\n"); - error_count++; - } + || arg_struct.s != ret_struct->s + || arg_struct.o != ret_struct->o) + { + ACE_OS::printf ("** cube_struct ERROR\n"); + error_count++; + } delete ret_struct; - } + } } - after = ACE_OS::gettimeofday(); + after = ACE_OS::gettimeofday(); - if (call_count > 0) + if (call_count > 0) { - if (error_count == 0) - { + if (error_count == 0) + { ACE_Time_Value diff = after - before; unsigned long us = diff.sec() * 1000 * 1000 + diff.usec(); us /= call_count; if (us > 0) - ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t" - "%ld calls/second\n", - us / 1000, us % 1000, - 1000000L / us); - } + ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t" + "%ld calls/second\n", + us / 1000, us % 1000, + 1000000L / us); + } - ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count); + ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count); } + // + // Simple test for DII: call "cube_struct". (It's not timed + // since the copious mallocation of DII would bias numbers against + // typical stub-based calls.) + // + do { // - // Simple test for DII: call "cube_struct". (It's not timed - // since the copious mallocation of DII would bias numbers against - // typical stub-based calls.) + // Create the request ... // - do { - // - // Create the request ... - // - CORBA_Request_ptr req; + CORBA_Request_ptr req; - req = objref->_request ((const CORBA_String) "cube_struct", env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request create"); - break; - } - - // - // ... initialise the argument list and result ... - // - Cubit_Many arg, *result; + req = objref->_request ((const CORBA_String) "cube_struct", env); + if (env.exception () != 0) { + print_exception (env.exception (), "DII request create"); + break; + } + + // + // ... initialise the argument list and result ... + // + Cubit_Many arg, *result; - arg.o = 3; arg.l = 5; arg.s = -7; + arg.o = 3; arg.l = 5; arg.s = -7; - CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE); + CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE); - req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request arg add"); - CORBA_release (req); - break; - } + req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env); + if (env.exception () != 0) { + print_exception (env.exception (), "DII request arg add"); + CORBA_release (req); + break; + } - req->result ()->value () - ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env); - if (env.exception () != 0) { - print_exception (env.exception (), "DII request result type"); - CORBA_release (req); - break; - } - - // - // Make the invocation, verify the result - // - req->invoke (); - if (req->env ()->exception () != 0) { - print_exception (req->env ()->exception (), "DII invoke"); - CORBA_release (req); - break; - } + req->result ()->value () + ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env); + if (env.exception () != 0) { + print_exception (env.exception (), "DII request result type"); + CORBA_release (req); + break; + } + + // + // Make the invocation, verify the result + // + req->invoke (); + if (req->env ()->exception () != 0) { + print_exception (req->env ()->exception (), "DII invoke"); + CORBA_release (req); + break; + } - result = (Cubit_Many *) req->result ()->value ()->value (); + result = (Cubit_Many *) req->result ()->value ()->value (); - if (result->o != 27 || result->l != 125 || result->s != -343) - ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n"); - else - dmsg ("DII cube_struct ... success!!"); + if (result->o != 27 || result->l != 125 || result->s != -343) + ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n"); + else + dmsg ("DII cube_struct ... success!!"); - CORBA_release (req); + CORBA_release (req); - } while (0); - - // - // Two more tests, using the "cube_union" function - // - cube_union_dii(call_count, error_count, objref, env); - if (env.exception () != 0) - error_count++; + } while (0); + + // + // Two more tests, using the "cube_union" function + // + cube_union_dii(call_count, error_count, objref, env); + if (env.exception () != 0) + error_count++; - cube_union_stub(i, call_count, error_count, objref, env); - if (env.exception () != 0) - error_count++; + cube_union_stub(i, call_count, error_count, objref, env); + if (env.exception () != 0) + error_count++; - if (exit_later) { - aCubit->Cubit_please_exit (env); - dexc (env, "server, please ACE_OS::exit"); - } + if (exit_later) { + aCubit->Cubit_please_exit (env); + dexc (env, "server, please ACE_OS::exit"); + } - CORBA_release (objref); + CORBA_release (objref); - return (error_count == 0) ? 0 : 1; + return (error_count == 0) ? 0 : 1; } diff --git a/TAO/IIOP/test/cubitS.cpp b/TAO/IIOP/test/cubitS.cpp index 8e3e9864be9..b153b71db1b 100644 --- a/TAO/IIOP/test/cubitS.cpp +++ b/TAO/IIOP/test/cubitS.cpp @@ -16,10 +16,16 @@ #include "method_db.i" #include "iiopobj.h" +#if defined(CUBIT_USE_DYNAMIC_HASH) TAO_Dynamic_Hash_OpTable tao_cubit_optable(7); // Dynamic Operation Table +#else +TAO_Linear_OpTable tao_cubit_optable(7); +#endif _skel_Cubit::_skel_Cubit(const char* obj_name) { + const char* mn = "_skel_Cubit::_skel_Cubit()"; + // Initialize Method Database initialize_method_db (&tao_cubit_optable); @@ -28,6 +34,14 @@ _skel_Cubit::_skel_Cubit(const char* obj_name) IIOP_Object *data; CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa(); + if (oa == 0) + { + // We just have to assume that oa will be good, or we have to + // throw an exception. For now we "assume", but we'll + ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to locate a valid object adapter\n", mn)); + return; + } + this->optable_ = &tao_cubit_optable; data = new IIOP_Object(type_id); @@ -41,14 +55,16 @@ _skel_Cubit::_skel_Cubit(const char* obj_name) ACE_OS::memcpy (data->profile.object_key.buffer, obj_name, - data->profile.object_key.length); + data->profile.object_key.length+1); this->set_parent(data); this->sub_ = this; - if (oa) - oa->bind(data->profile.object_key, this); - + if (oa->bind(data->profile.object_key, this) == -1) + { + ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to bind object to key '%s': %p\n", mn, data->profile.object_key.buffer)); + return; + } } void diff --git a/TAO/IIOP/test/cubit_i.cpp b/TAO/IIOP/test/cubit_i.cpp index 92cf5026fe1..ae22b7cd12c 100644 --- a/TAO/IIOP/test/cubit_i.cpp +++ b/TAO/IIOP/test/cubit_i.cpp @@ -18,7 +18,6 @@ Cubit_i::Cubit_i(const char* obj_name) : _skel_Cubit(obj_name) { - cout << "Cubit_i ident: " << this << endl; } Cubit_i::~Cubit_i() diff --git a/TAO/IIOP/test/method_db.i b/TAO/IIOP/test/method_db.i index b567d09b7af..6b77cdf040a 100644 --- a/TAO/IIOP/test/method_db.i +++ b/TAO/IIOP/test/method_db.i @@ -58,7 +58,7 @@ static const method_db cubit_operations[] = { }; -void initialize_method_db (TAO_Dynamic_Hash_OpTable *the_optable) +void initialize_method_db (TAO_Operation_Table *the_optable) { for (int ndx = 0; ndx < 7; ndx++) the_optable->bind(cubit_operations[ndx].opname, diff --git a/TAO/IIOP/test/svr.cpp b/TAO/IIOP/test/svr.cpp index 4afe2c62cd8..0e537bc6206 100644 --- a/TAO/IIOP/test/svr.cpp +++ b/TAO/IIOP/test/svr.cpp @@ -10,16 +10,61 @@ // Modified version of Cubit Example written by Sun Microsystems Inc. // Modified by: Brian Mendel -#include "cubit_i.h" -#include <ace/Get_Opt.h> +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" #include "corba/orb.h" -#include <corba/debug.h> -#include <connect.h> +#include "corba/debug.h" +#include "connect.h" + +#include "cubit_i.h" extern void print_exception (const CORBA_Exception *, const char *, FILE *f=stdout); +// Global Variables +CORBA_String key = (CORBA_String)"key0"; +int num_of_objs = 1; + +// = TITLE +// Parses the command line arguments and returns an error status +// +// = DESCRIPTION +// This method parses the command line arguments +int parse_args(int argc, char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "dk:n:"); + int c; + + while ((c = opts ()) != -1) + switch (c) { + + case 'd': // debug flag + TAO_debug_level++; + continue; + + case 'k': // key (str) + key = (CORBA_String) opts.optarg; + continue; + + case 'n': // idle seconds b4 exit + num_of_objs = ACE_OS::atoi(opts.optarg); + continue; + + case '?': + default: + ACE_OS::fprintf (stderr, "usage: %s" + " [-d]" + " [-k {object_key}]" + "\n", argv [0] + ); + return 1; + } + + return 0; // Indicates successful parsing of command line +} + + // // Standard command line parsing utilities used. // @@ -27,27 +72,13 @@ int main (int argc, char *argv[]) { CORBA_Environment env; - CORBA_Object_ptr obj; + CORBA_Object_ptr obj = 0; CORBA_ORB_ptr orb_ptr; CORBA_BOA_ptr oa_ptr; - CORBA_String key = (CORBA_String) "key0"; char *orb_name = "internet"; int idle = -1; - int debug_level = 1; - -#if defined (VXWORKS) - - char *oa_name = "mv2604d:1000"; - int dummy = 1; - - orb_ptr = CORBA_ORB_init (dummy, (char **)0, orb_name, env); - -#else orb_ptr = CORBA_ORB_init (argc, argv, orb_name, env); - -#endif - if (env.exception () != 0) { print_exception (env.exception (), "ORB init"); return 1; @@ -55,22 +86,70 @@ main (int argc, char *argv[]) // Initialize the Basic Object Adapter oa_ptr = orb_ptr->BOA_init(argc, argv, "ROA"); + if (oa_ptr == 0) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to initialize the BOA.\n"), 1); + + // + // Parse remaining command line and verify parameters. + // + parse_args(argc, argv); + // Create implementation object with user specified key - Cubit_i_ptr my_cubit = new Cubit_i(key); + Cubit_i_ptr *my_cubit = new Cubit_i_ptr[num_of_objs]; + for (int ndx = 0; ndx < num_of_objs; ndx++) + { + CORBA_String obj_str = CORBA_string_alloc(ACE_OS::strlen ((char *)key)+2); + sprintf(obj_str, "%s%d", (char*)key, ndx); + my_cubit[ndx] = new Cubit_i(obj_str); + if (my_cubit[ndx] == 0) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to create implementation object&d\n", ndx), 2); + + if (TAO_debug_level >= 1) + { + // Why are we getting the BOA_ptr from here when we've already + // got it above? + CORBA_OctetSeq obj_key; + obj_key.buffer = (CORBA_Octet *) obj_str; + obj_key.length = obj_key.maximum = ACE_OS::strlen (obj_str); + + if (oa_ptr->find(obj_key, obj) == -1) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); + + // + // Stringify the objref we'll be implementing, and + // print it to stdout. Someone will take that string + // and give it to some client. Then release the object. + // + CORBA_String str; + + str = orb_ptr->object_to_string (obj, env); + if (env.exception () != 0) { + print_exception (env.exception (), "object2string"); + return 1; + } + ACE_OS::puts ((char *)str); + ACE_OS::fflush (stdout); + dmsg1 ("Object Created at: '%ul'", obj); + dmsg1 ("listening as object '%s'", str); + + } + CORBA_string_free(obj_str); + } +// Cubit_i_ptr my_cubit = new Cubit_i(key); +// if (my_cubit1 == 0) +// ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to create implementation object\n"), 2); - if (debug_level >= 1) +/* if (TAO_debug_level >= 1) { // Why are we getting the BOA_ptr from here when we've already // got it above? - CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa(); CORBA_OctetSeq obj_key; obj_key.buffer = (CORBA_Octet *) key; obj_key.length = obj_key.maximum = ACE_OS::strlen ((char *)key); - if (oa) - (void) oa->find(obj_key, obj); - + if (oa_ptr->find(obj_key, obj) == -1) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); // // Stringify the objref we'll be implementing, and @@ -87,15 +166,27 @@ main (int argc, char *argv[]) ACE_OS::puts ((char *)str); ACE_OS::fflush (stdout); dmsg1 ("listening as object '%s'", str); - } + obj_key.buffer = (CORBA_Octet *)"key1"; + obj_key.length = obj_key.maximum = 4; + if (oa_ptr->find(obj_key, obj) == -1) + ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 3); + + str = orb_ptr->object_to_string (obj, env); + if (env.exception () != 0) { + print_exception (env.exception (), "object2string"); + return 1; + } + ACE_OS::puts ((char *)str); + ACE_OS::fflush (stdout); + dmsg1 ("listening as object '%s'", str); + } +*/ // Handle requests for this object until we're killed, or one of // the methods asks us to exit. // int terminationStatus = 0; - // Insert Object Key into context - // params->context(&obj_key); #if !defined(USE_HOMEBREW_EVENT_LOOP) ACE_Service_Config::run_reactor_event_loop(); @@ -1,4 +1,4 @@ -This is ACE version 4.2, released Wed May 21 14:12:26 CDT 1997. +This is ACE version 4.2.3, released Tue May 27 14:40:34 CDT 1997. If you have any problems with ACE, please send email to Douglas C. Schmidt (schmidt@cs.wustl.edu). diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 2b49dffc42b..4a26b74517c 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -823,8 +823,7 @@ ACE::bind_port (ACE_HANDLE handle) sockaddr_in sin; // This should be a constant, so I hope they never change the number // of bits in a port number! - const u_short MAX_SHORT = 65535; - static u_short upper_limit = MAX_SHORT; + static u_short upper_limit = ACE_MAX_DEFAULT_PORT; int lower_limit = IPPORT_RESERVED; int round_trip = upper_limit; @@ -847,11 +846,11 @@ ACE::bind_port (ACE_HANDLE handle) { upper_limit--; - /* Wrap back around when we reach the bottom. */ + // Wrap back around when we reach the bottom. if (upper_limit <= lower_limit) - upper_limit = MAX_SHORT; + upper_limit = ACE_MAX_DEFAULT_PORT; - /* See if we have already gone around once! */ + // See if we have already gone around once! if (upper_limit == round_trip) { errno = EAGAIN; diff --git a/ace/Connector.cpp b/ace/Connector.cpp index 2ab0ec98708..a5f405de623 100644 --- a/ace/Connector.cpp +++ b/ace/Connector.cpp @@ -361,9 +361,16 @@ ACE_Connector<SH, PR_CO_2>::connect (SH *&sh, this->create_AST (sh, synch_options); } else - // Make sure to close down the Channel to avoid descriptor - // leaks. - sh->close (0); + { + // Make sure to save/restore the errno since <close> may + // change it. + + int error = errno; + // Make sure to close down the Channel to avoid descriptor + // leaks. + sh->close (0); + errno = error; + } return -1; } else diff --git a/ace/Future.cpp b/ace/Future.cpp index 7c5fd9b29af..eccf2ef6e0b 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -17,13 +17,14 @@ ACE_Future_Rep<T>::dump (void) const { ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, - "ref_count_ = %d\n", - (int) this->ref_count_)); + "ref_count_ = %d\n", + (int) this->ref_count_)); ACE_DEBUG ((LM_INFO,"value_: \n")); if (this->value_) ACE_DEBUG ((LM_DEBUG," (NON-NULL)\n")); else ACE_DEBUG ((LM_DEBUG," (NULL)\n")); + ACE_DEBUG ((LM_INFO,"value_ready_: \n")); this->value_ready_.dump (); ACE_DEBUG ((LM_INFO,"value_ready_mutex_: \n")); @@ -31,6 +32,62 @@ ACE_Future_Rep<T>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } +template <class T> ACE_Future_Rep<T> * +ACE_Future_Rep<T>::create (void) +{ + // Yes set ref count to zero. + return new ACE_Future_Rep<T>(); +} + +template <class T> ACE_Future_Rep<T> * +ACE_Future_Rep<T>::attach (ACE_Future_Rep<T>*& rep) +{ + ACE_ASSERT (rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_Guard<ACE_Thread_Mutex> r_mon(rep->value_ready_mutex_)); + ++rep->ref_count_; + return rep; +} + +template <class T> void +ACE_Future_Rep<T>::detach (ACE_Future_Rep<T>*& rep) +{ + ACE_ASSERT(rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, rep->value_ready_mutex_)); + + if (rep->ref_count_-- == 0) + { + r_mon.release (); + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete rep; + } +} + +template <class T> void +ACE_Future_Rep<T>::assign (ACE_Future_Rep<T>*& rep, ACE_Future_Rep<T>* new_rep) +{ + ACE_ASSERT(rep != 0); + ACE_ASSERT(new_rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, rep->value_ready_mutex_)); + + ACE_Future_Rep<T>* old = rep; + rep = new_rep; + + // detached old last for exception safety + if (old->ref_count_-- == 0) + { + r_mon.release (); + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete old; + } +} + template <class T> ACE_Future_Rep<T>::ACE_Future_Rep (void) : value_ (0), @@ -43,7 +100,6 @@ template <class T> ACE_Future_Rep<T>::~ACE_Future_Rep (void) { delete this->value_; - this->value_ = 0; } template <class T> int @@ -63,7 +119,7 @@ ACE_Future_Rep<T>::set (const T &r) // Double-checked locking pattern to avoid multiple allocations. if (this->value_ == 0) - ACE_NEW_RETURN (this->value_, T (r), -1); + ACE_NEW_RETURN (this->value_, T (r), -1); // Signal all the waiting threads. return this->value_ready_.broadcast (); @@ -74,7 +130,8 @@ ACE_Future_Rep<T>::set (const T &r) } template <class T> int -ACE_Future_Rep<T>::get (T &value, ACE_Time_Value *tv) +ACE_Future_Rep<T>::get (T &value, + ACE_Time_Value *tv) { // If the value is already produced, return it. if (this->value_ == 0) @@ -85,11 +142,10 @@ ACE_Future_Rep<T>::get (T &value, ACE_Time_Value *tv) // producer writes to it. while (this->value_ == 0) - { - // Perform a timed wait. - if (this->value_ready_.wait (tv) == -1) - return -1; - } + // Perform a timed wait. + if (this->value_ready_.wait (tv) == -1) + return -1; + // Destructor releases the lock. } @@ -109,82 +165,45 @@ ACE_Future_Rep<T>::operator T () // If the value is not yet defined we must block until the // producer writes to it. + // Wait ``forever.'' + while (this->value_ == 0) - { - // wait forever - if (this->value_ready_.wait () == -1) - // What to do in this case since we've got to indicate - // failure somehow? Exceptions would be nice, but they're - // not portable... - return 0; - } + if (this->value_ready_.wait () == -1) + // What to do in this case since we've got to indicate + // failure somehow? Exceptions would be nice, but they're + // not portable... + return 0; // Destructor releases the mutex - } return *this->value_; } - template <class T> ACE_Future<T>::ACE_Future (void) - : future_rep_ (0) + : future_rep_ (FUTURE_REP::create ()) { } template <class T> ACE_Future<T>::ACE_Future (const ACE_Future<T> &r) + : future_rep_ (FUTURE_REP::attach (((ACE_Future<T> &) r).future_rep_)) { - - // copy constructor: - // - // bind <this> to the same <ACE_Future_Rep> as <r>. - - // @@ not really clear if this is needed... after all this - // ACE_Future is just being instantiated... - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->mutex_)); - - // acquire the mutex on <r>. We have to make sure - // that <r> does not delete its future_rep_... - - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, (ACE_Thread_Mutex &) r.mutex_)); - - // Check if 'r' has already a ACE_Future_rep bound to it. - if (r.future_rep_ == 0) - this->future_rep_ = r.create_rep_i (); - else - // ACE_Future_rep exists already, we can just link to it. - this->future_rep_ = r.future_rep_; - - this->future_rep_->ref_count_++; - } template <class T> ACE_Future<T>::ACE_Future (const T &r) + : future_rep_ (FUTURE_REP::create ()) { ACE_DEBUG ((LM_DEBUG," (%t) funny constructor\n")); - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->mutex_)); - this->create_rep_i ()->set (r); + this->future_rep_->set (r); } template <class T> ACE_Future<T>::~ACE_Future (void) { - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->mutex_)); - - if (this->future_rep_) - { - this->future_rep_->ref_count_--; - - if (this->future_rep_->ref_count_ == 0) - { - delete this->future_rep_; - this->future_rep_ = 0; - } - } - + FUTURE_REP::detach (future_rep_); } template <class T> int @@ -202,64 +221,35 @@ ACE_Future<T>::operator!= (const ACE_Future<T> &r) const template <class T> int ACE_Future<T>::cancel (const T &r) { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1)); + this->cancel (); + return this->future_rep_->set (r); +} +template <class T> int +ACE_Future<T>::cancel (void) +{ // If this ACE_Future is already attached to a ACE_Future_Rep, // detach it (maybe delete the ACE_Future_Rep). - if (this->future_rep_) - { - this->future_rep_->ref_count_--; - - if (this->future_rep_->ref_count_ == 0) - delete this->future_rep_; - } - - // Make a new ACE_Future_Rep and immediately assign - // the new value to it. - this->create_rep_i (); - return this->future_rep_->set (r); + FUTURE_REP::assign (this->future_rep_, FUTURE_REP::create ()); + return 0; } template <class T> int ACE_Future<T>::set (const T &r) { - if (this->future_rep_) - // Give the pointer to the result to the ACE_Future_Rep. - return this->future_rep_->set (r); - else - // @@ Maybe this should return a special value to indicate that - // there's no <ACE_Future_Rep> yet? - return 0; -} - -template <class T> ACE_Future_Rep<T> * -ACE_Future<T>::create_rep_i (void) const -{ - // Should only be called internally with locks held. - ACE_NEW_RETURN (((ACE_Future<T> *) this)->future_rep_, ACE_Future_Rep<T>, 0); - this->future_rep_->ref_count_ = 1; - return this->future_rep_; + // Give the pointer to the result to the ACE_Future_Rep. + return this->future_rep_->set (r); } - template <class T> int ACE_Future<T>::ready (void) { // We're ready if the ACE_Future_rep is ready... - if (this->future_rep_) - return this->future_rep_->ready (); - else - return 0; + return this->future_rep_->ready (); } template <class T> int ACE_Future<T>::get (T &value, ACE_Time_Value *tv) { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1)); - - if (this->future_rep_ == 0) - // Oops, we have to create a ACE_Future_Rep first. - this->create_rep_i (); - // We return the ACE_Future_rep. return this->future_rep_->get (value, tv); } @@ -283,38 +273,16 @@ ACE_Future<T>::operator T () } template <class T> void -ACE_Future<T>::operator = (const ACE_Future<T> &r) +ACE_Future<T>::operator = (const ACE_Future<T> &rhs) { // assignment: // // bind <this> to the same <ACE_Future_Rep> as <r>. - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->mutex_)); - - // if there is already a <ACE_Future_Rep> we have - // to disconnect from it... - if (this->future_rep_) - { - // Disconnect from the <ACE_Future_Rep>. - this->future_rep_->ref_count_--; - - if (this->future_rep_->ref_count_ == 0) - delete this->future_rep_; - } - - // Acquire the mutex on <r>. We have to make sure - // that <r> does not delete it's future_rep_... - - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, r_mon, (ACE_Thread_Mutex &) r.mutex_)); - - // Check if 'r' has already a ACE_Future_rep bound to it. - if (r.future_rep_ == 0) - this->future_rep_ = r.create_rep_i (); - else - // ACE_Future_rep exists already, we can just link to it. - this->future_rep_ = r.future_rep_; - - this->future_rep_->ref_count_++; + // This will work if &r == this, by first increasing the ref count + ACE_Future<T> &r = ( ACE_Future<T> &) rhs; + FUTURE_REP::assign (this->future_rep_, + FUTURE_REP::attach (r.future_rep_)); } template <class T> void @@ -324,8 +292,6 @@ ACE_Future<T>::dump (void) const if (this->future_rep_) this->future_rep_->dump (); - - this->mutex_.dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } @@ -346,6 +312,8 @@ ACE_Future<T>::operator &() } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +// This should probably be moved elsewhere now that ACE_Atomic_Op<> +// isn't used. template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/ace/Future.h b/ace/Future.h index a296a91c632..09d08f5fdcd 100644 --- a/ace/Future.h +++ b/ace/Future.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -11,8 +10,9 @@ // Future.h // // = AUTHOR -// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> +// Andres Kruse <Andres.Kruse@cern.ch>, Douglas C. Schmidt +// <schmidt@cs.wustl.edu>, and Per Andersson +// <Per.Andersson@hfera.ericsson.se>. // // ============================================================================ @@ -27,24 +27,48 @@ template <class T> class ACE_Future; template <class T> class ACE_Future_Rep -// = TITLE -// -// ACE_Future_Rep<T> -// -// = DESCRIPTION -// An ACE_Future_Rep<T> object encapsules a pointer to an -// object of class T which is the result of an asynchronous -// method invocation. It is pointed to by ACE_Future<T> object[s] -// and only accessible through them. + // = TITLE + // ACE_Future_Rep<T> + // + // = DESCRIPTION + // An ACE_Future_Rep<T> object encapsules a pointer to an + // object of class T which is the result of an asynchronous + // method invocation. It is pointed to by ACE_Future<T> object[s] + // and only accessible through them. { friend class ACE_Future<T>; private: - + + // Create, attach, detach and assign encapsulates the reference + // count handling and the object lifetime of ACE_Future_Rep<T> + // instances. + + static ACE_Future_Rep<T> *create (void); + // Create a ACE_Future_Rep<T> and initialize the reference count + + static ACE_Future_Rep<T> *attach (ACE_Future_Rep<T> *&rep); + // Precondition(rep != 0) + // Increase the reference count and return argument. Uses + // the attribute "value_ready_mutex_" to synchronize reference + // count updating + + static void detach (ACE_Future_Rep<T> *&rep); + // Precondition(rep != 0) + // Decreases the reference count and and deletes rep if + // there are no more references to rep. + + static void assign (ACE_Future_Rep<T> *&rep, + ACE_Future_Rep<T> *new_rep); + // Precondition(rep != 0 && new_rep != 0) + // Decreases the rep's reference count and and deletes rep if there + // are no more references to rep. Then assigns new_rep to rep + int set (const T &r); // Set the result value. - int get (T &value, ACE_Time_Value *tv); + int get (T &value, + ACE_Time_Value *tv); // Wait up to <tv> time to get the <value>. operator T (); @@ -62,7 +86,7 @@ private: ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. - // = constructor and destructor private + // = Constructor and destructor private ACE_Future_Rep (void); ~ACE_Future_Rep (void); @@ -72,7 +96,7 @@ private: T *value_; // Pointer to the result. - ACE_Atomic_Op<ACE_Thread_Mutex, int> ref_count_; + int ref_count_; // Reference count. // = Condition variable and mutex that protect the <value_>. @@ -82,10 +106,12 @@ private: template <class T> class ACE_Future // = TITLE - // This class implements a ``single write, multiple read'' pattern - // that can be used to return results from asynchronous method - // invocations. + // This class implements a ``single write, multiple read'' + // pattern that can be used to return results from asynchronous + // method invocations. + // // = DESCRIPTION + // @@ Please update me... { public: // = Initialization and termination methods. @@ -110,6 +136,12 @@ public: int cancel (const T &r); // Cancel an <ACE_Future> and assign the value <r>. It is used if a // client does not want to wait for <T> to be produced. + + int cancel (void); + // Cancel an <ACE_Future>. Put the future into its initial + // state. Returns 0 on succes and -1 on failure. It is now possible + // to reuse the ACE_Future<T>. But remember, the ACE_Future<T> + // is now bound to a new ACE_Future_Rep<T>. int operator == (const ACE_Future<T> &r) const; // Equality operator that returns 1 if both ACE_Future<T> objects @@ -124,7 +156,8 @@ public: // Make the result available. Is used by the server thread to give // the result to all waiting clients. - int get (T &value, ACE_Time_Value *tv = 0); + int get (T &value, + ACE_Time_Value *tv = 0); // Wait up to <tv> time to get the <value>. operator T (); @@ -146,24 +179,19 @@ public: // Declare the dynamic allocation hooks. private: - ACE_Future_Rep<T> *create_rep_i (void) const; - // Create the <ACE_Future_Rep> object. - - void* operator new (size_t nbytes); + void *operator new (size_t nbytes); // Do not allow new operator. - void operator delete(void *); + void operator delete (void *); // Do not allow delete operator void operator &(); // Do not allow address-of operator. - ACE_Future_Rep<T> *future_rep_; // the ACE_Future_Rep - - ACE_Thread_Mutex mutex_; + typedef ACE_Future_Rep<T> FUTURE_REP; + FUTURE_REP *future_rep_; // Protect operations on the <Future>. - }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) @@ -173,5 +201,7 @@ private: #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Future.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + #endif /* ACE_HAS_THREADS */ #endif /* ACE_FUTURE_H */ + diff --git a/ace/Handle_Set.cpp b/ace/Handle_Set.cpp index 0648a515032..b09333d144e 100644 --- a/ace/Handle_Set.cpp +++ b/ace/Handle_Set.cpp @@ -17,9 +17,9 @@ ACE_Handle_Set::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "[ ")); - ACE_DEBUG ((LM_DEBUG, "size_ = %d", this->size_)); + ACE_DEBUG ((LM_DEBUG, "\nsize_ = %d", this->size_)); ACE_DEBUG ((LM_DEBUG, "\nmax_handle_ = %d", this->max_handle_)); + ACE_DEBUG ((LM_DEBUG, "\n[ ")); #if defined (ACE_WIN32) for (size_t i = 0; i < this->mask_.fd_count + 1; i++) @@ -30,17 +30,10 @@ ACE_Handle_Set::dump (void) const ACE_DEBUG ((LM_DEBUG, " %d ", i)); #endif /* ACE_WIN32 */ - ACE_DEBUG ((LM_DEBUG, " ]")); + ACE_DEBUG ((LM_DEBUG, " ]\n")); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_HAS_BROKEN_BITSHIFT) -static const ACE_UINT32 MSB_MASK = ~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1)); -#else -// This needs to go here to avoid overflow problems on some compilers. -static const ACE_UINT32 MSB_MASK = ~(1 << (NFDBITS - 1)); -#endif /* ACE_HAS_BROKEN_BITSHIFT */ - // Table that maps bytes to counts of the enabled bits. const char ACE_Handle_Set::nbits_[256] = @@ -86,11 +79,13 @@ ACE_Handle_Set::ACE_Handle_Set (const ACE_FD_SET_TYPE &fd_mask) // speed up the count. int -ACE_Handle_Set::count_bits (unsigned long n) const +ACE_Handle_Set::count_bits (u_long n) const { ACE_TRACE ("ACE_Handle_Set::count_bits"); - return (ACE_Handle_Set::nbits_[n & 0xff] + ACE_Handle_Set::nbits_[(n >> 8) & 0xff] + - ACE_Handle_Set::nbits_[(n >> 16) & 0xff] + ACE_Handle_Set::nbits_[n >> 24]); + return (ACE_Handle_Set::nbits_[n & 0xff] + + ACE_Handle_Set::nbits_[(n >> 8) & 0xff] + + ACE_Handle_Set::nbits_[(n >> 16) & 0xff] + + ACE_Handle_Set::nbits_[n >> 24]); } // Synchronize the underlying FD_SET with the MAX_FD and the SIZE. @@ -100,16 +95,16 @@ ACE_Handle_Set::sync (ACE_HANDLE max) { ACE_TRACE ("ACE_Handle_Set::sync"); #if !defined(ACE_WIN32) - this->size_ = 0; + this->size_ = 0; - for (int i = (max - 1) / ACE_Handle_Set::WORDSIZE; - i >= 0; - i--) - this->size_ += count_bits (this->mask_.fds_bits[i]); + for (int i = (max - 1) / ACE_Handle_Set::WORDSIZE; + i >= 0; + i--) + this->size_ += count_bits (this->mask_.fds_bits[i]); - this->set_max (max); + this->set_max (max); #else - ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (max); #endif /* !ACE_WIN32 */ } @@ -120,9 +115,8 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max) { ACE_TRACE ("ACE_Handle_Set::set_max"); #if !defined(ACE_WIN32) - if (this->size_ == 0) - this->max_handle_ = -1; + this->max_handle_ = ACE_INVALID_HANDLE; else { int i; @@ -133,9 +127,10 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max) continue; this->max_handle_ = i * ACE_Handle_Set::WORDSIZE; + for (fd_mask val = this->mask_.fds_bits[i]; - (val & ~1) != 0; - val = (val >> 1) & MSB_MASK) + (val & ~1) != 0; // This obscure code is needed since "bit 0" is in location 1... + val = (val >> 1) & ACE_MSB_MASK) this->max_handle_++; } @@ -143,7 +138,7 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max) if (this->max_handle_ >= ACE_Handle_Set::MAXSIZE) this->max_handle_ = ACE_Handle_Set::MAXSIZE - 1; #else - ACE_UNUSED_ARG(current_max); + ACE_UNUSED_ARG (current_max); #endif /* !ACE_WIN32 */ } @@ -155,69 +150,7 @@ ACE_Handle_Set_Iterator::dump (void) const ACE_TRACE ("ACE_Handle_Set_Iterator::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "num_ = %d", this->num_)); - ACE_DEBUG ((LM_DEBUG, "\nindex_ = %d", this->index_)); + ACE_DEBUG ((LM_DEBUG, "\nhandle_index_ = %d", this->handle_index_)); + ACE_DEBUG ((LM_DEBUG, "\nword_num_ = %d", this->word_num_)); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } - -void -ACE_Handle_Set_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Handle_Set_Iterator::operator++"); - -#if defined(ACE_WIN32) - this->index_++; -#else /* !ACE_WIN32 */ - this->val_ = (this->val_ >> 1) & MSB_MASK; - this->num_++; - - - if (this->val_ == 0) - { - for (this->index_++; - this->index_ < ACE_Handle_Set::NUM_WORDS - && this->handles_.mask_.fds_bits[this->index_] == 0; - this->index_++) - continue; - - if (this->index_ >= ACE_Handle_Set::NUM_WORDS) - { - this->num_ = this->handles_.max_handle_ + 1; - return; - } - else - { - this->val_ = this->handles_.mask_.fds_bits[this->index_]; - this->num_ = this->index_ * ACE_Handle_Set::WORDSIZE; - } - } - - for (; ACE_BIT_DISABLED (this->val_, 1); this->num_++) - this->val_ = (this->val_ >> 1) & MSB_MASK; -#endif /* !ACE_WIN32 */ -} - -ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &f) - : handles_ (f), - num_ (0), - index_ (0) -{ - ACE_TRACE ("ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator"); -#if !defined(ACE_WIN32) - // Loop until we've found the first non-zero bit or we run off the - // end of the bitset. - for (; - this->num_ < ACE_Handle_Set::MAXSIZE - && this->handles_.mask_.fds_bits[this->index_] == 0; - this->index_++) - this->num_ += ACE_Handle_Set::WORDSIZE; - - if (this->num_ >= ACE_Handle_Set::MAXSIZE) - this->num_ = this->handles_.max_handle_ + 1; - else - for (this->val_ = this->handles_.mask_.fds_bits[this->index_]; - (ACE_BIT_DISABLED (this->val_, 1)) && this->num_ < ACE_Handle_Set::MAXSIZE; - this->num_++) - this->val_ = (this->val_ >> 1) & MSB_MASK; -#endif /* !ACE_WIN32 */ -} diff --git a/ace/Handle_Set.h b/ace/Handle_Set.h index ef01db484e6..3be77f18371 100644 --- a/ace/Handle_Set.h +++ b/ace/Handle_Set.h @@ -19,16 +19,6 @@ #include "ace/ACE.h" -// This wrapper design is not very portable to DEC OSF/1 I had to -// redefine NFDBITS to 32. On OSF/1 NFDBITS is a macro that expands to -// (sizeof(fd_mask)*8) which is 4096 by default. This was an -// inappropriate value for defining the MSB_MASK default value. Any -// ideas? The workaround is a pretty severe restriction for OSF/1. -// DJT -// #if defined (__osf__) -// #define NFDBITS 32 -// #endif - class ACE_Export ACE_Handle_Set { // = TITLE @@ -81,7 +71,7 @@ public: private: int size_; - // Size of the set. + // Size of the set, i.e., a count of the number of enabled bits. ACE_HANDLE max_handle_; // Current max handle. @@ -98,7 +88,7 @@ private: NBITS = 256 }; - int count_bits (unsigned long n) const; + int count_bits (u_long n) const; // Counts the number of bits enabled in N. Uses a table lookup to // speed up the count. @@ -111,17 +101,22 @@ private: class ACE_Export ACE_Handle_Set_Iterator // = TITLE - // Iterator for the ACE_Handle_Set abstraction. + // Iterator for the <ACE_Handle_Set> abstraction. { public: - ACE_Handle_Set_Iterator (const ACE_Handle_Set &); + ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs); // Constructor. - ACE_HANDLE operator ()(void); - // "Next" operator. + ACE_HANDLE operator () (void); + // "Next" operator. Returns the next unseen <ACE_HANDLE> in the + // <Handle_Set> up to <handle_set_.max_handle_>). When all the + // handles have been seen returns <ACE_INVALID_HANDLE>. Advances + // the iterator automatically, so you need not call <operator++> + // (which is now obsolete). void operator++ (void); - // Advance by "one." + // This is a no-op and no longer does anything. It's only here for + // backwards compatibility. void dump (void) const; // Dump the state of an object. @@ -133,16 +128,16 @@ private: const ACE_Handle_Set &handles_; // The <Handle_Set> we are iterating through. - int num_; - // Number of the word we're iterating on. + int handle_index_; + // Index of the bit we're examining in the current <word_num_> word. - size_t index_; - // Index of the current <num_> word. + int word_num_; + // Number of the word we're iterating over (typically between 0..7). #if !defined (ACE_WIN32) - fd_mask val_; -#endif /* ACE_WIN32 */ + fd_mask word_val_; // Value of the bits in the word we're iterating on. +#endif /* ACE_WIN32 */ }; #if defined (__ACE_INLINE__) diff --git a/ace/IOStream.cpp b/ace/IOStream.cpp index 8f9ceb042e7..4737cf6318a 100644 --- a/ace/IOStream.cpp +++ b/ace/IOStream.cpp @@ -4,10 +4,10 @@ #if !defined (ACE_IOSTREAM_C) #define ACE_IOSTREAM_C +#if !defined (ACE_LACKS_ACE_IOSTREAM) + #define ACE_BUILD_DLL #include "ace/IOStream.h" -#include "ace/Thread.h" -#include "ace/Handle_Set.h" /////////////////////////////////////////////////////////////////////////// @@ -42,7 +42,7 @@ // invokes iostream::operator>> (int&) then iostream::operator>> (String&) // // What has happened is that the first >> is invoked on the base class and returns - // a reference to iostream. The second >> has no idea of the ACE_IOStream and + // a reference to iostream. The second >> has no idea of the ACE_IOStream_T and // gets invoked on iostream. Probably NOT what you wanted! @@ -84,10 +84,8 @@ // a myiostream&, the second >> will be invoked as desired. */ -#if ! defined (ACE_IOSTREAM_BUILDING_TEMPLATE) - -ACE_Time_Value * -ACE_Streambuf_T::recv_timeout (ACE_Time_Value * tv) +ACE_Time_Value * +ACE_Streambuf::recv_timeout (ACE_Time_Value * tv) { ACE_Time_Value * rval = recv_timeout_; if (tv) @@ -102,7 +100,7 @@ ACE_Streambuf_T::recv_timeout (ACE_Time_Value * tv) } int -ACE_Streambuf_T::underflow (void) +ACE_Streambuf::underflow (void) { // If input mode is not set, any attempt to read from the stream is // a failure. @@ -221,7 +219,7 @@ ACE_Streambuf_T::underflow (void) // rather than repeating a lot of what you've already seen. int -ACE_Streambuf_T::overflow (int c) +ACE_Streambuf::overflow (int c) { // Check to see if output is allowed at all. if (! (mode_ & ios::out)) @@ -291,7 +289,7 @@ ACE_Streambuf_T::overflow (int c) // syncin int -ACE_Streambuf_T::syncin (void) +ACE_Streambuf::syncin (void) { // As discussed, there really isn't any way to sync input from a socket-like // device. We specifially override this base-class function so that it won't @@ -302,7 +300,7 @@ ACE_Streambuf_T::syncin (void) // syncout int -ACE_Streambuf_T::syncout (void) +ACE_Streambuf::syncout (void) { // Unlike syncin, syncout is a doable thing. All we have to do is // write whatever is in the output buffer to the peer. flushbuf () @@ -315,7 +313,7 @@ ACE_Streambuf_T::syncout (void) } int -ACE_Streambuf_T::sync (void) +ACE_Streambuf::sync (void) { // sync () is fairly traditional in that it syncs both input and output. // We could have omitted the call to syncin () but someday, we may want it @@ -334,7 +332,7 @@ ACE_Streambuf_T::sync (void) // flushbuf int -ACE_Streambuf_T::flushbuf (void) +ACE_Streambuf::flushbuf (void) { // pptr () is one character beyond the last character put // into the buffer. pbase () points to the beginning of @@ -395,8 +393,8 @@ ACE_Streambuf_T::flushbuf (void) return 0; } -int -ACE_Streambuf_T::get_one_byte (void) +int +ACE_Streambuf::get_one_byte (void) { // The recv function will return immediately if there is no data // waiting. So, we use recv_n to wait for exactly one byte to come @@ -411,7 +409,7 @@ ACE_Streambuf_T::get_one_byte (void) } int -ACE_Streambuf_T::fillbuf (void) +ACE_Streambuf::fillbuf (void) // This will be called when the read (get) buffer has been // exhausted (ie -- gptr == egptr) { @@ -422,7 +420,7 @@ ACE_Streambuf_T::fillbuf (void) return EOF; // Now, get whatever else may be in the buffer. This will return if - // there is nothing in the buffer. + // there is nothing in the buffer. int bc = this->recv (base (), blen (), recv_timeout_); @@ -441,7 +439,7 @@ ACE_Streambuf_T::fillbuf (void) return bc; } -ACE_Streambuf_T::ACE_Streambuf_T (u_int streambuf_size, int io_mode) +ACE_Streambuf::ACE_Streambuf (u_int streambuf_size, int io_mode) : eback_saved_ (0), // to avoid Purify UMR pbase_saved_ (0), // to avoid Purify UMR get_mode_ (1), @@ -454,26 +452,26 @@ ACE_Streambuf_T::ACE_Streambuf_T (u_int streambuf_size, int io_mode) (void)reset_put_buffer (); } -u_int ACE_Streambuf_T::streambuf_size (void) +u_int ACE_Streambuf::streambuf_size (void) { return streambuf_size_; } -u_int ACE_Streambuf_T::get_waiting (void) +u_int ACE_Streambuf::get_waiting (void) // Return the number of bytes not yet gotten. // eback + get_waiting = gptr { return this->gptr_saved_ - this->eback_saved_; } -u_int ACE_Streambuf_T::get_avail (void) +u_int ACE_Streambuf::get_avail (void) // Return the number of bytes in the get area (includes some already gotten); // eback + get_avail = egptr { return this->egptr_saved_ - this->eback_saved_; } -u_int ACE_Streambuf_T::put_avail (void) +u_int ACE_Streambuf::put_avail (void) // Return the number of bytes to be 'put' onto the stream media. // pbase + put_avail = pptr { @@ -481,7 +479,7 @@ u_int ACE_Streambuf_T::put_avail (void) } char * -ACE_Streambuf_T::reset_get_buffer (char * newBuffer, u_int _streambuf_size, u_int _gptr, u_int _egptr) +ACE_Streambuf::reset_get_buffer (char * newBuffer, u_int _streambuf_size, u_int _gptr, u_int _egptr) // // Typical usage: // @@ -536,7 +534,7 @@ ACE_Streambuf_T::reset_get_buffer (char * newBuffer, u_int _streambuf_size, u_in } char * -ACE_Streambuf_T::reset_put_buffer (char * newBuffer, u_int _streambuf_size, u_int _pptr) +ACE_Streambuf::reset_put_buffer (char * newBuffer, u_int _streambuf_size, u_int _pptr) // // Typical usage: // @@ -584,7 +582,7 @@ ACE_Streambuf_T::reset_put_buffer (char * newBuffer, u_int _streambuf_size, u_in } void -ACE_Streambuf_T::reset_base (void) +ACE_Streambuf::reset_base (void) { // Until we experience the first get or put operation, we do not // know what our current IO mode is. @@ -602,191 +600,12 @@ ACE_Streambuf_T::reset_base (void) // would be deleted when the object destructs. Since we are providing // separate read/write buffers, it is up to us to manage their memory. -ACE_Streambuf_T::~ACE_Streambuf_T (void) +ACE_Streambuf::~ACE_Streambuf (void) { delete [] this->eback_saved_; delete [] this->pbase_saved_; } -#endif // ACE_IOSTREAM_BUILDING_TEMPLATE - -/////////////////////////////////////////////////////////////////////////// - - -// We will be given a STREAM by the iostream object which creates us. -// See the ACE_IOStream template for how that works. Like other -// streambuf objects, we can be input-only, output-only or both. - -template <class STREAM> -ACE_Streambuf<STREAM>::ACE_Streambuf (STREAM *peer, u_int streambuf_size, int io_mode) - : ACE_Streambuf_T (streambuf_size, io_mode), peer_ (peer) -{ - // A streambuf allows for unbuffered IO where every character is - // read as requested and written as provided. To me, this seems - // terribly inefficient for socket-type operations, so I've disabled - // it. All of the work would be done by the underflow/overflow - // functions anyway and I haven't implemented anything there to - // support unbuffered IO. - - this->unbuffered (0); - - // Linebuffered is similar to unbuffered. Again, I don't have any - // need for this and I don't see the advantage. I believe this - // would have to be supported by underflow/overflow to be effective. -#if !defined (ACE_LACKS_LINEBUFFERED_STREAMBUF) - this->linebuffered (0); -#endif /* ! ACE_LACKS_LINEBUFFERED_STREAMBUF */ - -} - - -/////////////////////////////////////////////////////////////////////////// - - -// The typical constructor. This will initiailze your STREAM and then -// setup the iostream baseclass to use a custom streambuf based on -// STREAM. - -template <class STREAM> -ACE_IOStream<STREAM>::ACE_IOStream (STREAM & stream, u_int streambuf_size) - : iostream (streambuf_ = new ACE_Streambuf<STREAM> ((STREAM *) this, streambuf_size)), - STREAM (stream) -{ - iostream::init (this->streambuf_); -} - -template <class STREAM> -ACE_IOStream<STREAM>::ACE_IOStream (u_int streambuf_size) - : iostream (streambuf_ = new ACE_Streambuf<STREAM> ((STREAM *) this, streambuf_size)) -{ - iostream::init (this->streambuf_); -} - -// We have to get rid of the streambuf_ ourselves since we gave it to -// iostream () - -template <class STREAM> -ACE_IOStream<STREAM>::~ACE_IOStream (void) -{ - delete this->streambuf_; -} - -// The only ambituity in the multiple inheritance is the close () -// function. - -template <class STREAM> int -ACE_IOStream<STREAM>::close (void) -{ - return STREAM::close (); -} - -template <class STREAM> ACE_IOStream<STREAM> & -ACE_IOStream<STREAM>::operator>> (ACE_Time_Value *& tv) -{ - ACE_Time_Value * old_tv = this->streambuf_->recv_timeout (tv); - tv = old_tv; - return *this; -} - -#if defined (ACE_HAS_STRING_CLASS) +#endif /* !ACE_LACKS_ACE_IOSTREAM */ -// A simple string operator. The base iostream has 'em for char* but -// that isn't always the best thing for a String. If we don't provide -// our own here, we may not get what we want. - -template <class STREAM> ACE_IOStream<STREAM> & -ACE_IOStream<STREAM>::operator>> (ACE_IOStream_String & v) -{ - if (ipfx0 ()) - { - char c; - iostream::operator>> (c); - - for (v = c ; this->get (c) && !isspace (c) ; v += c) - continue; - } - - isfx (); - - return *this; -} - - -template <class STREAM> ACE_IOStream<STREAM> & -ACE_IOStream<STREAM>::operator<< (ACE_IOStream_String & v) -{ - if (opfx ()) - { -#if defined (ACE_WIN32) - for (int i = 0 ; i < v.GetLength () ; ++i) -#else - for (u_int i = 0 ; i < (u_int) v.length () ; ++i) -#endif - this->put (v[i]); - } - - osfx (); - - return *this; -} - - -////////////////////////////////////////////////////////////////// -// A more clever put operator for strings that knows how to -// deal with quoted strings containing back-quoted quotes. -// -template <class STREAM> ACE_IOStream<STREAM> & -ACE_IOStream<STREAM>::operator>> (QuotedString & str) -{ - if (ipfx0 ()) - { - char c; - - if (! (*this >> c)) // eat space up to the first char - // this->set (ios::eofbit|ios::failbit); - return *this; - - str = ""; // Initialize the string - - // if we don't have a quote, append until we see space - if (c != '"') - for (str = c ; this->get (c) && !isspace (c) ; str += c) - continue; - else - for (; this->get (c) && c != '"' ; str += c) - if (c == '\\') - { - this->get (c); - if (c != '"') - str += '\\'; - } - } - - isfx (); - - return *this; -} - -template <class STREAM> ACE_IOStream<STREAM> & -ACE_IOStream<STREAM>::operator<< (QuotedString & str) -{ - if (opfx ()) - { - this->put ('"'); - for (u_int i = 0 ; i < str.length () ; ++i) - { - if (str[i] == '"') - this->put ('\\'); - this->put (str[i]); - } - this->put ('"'); - } - - osfx (); - - return *this; -} - -#endif /* ACE_HAS_STRING_CLASS */ #endif /* ACE_IOSTREAM_C */ - diff --git a/ace/IOStream.h b/ace/IOStream.h index 7603553178d..1a9ac2886a5 100644 --- a/ace/IOStream.h +++ b/ace/IOStream.h @@ -7,7 +7,7 @@ // ace // // = FILENAME -// iostream.h +// IOStream.h // // = AUTHOR // James CE Johnson <jcej@lads.com> @@ -20,7 +20,7 @@ /* Changes 4/5/97 - ACE_Streambuf_T + ACE_Streambuf New public functions added @@ -62,26 +62,27 @@ Constructor changed Initialization of the get/put buffers was moved here from - the derived class/template ACE_Streambuf<...> + the derived class/template ACE_Streambuf_T<...> At the same time, the new functions reset_get/put_buffer are now used instead of the previous monolithic function. - ACE_Streambuf<...> + ACE_Streambuf_T<...> Constructor changed: Initialization of the get/put buffers has been moved to the - baseclass ACE_Streambuf_T. This will reduce template bloat + baseclass ACE_Streambuf. This will reduce template bloat as well as giving us more functionality as described above. */ #if !defined (ACE_IOSTREAM_H) #define ACE_IOSTREAM_H +#if !defined (ACE_LACKS_ACE_IOSTREAM) + #include "ace/INET_Addr.h" #include "ace/Handle_Set.h" -#include <iomanip.h> #if defined (ACE_HAS_STRING_CLASS) #if defined (ACE_WIN32) @@ -104,15 +105,15 @@ public: inline QuotedString (void) { *this = ""; } inline QuotedString (const char * c) { *this = ACE_IOStream_String (c); } inline QuotedString (const ACE_IOStream_String& s) { *this = s; } - inline QuotedString& operator= (const ACE_IOStream_String& s) + inline QuotedString& operator= (const ACE_IOStream_String& s) { return (QuotedString&) ACE_IOStream_String::operator= (s); } inline QuotedString & operator = (const char c) { - return (QuotedString&) ACE_IOStream_String::operator= (c); + return (QuotedString&) ACE_IOStream_String::operator= (c); } - inline QuotedString & operator = (const char* c) { - return (QuotedString&) ACE_IOStream_String::operator= (c); + inline QuotedString & operator = (const char* c) { + return (QuotedString&) ACE_IOStream_String::operator= (c); } inline bool operator < (const QuotedString& s) const { return *(ACE_IOStream_String *) this < (ACE_IOStream_String) s; @@ -126,7 +127,7 @@ public: /////////////////////////////////////////////////////////////////////////// -class ACE_Export ACE_Streambuf_T : public streambuf +class ACE_Export ACE_Streambuf : public streambuf // = TITLE // Create your custom streambuf by providing and ACE_*_Stream // object to this template. I have tested it with @@ -190,7 +191,7 @@ class ACE_Export ACE_Streambuf_T : public streambuf { public: - virtual ~ACE_Streambuf_T (void); + virtual ~ACE_Streambuf (void); // If the default allocation strategey were used the common buffer // would be deleted when the object destructs. Since we are // providing separate read/write buffers, it is up to us to manage @@ -232,7 +233,7 @@ public: // Query the streambuf for the size of it's buffers. protected: - ACE_Streambuf_T (u_int streambuf_size, int io_mode); + ACE_Streambuf (u_int streambuf_size, int io_mode); virtual int sync (void); // Sync both input and output. See syncin/syncout below for @@ -322,47 +323,6 @@ protected: /////////////////////////////////////////////////////////////////////////// -template <class STREAM> -class ACE_Streambuf : public ACE_Streambuf_T -{ -public: - ACE_Streambuf (STREAM * peer, u_int streambuf_size = ACE_STREAMBUF_SIZE, int io_mode = ios::in | ios::out); - // We will be given a STREAM by the iostream object which creates - // us. See the ACE_IOStream template for how that works. Like - // other streambuf objects, we can be input-only, output-only or - // both. - - virtual ssize_t send ( char * buf, ssize_t len ) - { - return peer_->send_n(buf,len); - } - virtual ssize_t recv ( char * buf, ssize_t len, ACE_Time_Value * tv = NULL ) - { - return this->recv( buf, len, 0, tv ); - } - virtual ssize_t recv ( char * buf, ssize_t len, int flags, ACE_Time_Value * tv = NULL ) - { - ssize_t rval = peer_->recv(buf,len,flags,tv); - return rval; - } - virtual ssize_t recv_n( char * buf, ssize_t len, int flags = 0, ACE_Time_Value * tv = NULL ) - { - ssize_t rval = peer_->recv_n(buf,len,flags,tv); - return rval; - } - -protected: - STREAM * peer_; - // This will be our ACE_SOCK_Stream or similar object. - - virtual ACE_HANDLE get_handle(void) - { - return peer_ ? peer_->get_handle() : 0 ; - } -}; - -/////////////////////////////////////////////////////////////////////////// - // These typedefs are provided by G++ (on some systems?) without the // trailing '_'. Since we can't count on 'em, I've defined them to // what GNU wants here. @@ -442,8 +402,8 @@ typedef ostream& (*__omanip_)(ostream&); PUT_PROT(MT,char,CODE) \ PUT_PROT(MT,u_char,CODE) \ PUT_PROT(MT,const char *,CODE) \ - PUT_PROT(MT,const u_char *,CODE) \ - PUT_PROT(MT,const void *,CODE) \ + PUT_PROT(MT,u_char *,CODE) \ + PUT_PROT(MT,void *,CODE) \ inline virtual MT& operator<<(__omanip_ func) CODE2 \ inline virtual MT& operator<<(__manip_ func) CODE2 @@ -478,212 +438,9 @@ typedef ostream& (*__omanip_)(ostream&); /////////////////////////////////////////////////////////////////////////// -template <class STREAM> -class ACE_IOStream : public iostream, public STREAM - // = TITLE - // A template adapter for creating an iostream-like object using - // an ACE IPC Stream for the actual I/O. Iostreams use an - // underlying streambuf object for the IO interface. The - // iostream class and derivatives provide you with a host of - // convenient operators that access the streambuf. - // - // = DESCRIPTION - // We inherit all characteristics of iostream and your <STREAM> - // class. When you create a new class from this template, you - // can use it anywhere you would have used your original - // <STREAM> class. - // - // To create an iostream for your favorite ACE IPC class (e.g., - // <ACE_SOCK_Stream>), feed that class to this template's - // <STREAM> parameter, e.g., - // - // typedef ACE_Svc_Handler<ACE_SOCK_iostream, - // ACE_INET_Addr, ACE_NULL_SYNCH> - // Service_Handler; - // - // Because the operators in the iostream class are not virtual, - // you cannot easily provide overloads in your custom - // ACE_IOStream classes. To make these things work correctly, - // you need to overload ALL operators of the ACE_IOStream you - // create. I've attempted to do that here to make things easier - // for you but there are no guarantees. - // - // In the iostream.cpp file is an example of why it is necessary - // to overload all of the get/put operators when you want to - // customize only one or two. -{ -public: - ACE_IOStream (STREAM & stream, u_int streambuf_size = ACE_STREAMBUF_SIZE); - ACE_IOStream (u_int streambuf_size = ACE_STREAMBUF_SIZE); - // The default constructor. This will initiailze your STREAM and - // then setup the iostream baseclass to use a custom streambuf based - // on STREAM. - - virtual ~ACE_IOStream (void); - // We have to get rid of the streambuf_ ourselves since we gave it - // to iostream(); - - virtual int close (void); - // The only ambituity in the multiple inheritance is the close() - // function. - -#if defined (ACE_HAS_STRING_CLASS) - virtual ACE_IOStream<STREAM> & operator>>(ACE_IOStream_String & v); - // A simple string operator. The base iostream has 'em for char* - // but that isn't always the best thing for a String. If we don't - // provide our own here, we may not get what we want. - - virtual ACE_IOStream<STREAM> & operator<<(ACE_IOStream_String & v); - // The converse of the String put operator. +// Include the templates here. +#include "ace/IOStream_T.h" - virtual ACE_IOStream<STREAM> & operator>>(QuotedString &v); - // A more clever operator that handles quoted strings so that we - // can get strings containing whitespace! - - virtual ACE_IOStream<STREAM> & operator<<(QuotedString &v); - // The converse of the QuotedString put operator. -#endif /* ACE_HAS_STRING_CLASS */ - - // = Using the macros to provide get/set operators. -#if !defined (ACE_LACKS_IOSTREAM_SETGET) - GETPUT_FUNC_SET (ACE_IOStream<STREAM>) -#endif /* ACE_LACKS_IOSTREAM_SETSET */ - -#if defined (ACE_LACKS_IOSTREAM_FX) - virtual int ipfx (int need = 0) { return good(); } - virtual int ipfx0(void) { return good(); } // Optimized ipfx(0) - virtual int ipfx1(void) { return good(); } // Optimized ipfx(1) - virtual void isfx (void) { return; } - virtual int opfx (void) { return good(); } - virtual void osfx (void) { put(' '); return; } -#else -#if defined (__GNUC__) - virtual int ipfx0(void) { return(iostream::ipfx0()); } // Optimized ipfx(0) - virtual int ipfx1(void) { return(iostream::ipfx1()); } // Optimized ipfx(1) -#else - virtual int ipfx0(void) { return(iostream::ipfx(0)); } - virtual int ipfx1(void) { return(iostream::ipfx(1)); } -#endif - virtual int ipfx (int need = 0) { return(iostream::ipfx(need)); } - virtual void isfx (void) { iostream::isfx(); return; } - virtual int opfx (void) { return(iostream::opfx()); } - virtual void osfx (void) { iostream::osfx(); return; } -#endif /* ACE_LACKS_IOSTREAM_FX */ - - ACE_IOStream<STREAM> & operator>>(ACE_Time_Value *&tv); - // Allow the programmer to provide a timeout for read operations. - // Give it a pointer to NULL to block forever. - -protected: - - ACE_Streambuf<STREAM> *streambuf_; - // This is where all of the action takes place. The - // streambuf_ is the interface to the underlying STREAM. - -private: - // We move these into the private section so that they cannot - // be used by the application programmer. This is necessary - // because streambuf_ will be buffering IO on the STREAM - // object. If these functions were used in your program, - // there is a danger of getting the datastream out of sync. - ssize_t send (...); - ssize_t recv (...); - ssize_t send_n (...); - ssize_t recv_n (...); -}; - -/////////////////////////////////////////////////////////////////////////// - -template <class STREAM> -class ACE_SOCK_Dgram_SC : public STREAM -// Datagrams don't have the notion of a "peer". Each send and receive -// on a datagram can go to a different peer if you want. If you're -// using datagrams for stream activity, you probably want 'em all to -// go to (and come from) the same place. That's what this class is -// for. BTW: 'Dgram_SC' is short for 'Datagram-Self-Contained'. -// Here, we keep an address object so that we can remember who last -// sent us data. When we write back, we're then able to write back to -// that same address. -{ -protected: - ACE_INET_Addr peer_; - -public: - ACE_SOCK_Dgram_SC (void) - { - } - - ACE_SOCK_Dgram_SC (STREAM &source, ACE_INET_Addr &dest) - : STREAM (source), peer_ (dest) - { - } - - inline ssize_t send_n (char *buf, ssize_t len) - { - return STREAM::send (buf, len, peer_); - } - - inline ssize_t recv (char * buf, ssize_t len, ACE_Time_Value * tv = NULL) - { - return recv (buf, len, 0, tv); - } - - inline ssize_t recv (char * buf, ssize_t len, int flags, ACE_Time_Value * tv = NULL) - { - if (tv != 0) - { - ACE_HANDLE handle = this->get_handle (); - ACE_Handle_Set handle_set; - - handle_set.set_bit (handle); - - switch (ACE_OS::select (int (handle) + 1, - (fd_set *) handle_set, // read_fds. - (fd_set *) 0, // write_fds. - (fd_set *) 0, // exception_fds. - tv)) - { - case 0: - errno = ETIME; - case -1: - return -1; - default: - ; // Do the 'recv' below - } - } - - int rval = STREAM::recv (buf, len, peer_, flags); -#ifdef WIN32 - if (rval == SOCKET_ERROR) - if (WSAGetLastError() == WSAEMSGSIZE) - if (flags & MSG_PEEK) - rval = len; -#endif - - return rval < len ? rval : len; - } - inline ssize_t recv_n (char * buf, - ssize_t len, int flags = 0, - ACE_Time_Value * tv = NULL) - { - int rval = this->recv (buf, len, flags, tv); - return rval; - } - - inline int get_remote_addr (ACE_INET_Addr &addr) const - { - addr = peer_; - return 0; - } - -}; - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -# if ! defined( ACE_IOSTREAM_C ) -# define ACE_IOSTREAM_BUILDING_TEMPLATE -# endif -# include "ace/IOStream.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* !ACE_LACKS_ACE_IOSTREAM */ #endif /* ACE_IOSTREAM_H */ - diff --git a/ace/Local_Tokens.h b/ace/Local_Tokens.h index 5663e0913d0..3cd9c688b0f 100644 --- a/ace/Local_Tokens.h +++ b/ace/Local_Tokens.h @@ -641,7 +641,6 @@ private: // Name of the token. }; - // 7.. class ACE_Export ACE_Token_Proxy // = TITLE diff --git a/ace/Local_Tokens_T.cpp b/ace/Local_Tokens_T.cpp index c28e62feb31..1be17133702 100644 --- a/ace/Local_Tokens_T.cpp +++ b/ace/Local_Tokens_T.cpp @@ -1,6 +1,7 @@ // Local_Tokens_T.cpp // $Id$ +#if 0 #if !defined (ACE_LOCAL_TOKENS_T_C) #define ACE_LOCAL_TOKENS_T_C @@ -53,3 +54,4 @@ ACE_Token_Name<TYPE>::dump (void) const } #endif /* ACE_LOCAL_TOKENS_T_C */ +#endif /* 0 */ diff --git a/ace/Makefile b/ace/Makefile index 1bdf1bd1807..4cf6ea6df2e 100644 --- a/ace/Makefile +++ b/ace/Makefile @@ -36,6 +36,7 @@ FILES = Log_Msg \ Handle_Set \ High_Res_Timer \ INET_Addr \ + IOStream \ IO_Cntl_Msg \ IO_SAP \ IPC_SAP \ @@ -140,9 +141,8 @@ TEMPLATE_FILES = \ Event_Handler_T \ Future \ Hash_Map_Manager \ - IOStream \ + IOStream_T \ Local_Name_Space_T \ - Local_Tokens_T \ Malloc_T \ Map_Manager \ Message_Queue \ @@ -247,7 +247,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/FIFO.i \ $(WRAPPER_ROOT)/ace/FIFO_Send.i \ $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.i -.obj/ACE.o .shobj/ACE.so: ACE.cpp $(WRAPPER_ROOT)/ace/IPC_SAP.h \ +.obj/ACE.o .shobj/ACE.so: ACE.cpp \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -390,7 +391,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Hash_Map_Manager.h \ $(WRAPPER_ROOT)/ace/Message_Queue.i \ $(WRAPPER_ROOT)/ace/Method_Object.h -.obj/Addr.o .shobj/Addr.so: Addr.cpp $(WRAPPER_ROOT)/ace/Addr.h \ +.obj/Addr.o .shobj/Addr.so: Addr.cpp \ + $(WRAPPER_ROOT)/ace/Addr.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -403,7 +405,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/ACE.i \ $(WRAPPER_ROOT)/ace/Addr.i -.obj/ARGV.o .shobj/ARGV.so: ARGV.cpp $(WRAPPER_ROOT)/ace/ARGV.h \ +.obj/ARGV.o .shobj/ARGV.so: ARGV.cpp \ + $(WRAPPER_ROOT)/ace/ARGV.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -425,9 +428,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i .obj/CORBA_Handler.o .shobj/CORBA_Handler.so: CORBA_Handler.cpp \ $(WRAPPER_ROOT)/ace/CORBA_Handler.h \ @@ -610,7 +613,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/SString.i \ $(WRAPPER_ROOT)/ace/DEV.i \ $(WRAPPER_ROOT)/ace/DEV_IO.i -.obj/Dump.o .shobj/Dump.so: Dump.cpp $(WRAPPER_ROOT)/ace/Dump.h \ +.obj/Dump.o .shobj/Dump.so: Dump.cpp \ + $(WRAPPER_ROOT)/ace/Dump.h \ $(WRAPPER_ROOT)/ace/Synch.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -687,7 +691,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Mem_Map.i \ $(WRAPPER_ROOT)/ace/Memory_Pool.i \ $(WRAPPER_ROOT)/ace/Message_Block.i -.obj/FIFO.o .shobj/FIFO.so: FIFO.cpp $(WRAPPER_ROOT)/ace/FIFO.h \ +.obj/FIFO.o .shobj/FIFO.so: FIFO.cpp \ + $(WRAPPER_ROOT)/ace/FIFO.h \ $(WRAPPER_ROOT)/ace/IPC_SAP.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -778,7 +783,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/FIFO.i \ $(WRAPPER_ROOT)/ace/FIFO_Send.i \ $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.i -.obj/FILE.o .shobj/FILE.so: FILE.cpp $(WRAPPER_ROOT)/ace/FILE.h \ +.obj/FILE.o .shobj/FILE.so: FILE.cpp \ + $(WRAPPER_ROOT)/ace/FILE.h \ $(WRAPPER_ROOT)/ace/IO_SAP.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -925,6 +931,26 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Addr.h \ $(WRAPPER_ROOT)/ace/Addr.i \ $(WRAPPER_ROOT)/ace/INET_Addr.i +.obj/IOStream.o .shobj/IOStream.so: IOStream.cpp \ + $(WRAPPER_ROOT)/ace/IOStream.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/OS.i \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.i \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.i \ + $(WRAPPER_ROOT)/ace/IOStream_T.h .obj/IO_Cntl_Msg.o .shobj/IO_Cntl_Msg.so: IO_Cntl_Msg.cpp .obj/IO_SAP.o .shobj/IO_SAP.so: IO_SAP.cpp \ $(WRAPPER_ROOT)/ace/IO_SAP.h \ @@ -1085,7 +1111,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Local_Tokens.i \ $(WRAPPER_ROOT)/ace/Token_Manager.h \ $(WRAPPER_ROOT)/ace/Token_Manager.i -.obj/LSOCK.o .shobj/LSOCK.so: LSOCK.cpp $(WRAPPER_ROOT)/ace/LSOCK.h \ +.obj/LSOCK.o .shobj/LSOCK.so: LSOCK.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ $(WRAPPER_ROOT)/ace/SOCK.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -1256,7 +1283,6 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/LSOCK_Stream.i .obj/Log_Record.o .shobj/Log_Rord.so: Log_Record.cpp \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -1264,6 +1290,7 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/OS.i \ $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/ACE.i .obj/Malloc.o .shobj/Malloc.so: Malloc.cpp \ @@ -1445,9 +1472,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i .obj/Name_Proxy.o .shobj/Name_Proxy.so: Name_Proxy.cpp \ $(WRAPPER_ROOT)/ace/Name_Proxy.h \ @@ -1553,9 +1580,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/SString.h \ $(WRAPPER_ROOT)/ace/SString.i @@ -1776,9 +1803,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/SString.h \ $(WRAPPER_ROOT)/ace/SString.i \ @@ -1941,9 +1968,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Thread_Manager.h \ $(WRAPPER_ROOT)/ace/Thread.h \ @@ -1980,9 +2007,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Process.i \ $(WRAPPER_ROOT)/ace/ARGV.h \ @@ -1998,9 +2025,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Process.i \ $(WRAPPER_ROOT)/ace/Process_Manager.h \ @@ -2102,9 +2129,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Timer_Queue.h \ $(WRAPPER_ROOT)/ace/Synch.h \ @@ -2279,9 +2306,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i .obj/Registry_Name_Space.o .shobj/Registry_Name_Space.so: Registry_Name_Space.cpp \ $(WRAPPER_ROOT)/ace/Registry_Name_Space.h \ @@ -2292,9 +2319,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i .obj/Remote_Name_Space.o .shobj/Remote_Name_Space.so: Remote_Name_Space.cpp \ $(WRAPPER_ROOT)/ace/Remote_Name_Space.h \ @@ -2444,7 +2471,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Remote_Tokens.i \ $(WRAPPER_ROOT)/ace/Singleton.h \ $(WRAPPER_ROOT)/ace/Singleton.i -.obj/SOCK.o .shobj/SOCK.so: SOCK.cpp $(WRAPPER_ROOT)/ace/SOCK.h \ +.obj/SOCK.o .shobj/SOCK.so: SOCK.cpp \ + $(WRAPPER_ROOT)/ace/SOCK.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -2665,7 +2693,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/INET_Addr.h \ $(WRAPPER_ROOT)/ace/INET_Addr.i \ $(WRAPPER_ROOT)/ace/SOCK_Stream.i -.obj/SPIPE.o .shobj/SPIPE.so: SPIPE.cpp $(WRAPPER_ROOT)/ace/SPIPE.h \ +.obj/SPIPE.o .shobj/SPIPE.so: SPIPE.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ $(WRAPPER_ROOT)/ace/IPC_SAP.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -3603,9 +3632,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Malloc.h \ $(WRAPPER_ROOT)/ace/Malloc.i \ @@ -3631,7 +3660,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Mem_Map.h \ $(WRAPPER_ROOT)/ace/Mem_Map.i \ $(WRAPPER_ROOT)/ace/Memory_Pool.i -.obj/Task.o .shobj/Task.so: Task.cpp $(WRAPPER_ROOT)/ace/Task.h \ +.obj/Task.o .shobj/Task.so: Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ $(WRAPPER_ROOT)/ace/Service_Object.h \ $(WRAPPER_ROOT)/ace/Shared_Object.h \ $(WRAPPER_ROOT)/ace/ACE.h \ @@ -3864,9 +3894,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/SString.h \ $(WRAPPER_ROOT)/ace/SString.i @@ -4080,9 +4110,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/DEV_Addr.h \ $(WRAPPER_ROOT)/ace/Addr.h \ @@ -4819,9 +4849,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i .obj/Auto_Ptr.o .shobj/Auto_Ptr.so: Auto_Ptr.cpp \ $(WRAPPER_ROOT)/ace/Auto_Ptr.h \ @@ -5125,9 +5155,9 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Trace.h \ $(WRAPPER_ROOT)/ace/Log_Msg.h \ $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/Service_Config.h \ $(WRAPPER_ROOT)/ace/Service_Object.h \ @@ -5204,7 +5234,8 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Message_Queue.i \ $(WRAPPER_ROOT)/ace/ReactorEx.i \ $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h -.obj/IOStream.o .shobj/IOStream.so: IOStream.cpp \ +.obj/IOStream_T.o .shobj/IOStream_T.so: IOStream_T.cpp \ + $(WRAPPER_ROOT)/ace/IOStream_T.h \ $(WRAPPER_ROOT)/ace/IOStream.h \ $(WRAPPER_ROOT)/ace/INET_Addr.h \ $(WRAPPER_ROOT)/ace/ACE.h \ @@ -5222,9 +5253,7 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Addr.i \ $(WRAPPER_ROOT)/ace/INET_Addr.i \ $(WRAPPER_ROOT)/ace/Handle_Set.h \ - $(WRAPPER_ROOT)/ace/Handle_Set.i \ - $(WRAPPER_ROOT)/ace/Thread.h \ - $(WRAPPER_ROOT)/ace/Thread.i + $(WRAPPER_ROOT)/ace/Handle_Set.i .obj/Local_Name_Space_T.o .shobj/Local_Name_Space_T.so: Local_Name_Space_T.cpp \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ @@ -5323,20 +5352,6 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ $(WRAPPER_ROOT)/ace/Name_Request_Reply.h \ $(WRAPPER_ROOT)/ace/Naming_Context.h -.obj/Local_Tokens_T.o .shobj/Local_Tokens_T.so: Local_Tokens_T.cpp \ - $(WRAPPER_ROOT)/ace/Local_Tokens_T.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/OS.i \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/Local_Tokens_T.i .obj/Malloc_T.o .shobj/Malloc_T.so: Malloc_T.cpp \ $(WRAPPER_ROOT)/ace/Malloc_T.h \ $(WRAPPER_ROOT)/ace/ACE.h \ @@ -5649,6 +5664,7 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Stream_Modules.i .obj/Singleton.o .shobj/Singleton.so: Singleton.cpp \ $(WRAPPER_ROOT)/ace/Singleton.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ $(WRAPPER_ROOT)/ace/ACE.h \ $(WRAPPER_ROOT)/ace/OS.h \ $(WRAPPER_ROOT)/ace/config.h \ @@ -5660,19 +5676,18 @@ Svc_Conf_l.cpp: Svc_Conf.l $(WRAPPER_ROOT)/ace/Log_Priority.h \ $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/Singleton.i \ - $(WRAPPER_ROOT)/ace/Synch_T.h \ - $(WRAPPER_ROOT)/ace/Event_Handler.h \ - $(WRAPPER_ROOT)/ace/Event_Handler.i \ - $(WRAPPER_ROOT)/ace/Synch.h \ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ $(WRAPPER_ROOT)/ace/Synch.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.i \ $(WRAPPER_ROOT)/ace/Synch_T.i \ $(WRAPPER_ROOT)/ace/Thread.h \ - $(WRAPPER_ROOT)/ace/Thread.i + $(WRAPPER_ROOT)/ace/Thread.i \ + $(WRAPPER_ROOT)/ace/Singleton.i .obj/Strategies_T.o .shobj/Strategies_T.so: Strategies_T.cpp \ $(WRAPPER_ROOT)/ace/Strategies_T.h \ $(WRAPPER_ROOT)/ace/Service_Config.h \ diff --git a/ace/Map_Manager.h b/ace/Map_Manager.h index 74ec2902f33..d9d1ea56ea1 100644 --- a/ace/Map_Manager.h +++ b/ace/Map_Manager.h @@ -140,11 +140,13 @@ public: int unbind (const EXT_ID &ext_id); // Unbind (remove) the <ext_id> from the map. Don't return the // <int_id> to the caller (this is useful for collections where the - // <int_id>s are *not* dynamically allocated...) + // <int_id>s are *not* dynamically allocated...) Returns 0 if + // successful, else -1. int unbind (const EXT_ID &ext_id, INT_ID &int_id); - // Break any association of <ext_id>. Returns the value of <int_id> in - // case the caller needs to deallocate memory. + // Break any association of <ext_id>. Returns the value of <int_id> + // in case the caller needs to deallocate memory. Returns 0 if + // successful, else -1. size_t current_size (void); // Return the current size of the map. diff --git a/ace/OS.cpp b/ace/OS.cpp index 42e24c9a72a..450c4d2f129 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -466,7 +466,19 @@ int ACE_OS::sched_params (const ACE_Sched_Params &sched_params) { // ACE_TRACE ("ACE_OS::sched_params"); -#if defined (ACE_HAS_STHREADS) +#if defined (CHORUS) + int result; + struct sched_param param; + ACE_thread_t thr_id = ACE_OS::thr_self (); + + param.sched_priority = sched_params.priority (); + + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, + sched_params.policy (), + ¶m), + result), + int, -1); +#elif defined (ACE_HAS_STHREADS) // Set priority class, priority, and quantum of this LWP or process as // specified in sched_params. @@ -631,19 +643,6 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params) // Set the thread priority on the current thread. return ACE_OS::thr_setprio (sched_params.priority ()); - -#elif defined (CHORUS) - int result; - struct sched_param param; - ACE_thread_t thr_id = ACE_OS::thr_self (); - - param.sched_priority = sched_params.priority (); - - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, - sched_params.policy (), - ¶m), - result), - int, -1); #else ACE_UNUSED_ARG (sched_params); ACE_NOTSUP_RETURN (-1); @@ -1281,6 +1280,14 @@ ACE_OS::thr_create (ACE_THR_FUNC func, stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE; # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ +# if defined (CHORUS) + // if it is a super actor, we can't set stacksize. + // But for the time bing we are all non-super actors + // To be fixed later + if (stacksize == 0) + stacksize = 0x100000; +# endif /*CHORUS */ + if (stacksize != 0) { size_t size = stacksize; @@ -1448,7 +1455,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (priority != ACE_DEFAULT_THREAD_PRIORITY) { struct sched_param sparam; - ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); # if defined (ACE_HAS_DCETHREADS) && !defined (ACE_HAS_SETKIND_NP) @@ -1473,32 +1479,42 @@ ACE_OS::thr_create (ACE_THR_FUNC func, sparam.sched_priority = priority; # endif -# if !defined (ACE_HAS_FSU_PTHREADS) - int retval = 0; +# if defined (ACE_HAS_FSU_PTHREADS) + if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY + && sparam.sched_priority <= PTHREAD_MAX_PRIORITY) + attr.prio = sparam.sched_priority; + else + { + pthread_attr_destroy (&attr); + errno = EINVAL; + return -1; + } +# else + { +# if defined (ACE_HAS_STHREADS) + // Solaris POSIX only allows priorities > 0 to + // ::pthread_attr_setschedparam. If a priority of 0 was + // requested, set the thread priority after creating it, below. + if (priority > 0) +# endif /* STHREADS */ + { # if defined (ACE_HAS_SETKIND_NP) - retval = ::pthread_attr_setsched (&attr, SCHED_OTHER); + result = ::pthread_attr_setsched (&attr, SCHED_OTHER); # else /* ACE_HAS_SETKIND_NP */ - retval = ::pthread_attr_setschedparam (&attr, &sparam); + result = ::pthread_attr_setschedparam (&attr, &sparam); # endif /* ACE_HAS_SETKIND_NP */ - if (retval != 0) - { + if (result != 0) + { # if defined (ACE_HAS_SETKIND_NP) - ::pthread_attr_delete (&attr); + ::pthread_attr_delete (&attr); # else /* ACE_HAS_SETKIND_NP */ - ::pthread_attr_destroy (&attr); + ::pthread_attr_destroy (&attr); # endif /* ACE_HAS_SETKIND_NP */ - errno = retval; - return -1; - } -# else - if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY - && sparam.sched_priority <= PTHREAD_MAX_PRIORITY) - attr.prio = sparam.sched_priority; - else - { - pthread_attr_destroy (&attr); - return -1; - } + errno = result; + return -1; + } + } + } # endif /* ACE_HAS_FSU_PTHREADS */ } @@ -1584,6 +1600,46 @@ ACE_OS::thr_create (ACE_THR_FUNC func, // ACE_thread_t and ACE_hthread_t are the same. if (result != -1) *thr_handle = *thr_id; + + // If the priority is 0, then we might have to set it now because we couldn't + // set it with ::pthread_attr_setschedparam, as noted above. This doesn't + // provide strictly correct behavior, because the thread was created + // (above) with the priority of its parent. (That applies regardless + // of the inherit_sched attribute: if it was PTHREAD_INHERIT_SCHED, then + // it certainly inherited its parent's priority. If it was + // PTHREAD_EXPLICIT_SCHED, then "attr" was initialized by the Solaris + // ::pthread_attr_init () to contain NULL for the priority, which indicated + // to Solaris ::pthread_create () to inherit the parent priority.) + if (priority == 0) + { + // Check the priority of this thread, which is the parent of the + // newly created thread. If it is 0, then the newly created thread + // will have inherited the priority of 0, so there's no need to + // explicitly set it. + struct sched_param sparam; + int policy = 0; + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (), + &policy, + &sparam), + result), int, + -1, result); + + if (sparam.sched_priority != 0) + { + ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); + // The memset to 0 sets the priority to 0, so we don't need + // to explicitly set sparam.sched_priority. + + // The only policy currently (version 2.5.1) supported by by Solaris + // is SCHED_OTHER, so that's hard-coded below. + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam ( + *thr_id, + SCHED_OTHER, + &sparam), + result), + int, -1); + } + } # else *thr_handle = ACE_OS::NULL_hthread; # endif /* ACE_HAS_STHREADS */ @@ -1603,15 +1659,28 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (result != -1) { + // With Solaris threads, ACE_thread_t and ACE_hthread_t are the same. + *thr_handle = *thr_id; + if (priority != ACE_DEFAULT_THREAD_PRIORITY) { // Set the priority of the new thread and then let it // continue, but only if the user didn't start it suspended // in the first place! - ACE_OS::thr_setprio (*thr_handle, priority); + if ((result = ACE_OS::thr_setprio (*thr_id, priority)) != 0) + { + errno = result; + return -1; + } if (start_suspended == 0) - ACE_OS::thr_continue (*thr_handle); + { + if ((result = ACE_OS::thr_continue (*thr_id)) != 0) + { + errno = result; + return -1; + } + } } } return result; @@ -190,7 +190,6 @@ private: #define ACE_MAX(x,y) (((x)>(y))?(x):(y)) #define ACE_MIN(x,y) (((x)<(y))?(x):(y)) - // keep the compiler from complaining of // parameters which are not used. #if defined (ghs) @@ -1073,7 +1072,11 @@ typedef pthread_mutex_t ACE_thread_mutex_t; # endif /* ACE_HAS_DCETHREADS */ # define THR_BOUND 0x00000001 +# if defined (CHORUS) +# define THR_NEW_LWP 0x00000000 +# else # define THR_NEW_LWP 0x00000002 +# endif /* CHORUS */ # define THR_DETACHED 0x00000040 # define THR_SUSPENDED 0x00000080 # define THR_DAEMON 0x00000100 @@ -1517,6 +1520,9 @@ struct utsname #define ACE_DEFAULT_GLOBALNAME_A "\\globalnames" #define ACE_DEFAULT_GLOBALNAME_W L"\\globalnames" +// Need to work around odd glitches with NT. +#define ACE_MAX_DEFAULT_PORT 65279 + // We're on WinNT or Win95 #define ACE_PLATFORM_A "Win32" #define ACE_PLATFORM_EXE_SUFFIX_A ".exe" @@ -1735,6 +1741,9 @@ typedef char TCHAR; #define RUSAGE_SELF 1 #endif /* m88k */ +// Default port is MAX_SHORT. +#define ACE_MAX_DEFAULT_PORT 65535 + // Default semaphore key #define ACE_DEFAULT_SEM_KEY 1234 #define ACE_INVALID_SEM_KEY -1 @@ -2076,6 +2085,9 @@ extern "C" #if defined (ACE_HAS_STHREADS) #include /**/ <sys/priocntl.h> +#if defined (ACE_LACKS_PRI_T) +typedef int pri_t; +#endif /* ACE_LACKS_PRI_T */ typedef id_t ACE_id_t; typedef pri_t ACE_pri_t; #else @@ -2560,6 +2572,13 @@ struct ACE_Export ACE_Str_Buf : public strbuf // Constructor. }; +#if defined (ACE_HAS_BROKEN_BITSHIFT) +#define ACE_MSB_MASK (~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1))) +#else +// This needs to go here to avoid overflow problems on some compilers. +#define ACE_MSB_MASK (~(1 << (NFDBITS - 1))) +#endif /* ACE_HAS_BROKEN_BITSHIFT */ + class ACE_Export ACE_OS // = TITLE // This class defines an operating system independent @@ -2714,9 +2733,14 @@ public: #undef getpwnam_r #endif /* ACE_HAS_BROKEN_R_ROUTINES */ +#if defined (difftime) +#define ACE_DIFFTIME(t1, t0) difftime(t1,t0) +#undef difftime +#endif /* difftime */ + // = A set of wrappers for operations on time. - static time_t time (time_t *tloc); static double difftime (time_t t1, time_t t0); + static time_t time (time_t *tloc); static time_t mktime (struct tm *timeptr); static struct tm *localtime (const time_t *clock); static struct tm *localtime_r (const time_t *clock, struct tm *res); @@ -912,11 +912,12 @@ ACE_OS::unlink (const char *path) #endif /* VXWORKS */ } + ACE_INLINE char * ACE_OS::tempnam (const char *dir, const char *pfx) { // ACE_TRACE ("ACE_OS::tempnam"); -#if defined (VXWORKS) +#if defined (VXWORKS) || defined (ACE_LACKS_TEMPNAM) ACE_NOTSUP_RETURN (0); #else #if defined (WIN32) @@ -927,6 +928,7 @@ ACE_OS::tempnam (const char *dir, const char *pfx) #endif /* VXWORKS */ } + ACE_INLINE LPTSTR ACE_OS::cuserid (LPTSTR user, size_t maxlen) { @@ -4152,9 +4154,16 @@ ACE_OS::thr_min_stack (void) // ACE_TRACE ("ACE_OS::thr_min_stack"); #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_STHREADS) +#if defined (ACE_HAS_THR_MINSTACK) + // Tandem did some weirdo mangling of STHREAD names... + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_minstack (), + ace_result_), + int, -1); +#else ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_min_stack (), - ace_result_), - int, -1); + ace_result_), + int, -1); +#endif /* !ACE_HAS_THR_MINSTACK */ #elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_HAS_SETKIND_NP) #if defined (ACE_HAS_IRIX62_THREADS) return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN); @@ -5078,6 +5087,13 @@ ACE_OS::dlsym (void *handle, ACE_DL_TYPE symbolname) #if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) #if defined (ACE_LACKS_POSIX_PROTO) ACE_OSCALL_RETURN (::dlsym (handle, (char*) symbolname), void *, 0); +#elif defined (ACE_USES_ASM_SYMBOL_IN_DLSYM) + char asm_symbolname [MAXPATHLEN] ; + if (strlen (symbolname) + 2 > sizeof asm_symbolname) + return 0 ; + ACE_OS::strcpy (asm_symbolname, "_") ; + ACE_OS::strcpy (asm_symbolname + 1, symbolname) ; + ACE_OSCALL_RETURN (::dlsym (handle, asm_symbolname), void *, 0); #else ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); #endif /* ACE_LACKS_POSIX_PROTO */ @@ -5649,12 +5665,18 @@ ACE_OS::open (const char *filename, #endif /* ACE_WIN32 */ } + ACE_INLINE double ACE_OS::difftime (time_t t1, time_t t0) { +#if defined (ACE_DIFFTIME) + return ACE_DIFFTIME(t1, t0); +#else return ::difftime (t1, t0); +#endif /* ACE_DIFFTIME */ } + ACE_INLINE char * ACE_OS::ctime (const time_t *t) { @@ -6393,7 +6415,7 @@ ACE_OS::sleep (u_int seconds) #if defined (ACE_WIN32) ::Sleep (seconds * 1000); return 0; -#elif defined (VXWORKS) +#elif defined (ACE_HAS_CLOCK_GETTIME) struct timespec rqtp; // Initializer doesn't work with Green Hills 1.8.7 rqtp.tv_sec = seconds; @@ -6833,8 +6855,14 @@ ACE_OS::sigaddset (sigset_t *s, int signum) #if !defined (ACE_LACKS_SIGSET) ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1); #else - if (signum < 1 || signum > NSIG) - return 1 ; // Invalid signum, return error + if (s == NULL) { + errno = EFAULT ; + return -1 ; + } + if (signum < 1 || signum > NSIG) { + errno = EINVAL ; + return -1 ; // Invalid signum, return error + } *s |= (1 << (signum - 1)) ; return 0 ; #endif /* !ACE_LACKS_SIGSET */ @@ -6846,8 +6874,14 @@ ACE_OS::sigdelset (sigset_t *s, int signum) #if !defined (ACE_LACKS_SIGSET) ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1); #else - if (signum < 1 || signum > NSIG) - return 1 ; // Invalid signum, return error + if (s == NULL) { + errno = EFAULT ; + return -1 ; + } + if (signum < 1 || signum > NSIG) { + errno = EINVAL ; + return -1 ; // Invalid signum, return error + } *s &= ~(1 << (signum - 1)) ; return 0 ; #endif /* !ACE_LACKS_SIGSET */ @@ -6859,6 +6893,10 @@ ACE_OS::sigemptyset (sigset_t *s) #if !defined (ACE_LACKS_SIGSET) ACE_OSCALL_RETURN (::sigemptyset (s), int, -1); #else + if (s == NULL) { + errno = EFAULT ; + return -1 ; + } *s = 0 ; return 0 ; #endif /* !ACE_LACKS_SIGSET */ @@ -6870,6 +6908,10 @@ ACE_OS::sigfillset (sigset_t *s) #if !defined (ACE_LACKS_SIGSET) ACE_OSCALL_RETURN (::sigfillset (s), int, -1); #else + if (s == NULL) { + errno = EFAULT ; + return -1 ; + } *s = ~(sigset_t) 0 ; return 0 ; #endif /* !ACE_LACKS_SIGSET */ @@ -6881,8 +6923,14 @@ ACE_OS::sigismember (sigset_t *s, int signum) #if !defined (ACE_LACKS_SIGSET) ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1); #else - if (signum < 1 || signum > NSIG) - return 1 ; // Invalid signum, return error + if (s == NULL) { + errno = EFAULT ; + return -1 ; + } + if (signum < 1 || signum > NSIG) { + errno = EINVAL ; + return -1 ; // Invalid signum, return error + } return ((*s & (1 << (signum - 1))) != 0) ; #endif /* !ACE_LACKS_SIGSET */ } diff --git a/ace/Process.cpp b/ace/Process.cpp index 8f71a7c2941..3e6dd376221 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -280,8 +280,6 @@ ACE_Process::spawn (ACE_Process_Options &options) // Server process. The fork succeeded. return this->child_id_; } - - return 0; #endif /* ACE_WIN32 */ } @@ -635,7 +633,7 @@ ACE_Process_Options::command_line_argv (void) return command_line_argv_; } -char ** +char * const * ACE_Process_Options::env_argv (void) { return environment_argv_; diff --git a/ace/Process.h b/ace/Process.h index cd3ef49cba4..6295c606a63 100644 --- a/ace/Process.h +++ b/ace/Process.h @@ -137,7 +137,7 @@ public: // and returned with each entry pointing to the start of // null-terminated string. Returns { 0 } if nothing has been set. - char **env_argv (void); + char * const *env_argv (void); // argv-style array of environment settings. // = Accessors for the standard handles. diff --git a/ace/README b/ace/README index 6f7f7c56e43..18e453add2f 100644 --- a/ace/README +++ b/ace/README @@ -57,6 +57,7 @@ ACE_HAS_IP_MULTICAST Platform supports IP multicast ACE_HAS_IRIX_GETTIMEOFDAY Denotes that IRIX 5.3 has second argument to gettimeofday() which is variable ... ACE_HAS_IRIX62_THREADS Platform supports the very odd IRIX 6.2 threads... ACE_HAS_THR_KEYDELETE Platform supports thr_keydelete (e.g,. UNIXWARE) +ACE_HAS_THR_MINSTACK Platform calls thr_minstack() rather than thr_min_stack() (e.g., Tandem). ACE_HAS_LIMITED_RUSAGE_T The rusage_t structure has only two fields. ACE_HAS_LONGLONG_T Compiler/platform supports the "long long" datatype. ACE_HAS_LONG_MAP_FAILED Platform defines MAP_FAILED as a long constant. @@ -162,6 +163,7 @@ ACE_HAS_XLI Platform has the XLI version of TLI ACE_HAS_XT Platform has Xt and Motif ACE_HAS_YIELD_VOID_PTR Platform requires pthread_yield() to take a NULL. ACE_LACKS_ACCESS Platform lacks access() (e.g., VxWorks and Chorus) +ACE_LACKS_ACE_IOSTREAM Platform can not build ace/IOStream{,_T}.cpp. This does not necessarily mean that the platform does not support iostreams. ACE_LACKS_CONST_STRBUF_PTR Platform uses struct strbuf * rather than const struct strbuf * (e.g., HP/UX 10.x) ACE_LACKS_CONST_TIMESPEC_PTR Platform forgot const in cond_timewait (e.g., HP/UX). ACE_LACKS_COND_T Platform lacks condition variables (e.g., Win32 and VxWorks) @@ -170,7 +172,6 @@ ACE_LACKS_EXEC Platform lacks the exec() family of system calls (e.g., Win32, ACE_LACKS_FILELOCKS Platform lacks file locking mechanism ACE_LACKS_GETPGID Platform lacks getpgid() call (e.g., Win32, Chorus, and FreeBSD). ACE_LACKS_GETSERVBYNAME Platforms lacks getservbyname() (e.g., VxWorks and Chorus). -ACE_LACKS_IOSTREAM_SETGET Platforms lacks IOStream get/set operators (e.g., SGI IRIX 6.2). ACE_LACKS_IOSTREAM_FX iostream header does not declare ipfx (), opfx (), etc. ACE_LACKS_LINEBUFFERED_STREAMBUF Platform lacks streambuf "linebuffered ()". ACE_LACKS_MADVISE Platform lacks madvise() (e.g., Linux) @@ -188,6 +189,7 @@ ACE_LACKS_NETDB_REENTRANT_FUNCTIONS Platform does not support reentrant netdb fu ACE_LACKS_RPC_H Platform lacks the ONC RPC header files. ACE_LACKS_PARAM_H Platform lacks <sys/param.h> (e.g., MVS) ACE_LACKS_POSIX_PROTO Platform lacks POSIX prototypes for certain System V functions like shared memory and message queues. +ACE_LACKS_PRI_T Platform lacks pri_t (e.g., Tandem NonStop UNIX). ACE_LACKS_PTHREAD_CANCEL Platform lacks pthread_cancel(). ACE_LACKS_PTHREAD_THR_SIGSETMASK Platform lacks pthread_thr_sigsetmask (e.g., MVS, HP/UX, and OSF/1 3.2) ACE_LACKS_PWD_REENTRANT_FUNCTIONS Platform lacks getpwnam_r() methods (e.g., SGI 6.2). @@ -238,6 +240,7 @@ ACE_TEMPLATES_REQUIRE_PRAGMA Compiler's template mechanism must use a pragma Th ACE_TEMPLATES_REQUIRE_SOURCE Compiler's template mechanim must see source code (i.e., .cpp files). This is used for GNU G++. ACE_TEMPLATES_REQUIRE_SPECIALIZATION Compiler's template mechanism requires the use of explicit C++ specializations for all used templates. This is also used for GNU G++ if you don't use the "repo" patches. ACE_USE_POLL Use the poll() event demultiplexor rather than select(). +ACE_USES_ASM_SYMBOL_IN_DLSYM Platform uses assembly symbols instead of C symbols in dlsym() ACE_WSOCK_VERSION A parameter list indicating the version of WinSock (e.g., "1, 1" is version 1.1). ---------------------------------------- diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 70b04a8a371..0ccb58321c6 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -212,7 +212,7 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, break; } // Here's the first free slot, so let's take it. - else if (ACE_REACTOR_EVENT_HANDLER (this, i) == ACE_INVALID_HANDLE + else if (ACE_REACTOR_HANDLE (i) == ACE_INVALID_HANDLE && assigned_slot == -1) assigned_slot = i; } @@ -1031,9 +1031,9 @@ ACE_Reactor::remove_handler_i (const ACE_Handle_Set &handles, ACE_TRACE ("ACE_Reactor::remove_handler_i"); ACE_HANDLE h; - for (ACE_Handle_Set_Iterator handle_iter (handles); - (h = handle_iter ()) != ACE_INVALID_HANDLE; - ++handle_iter) + ACE_Handle_Set_Iterator handle_iter (handles); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->remove_handler_i (h, mask) == -1) return -1; @@ -1048,9 +1048,8 @@ ACE_Reactor::register_handler_i (const ACE_Handle_Set &handles, ACE_TRACE ("ACE_Reactor::register_handler_i"); ACE_HANDLE h; - for (ACE_Handle_Set_Iterator handle_iter (handles); - (h = handle_iter ()) != ACE_INVALID_HANDLE; - ++handle_iter) + ACE_Handle_Set_Iterator handle_iter (handles); + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->register_handler_i (h, handler, mask) == -1) return -1; @@ -1427,16 +1426,15 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, { ACE_HANDLE handle; - // Handle output events (this code needs to come first - // to handle the obscure case of piggy-backed data - // coming along with the final handshake message of a - // nonblocking connection). + // Handle output events (this code needs to come first to handle + // the obscure case of piggy-backed data coming along with the + // final handshake message of a nonblocking connection). + + ACE_Handle_Set_Iterator handle_iter_wr (dispatch_set.wr_mask_); - for (ACE_Handle_Set_Iterator handle_iter_wr (dispatch_set.wr_mask_); - (handle = handle_iter_wr ()) != ACE_INVALID_HANDLE + while ((handle = handle_iter_wr ()) != ACE_INVALID_HANDLE && number_dispatched < number_of_active_handles - && this->state_changed_ == 0; - ++handle_iter_wr) + && this->state_changed_ == 0) { number_dispatched++; this->notify_handle (handle, @@ -1461,11 +1459,12 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, ACE_HANDLE handle; // Handle "exceptional" events. - for (ACE_Handle_Set_Iterator handle_iter_ex (dispatch_set.ex_mask_); - (handle = handle_iter_ex ()) != ACE_INVALID_HANDLE + + ACE_Handle_Set_Iterator handle_iter_ex (dispatch_set.ex_mask_); + + while ((handle = handle_iter_ex ()) != ACE_INVALID_HANDLE && number_dispatched < number_of_active_handles - && this->state_changed_ == 0; - ++handle_iter_ex) + && this->state_changed_ == 0) { this->notify_handle (handle, ACE_Event_Handler::EXCEPT_MASK, @@ -1475,6 +1474,7 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, number_dispatched++; } } + if (number_dispatched > 0) { number_of_active_handles -= number_dispatched; @@ -1489,11 +1489,12 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, ACE_HANDLE handle; // Handle input, passive connection, and shutdown events. - for (ACE_Handle_Set_Iterator handle_iter_rd (dispatch_set.rd_mask_); - (handle = handle_iter_rd ()) != ACE_INVALID_HANDLE + + ACE_Handle_Set_Iterator handle_iter_rd (dispatch_set.rd_mask_); + + while ((handle = handle_iter_rd ()) != ACE_INVALID_HANDLE && number_dispatched < number_of_active_handles - && this->state_changed_ == 0; - ++handle_iter_rd) + && this->state_changed_ == 0) { this->notify_handle (handle, ACE_Event_Handler::READ_MASK, @@ -1503,9 +1504,11 @@ ACE_Reactor::dispatch_io_handlers (int &number_of_active_handles, number_dispatched++; } } + if (number_dispatched > 0) { number_of_active_handles -= number_dispatched; + if (this->state_changed_) return -1; } @@ -1569,7 +1572,7 @@ ACE_Reactor::dispatch (int number_of_active_handles, break; // State has changed, exit inner loop. else if (this->dispatch_io_handlers (number_of_active_handles, dispatch_set) == -1) - // State has changed exit inner loop. + // State has changed, so exit the inner loop. break; } diff --git a/ace/Sched_Params.cpp b/ace/Sched_Params.cpp index 35b7bcdf5cf..a6e5553f71e 100644 --- a/ace/Sched_Params.cpp +++ b/ace/Sched_Params.cpp @@ -63,17 +63,11 @@ ACE_Sched_Params::priority_min (const Policy policy, // pcinfo.pc_clinfo)->ts_maxupri. The minimum priority is just // the negative of that. - int priority = -((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri; - - // Don't return priority of 0, because that can't be used with - // ::pthread_attr_setschedparam on Solaris 2.5.1. - return priority == 0 ? 1 : 0; + return -((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri; } else { - // Don't return priority of 0, because that can't be used with - // ::pthread_attr_setschedparam on Solaris 2.5.1. - return 1; + return 0; } #elif defined (ACE_HAS_DCETHREADS) || defined(ACE_HAS_PTHREADS) && !defined(ACE_LACKS_SETSCHED) @@ -86,7 +80,9 @@ ACE_Sched_Params::priority_min (const Policy policy, return ACE_THR_PRI_FIFO_MIN; case ACE_SCHED_RR: return ACE_THR_PRI_RR_MIN; - case ACE_SCHED_OTHER: +#if !defined (CHORUS) // SCHED_OTHRE and SCHED_RR have same value + case ACE_SCHED_OTHER: +#endif /* CHORUS */ default: return ACE_THR_PRI_OTHER_MIN; } @@ -99,7 +95,9 @@ ACE_Sched_Params::priority_min (const Policy policy, return ACE_PROC_PRI_FIFO_MIN; case ACE_SCHED_RR: return ACE_PROC_PRI_RR_MIN; - case ACE_SCHED_OTHER: +#if !defined (CHORUS) // SCHED_OTHRE and SCHED_RR have same value + case ACE_SCHED_OTHER: +#endif /* CHORUS */ default: return ACE_PROC_PRI_OTHER_MIN; } @@ -164,7 +162,9 @@ ACE_Sched_Params::priority_max (const Policy policy, return ACE_THR_PRI_FIFO_MAX; case ACE_SCHED_RR: return ACE_THR_PRI_RR_MAX; - case ACE_SCHED_OTHER: +#if !defined (CHORUS) // SCHED_OTHRE and SCHED_RR have same value + case ACE_SCHED_OTHER: +#endif /* CHORUS */ default: return ACE_THR_PRI_OTHER_MAX; } @@ -177,7 +177,9 @@ ACE_Sched_Params::priority_max (const Policy policy, return ACE_PROC_PRI_FIFO_MAX; case ACE_SCHED_RR: return ACE_PROC_PRI_RR_MAX; - case ACE_SCHED_OTHER: +#if !defined (CHORUS) // SCHED_OTHRE and SCHED_RR have same value + case ACE_SCHED_OTHER: +#endif /* CHORUS */ default: return ACE_PROC_PRI_OTHER_MAX; } diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index ac486095846..b5d96080c9b 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -289,7 +289,7 @@ protected: ACE_Task_Base *task = 0); // Create a new thread (must be called with locks held). -private: +protected: int resize (size_t); // Resize the pool of Thread_Descriptors. diff --git a/ace/config-chorus.h b/ace/config-chorus.h index 7008b8a62c6..ea98287a098 100644 --- a/ace/config-chorus.h +++ b/ace/config-chorus.h @@ -33,6 +33,7 @@ // got struct timespec #define ACE_HAS_POSIX_TIME +#define ACE_HAS_CLOCK_GETTIME #define ACE_LACKS_STRRECVFD #define ACE_HAS_CPLUSPLUS_HEADERS @@ -47,7 +48,8 @@ // Platforms lacks UNIX domain sockets. #define ACE_LACKS_UNIX_DOMAIN_SOCKETS #define ACE_LACKS_UTSNAME_T -#define ACE_LACKS_SETSCHED +#define ACE_HAS_PTHREADS_1003_DOT_1C +//#define ACE_LACKS_SETSCHED #define ACE_LACKS_MSYNC #define ACE_LACKS_MADVISE diff --git a/ace/config-freebsd-pthread.h b/ace/config-freebsd-pthread.h index d1e1311cdc7..9708973eda4 100644 --- a/ace/config-freebsd-pthread.h +++ b/ace/config-freebsd-pthread.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -// config-freebsd-pthread.h +// $Id$ // ***** This configuration file is still under debugging. ***** // ***** It still doesn't work quite the way it expected to. ***** @@ -22,6 +22,18 @@ #define ACE_LACKS_GETPGID #define ACE_LACKS_RWLOCK_T #define ACE_HAS_SIG_MACROS +#define ACE_HAS_CHARPTR_DL +#define ACE_USES_ASM_SYMBOL_IN_DLSYM + +// sched.h still not fully support on FreeBSD ? +// this is taken from /usr/src/lib/libc_r/uthread/pthread-private.h +enum schedparam_policy { + SCHED_RR, + SCHED_IO, + SCHED_FIFO, + SCHED_OTHER +}; + // Platform supports POSIX timers via timestruct_t. #define ACE_HAS_POSIX_TIME #define ACE_NEEDS_SYSTIME_H diff --git a/ace/config-freebsd.h b/ace/config-freebsd.h index 7c81d324656..5b9e8c426c7 100644 --- a/ace/config-freebsd.h +++ b/ace/config-freebsd.h @@ -22,6 +22,8 @@ #define ACE_LACKS_GETPGID #define ACE_LACKS_RWLOCK_T #define ACE_HAS_SIG_MACROS +#define ACE_HAS_CHARPTR_DL +#define ACE_USES_ASM_SYMBOL_IN_DLSYM // This is for 2.1.x only. By default, gcc defines __FreeBSD__ automatically #if defined(FreeBSD_2_1) diff --git a/ace/config-hpux-9.x-orbix.h b/ace/config-hpux-9.x-orbix.h index 8684a385aab..4a3395e01d3 100644 --- a/ace/config-hpux-9.x-orbix.h +++ b/ace/config-hpux-9.x-orbix.h @@ -90,6 +90,8 @@ // Platform has the XLI version of ACE_TLI. // #define ACE_HAS_XLI +#define ACE_LACKS_ACE_IOSTREAM + #define ACE_NEEDS_DEV_IO_CONVERSION // Turns off the tracing feature. diff --git a/ace/config-hpux-9.x.h b/ace/config-hpux-9.x.h index 43ba829af2e..6ec331e3dee 100644 --- a/ace/config-hpux-9.x.h +++ b/ace/config-hpux-9.x.h @@ -16,7 +16,9 @@ #define ACE_HAS_BROKEN_HPUX_TEMPLATES #endif /* __cplusplus < 199707L */ -#define ACE_HAS_BROKEN_ENUM +#define ACE_HAS_BROKEN_ENUMS +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_GETPGID #define ACE_HAS_BROKEN_CONVERSIONS // They forgot a const in the prototype of const_timewait... @@ -87,6 +89,8 @@ // Platform has the XLI version of ACE_TLI. // #define ACE_HAS_XLI +#define ACE_LACKS_ACE_IOSTREAM + #define ACE_NEEDS_DEV_IO_CONVERSION // Turns off the tracing feature. diff --git a/ace/config-irix6.2-sgic++-nothreads.h b/ace/config-irix6.2-sgic++-nothreads.h index bed586602ab..60cfbb2d61f 100644 --- a/ace/config-irix6.2-sgic++-nothreads.h +++ b/ace/config-irix6.2-sgic++-nothreads.h @@ -17,7 +17,7 @@ // Include XtReactor into the library. #define ACE_HAS_XT -#define ACE_LACKS_IOSTREAM_SETGET +#define ACE_LACKS_SIGNED_CHAR // Platform supports getpagesize() call. #define ACE_HAS_GETPAGESIZE diff --git a/ace/config-irix6.2-sgic++.h b/ace/config-irix6.2-sgic++.h index d60e0e9c3c0..a82bddb1c63 100644 --- a/ace/config-irix6.2-sgic++.h +++ b/ace/config-irix6.2-sgic++.h @@ -13,7 +13,7 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H -#define ACE_LACKS_IOSTREAM_SETGET +#define ACE_LACKS_SIGNED_CHAR #define ACE_HAS_P_READ_WRITE #define ACE_HAS_IRIX62_THREADS #define ACE_HAS_PTHREAD_SIGMASK diff --git a/apps/Gateway/Gateway/proxy_config b/apps/Gateway/Gateway/proxy_config index e0784e4038e..54343cb0e73 100644 --- a/apps/Gateway/Gateway/proxy_config +++ b/apps/Gateway/Gateway/proxy_config @@ -35,7 +35,7 @@ # ID Port Role Timeout Port # ---- -------- ------ ------ ---------- ----- -------- 1 merengue.cs 10010 S 32 0 1 - 2 tango.cs 10010 C 32 0 1 + 2 flamenco.cs 10010 C 32 0 1 # 3 mambo.cs 10002 C 32 0 1 # 4 lambada.cs 10002 C 32 0 1 # 5 lambada.cs 10002 C 32 0 1 diff --git a/apps/JAWS/server/ChangeLog b/apps/JAWS/server/ChangeLog index 800871337d0..03cd5224b06 100644 --- a/apps/JAWS/server/ChangeLog +++ b/apps/JAWS/server/ChangeLog @@ -1,3 +1,53 @@ +Fri May 23 00:45:24 1997 James C Hu <jxh@lambada.cs.wustl.edu> + + * JAWS/server: Debugged HTTP/0.9 GET requests, and HTTP/1.0 PUT + requests. Both work now, with minor problems: e.g. the + Content-type header doesn't really work (always sends text/html + as the content type). What it should do is see if the request + included a content type header, and use it, otherwise, resort to + some file suffix and mimetype matching algorithm. + + * Parse_Headers.h (complete_header_line): Added comments + explaining the new return values of -1, 0 and 1 (see comments + for Parse_Headers.cpp below). + + * Parse_Headers.cpp (complete_header_line): modified so that it + returns three values instead of two. -1 means that an end of + line was encountered, but nothing after it yet to verify if it + is really a complete header line. 0 means the read cut off in + the middle of a line (no end of line character found). 1 means + the line is verified to be a complete header line. + + * HTTP_Request.cpp (parse_request): Changed the test so that an + HTTP/0.9 request would be sent immediately after being issued. + This involved changes to Parse_Headers. + + * JAWS_File.cpp (acquire): Changes involved adding some debugging + statements to understand why PUT was not working. Discovered a + bug in how ACE_Mem_Map was being used. + + * HTTP_Request.cpp (content_length): Changed to extract value from + the headers, if available. + +Thu May 22 16:22:03 1997 James C. Hu <jxh@pride.cs.wustl.edu> + + * HTTP_Request.cpp (cgi_env): Added a cast so that a warning + generated by SGI C++ compiler goes away. + + * Makefile: Reordered the way the files are compiled/linked so + that useless warnings about object files not resolving any + symbols go away. + +Wed May 21 15:33:33 1997 James C Hu <jxh@polka.cs.wustl.edu> + + * JAWS_File.{h,cpp}: Added some comments. Will add a copy () + method soon, after I move my workspace over to lambada. + + * JAWS_Tilde.{h,cpp}: This class is being implemented but has not + been added to the repository yet, since JAWS as yet does not use + it, and it is still being developed. This will be a cache of + the expansions from ~foo to the home directory of foo. + Tue May 20 22:49:24 1997 James C Hu <jxh@polka.cs.wustl.edu> * JAWS_File.{h,cpp}: New class created to replace the old kludgy diff --git a/apps/JAWS/server/HTTP_Request.cpp b/apps/JAWS/server/HTTP_Request.cpp index 5c1fa5e4772..6dfa30c882b 100644 --- a/apps/JAWS/server/HTTP_Request.cpp +++ b/apps/JAWS/server/HTTP_Request.cpp @@ -60,20 +60,21 @@ HTTP_Request::parse_request (ACE_Message_Block &mb) // In Apache, they assume that each header line should not exceed 8K. - if (this->headers_.complete_header_line (mb.rd_ptr ())) + int result = this->headers_.complete_header_line (mb.rd_ptr ()); + if (result != 0) { if (!this->got_request_line ()) { this->parse_request_line (mb.rd_ptr ()); - while (this->headers_.complete_header_line (mb.rd_ptr ())) + while (this->headers_.complete_header_line (mb.rd_ptr ()) > 0) this->headers_.parse_header_line (mb.rd_ptr ()); } - else + else if (result > 0) do { this->headers_.parse_header_line (mb.rd_ptr ()); } - while (this->headers_.complete_header_line (mb.rd_ptr ())); + while (this->headers_.complete_header_line (mb.rd_ptr ()) > 0); } mb.wr_ptr (strlen(mb.rd_ptr ()) - mb.length ()); @@ -104,8 +105,6 @@ HTTP_Request::parse_request_line (char * const request_line) *ptr = '\0'; ptr += offset; - ACE_DEBUG ((LM_DEBUG, " (%t) request being parsed: %s\n", buf)); - char *lasts; // for strtok_r // Get the request type. @@ -132,7 +131,7 @@ HTTP_Request::parse_request_line (char * const request_line) this->method (), this->uri (), (this->version () ? this->version () : "HTTP/0.9"))); - ACE_OS::memmove (buf, ptr, ACE_OS::strlen (ptr)); + ACE_OS::memmove (buf, ptr, ACE_OS::strlen (ptr)+1); } int @@ -186,10 +185,10 @@ HTTP_Request::cgi (void) const return this->cgi_; } -const char * const * +const char ** HTTP_Request::cgi_env (void) const { - return this->cgi_env_; + return (const char **)this->cgi_env_; } const char * @@ -269,7 +268,12 @@ HTTP_Request::data_length (void) int HTTP_Request::content_length (void) { - return content_length_; + if (this->content_length_ == -1) + { + const char * clv = this->headers_["Content-length"]; + this->content_length_ = (clv ? ACE_OS::atoi (clv) : 0); + } + return this->content_length_; } int diff --git a/apps/JAWS/server/HTTP_Request.h b/apps/JAWS/server/HTTP_Request.h index 25d5c13e309..018cf2878f6 100644 --- a/apps/JAWS/server/HTTP_Request.h +++ b/apps/JAWS/server/HTTP_Request.h @@ -40,7 +40,7 @@ public: int cgi (void) const; const char * cgi_args (void) const; - const char * const * cgi_env (void) const; + const char ** cgi_env (void) const; const char * query_string (void) const; const char * path_info (void) const; diff --git a/apps/JAWS/server/JAWS_File.cpp b/apps/JAWS/server/JAWS_File.cpp index a0d2d62567a..8a32a6c4a82 100644 --- a/apps/JAWS/server/JAWS_File.cpp +++ b/apps/JAWS/server/JAWS_File.cpp @@ -25,10 +25,11 @@ static const int READ_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | static const int WRITE_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED | O_RDWR | - O_CREAT); + O_CREAT | + O_TRUNC); #else static const int READ_FLAGS = O_RDONLY; -static const int WRITE_FLAGS = O_RDWR | O_CREAT; +static const int WRITE_FLAGS = O_RDWR | O_CREAT | O_TRUNC; #endif /* ACE_WIN32 */ // static data members @@ -37,18 +38,16 @@ JAWS_File_Handle::vfs_ = JAWS_Virtual_Filesystem::instance (); JAWS_Virtual_Filesystem * JAWS_Virtual_Filesystem::cvf_ = 0; ACE_SYNCH_MUTEX JAWS_Virtual_Filesystem::lock_; +// this is how you make data opaque in C++ +// I'd like to do this with JAWS_File too, but Doug would pro'ly kill me class JAWS_Virtual_Filesystem_Singleton { public: JAWS_Virtual_Filesystem_Singleton (void) - { - this->singleton_ = JAWS_Virtual_Filesystem::instance (); - } + { this->singleton_ = JAWS_Virtual_Filesystem::instance (); } ~JAWS_Virtual_Filesystem_Singleton (void) - { - delete this->singleton_; - } + { delete this->singleton_; } private: JAWS_Virtual_Filesystem * singleton_; @@ -91,18 +90,23 @@ JAWS_File_Handle::~JAWS_File_Handle (void) { if (this->handle_ != ACE_INVALID_HANDLE) { + // this was dup ()'d ACE_OS::close (this->handle_); } + if (this->file_ != 0) { switch (this->file_->action ()) { case JAWS_File::WRITING: this->file_->release (); + // assert (this->file_->reference_count () == 0); + // put it into the CVF this->vfs_->replace (this->file_); break; case JAWS_File::WAITING: + // last one using a stale file is resposible for deleting it if (this->file_->release () == 0) delete this->file_; break; @@ -384,13 +388,14 @@ JAWS_File::acquire (void) this->handle_ = ACE_OS::open (this->tempname_, READ_FLAGS, R_MASK); if (this->handle_ == ACE_INVALID_HANDLE) { - this->error (JAWS_File::OPEN_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: open"); } else if (this->mmap_.map (this->handle_, -1, - PROT_READ, MAP_PRIVATE) != 0 - || this->mmap_.map (this->tempname_) != 0) + PROT_READ, MAP_PRIVATE) != 0) { - this->error (JAWS_File::MEMMAP_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::MEMMAP_FAILED, + "JAWS_File::acquire: map"); ACE_OS::close (this->handle_); this->handle_ = ACE_INVALID_HANDLE; } @@ -401,12 +406,28 @@ JAWS_File::acquire (void) this->handle_ = ACE_OS::open (this->tempname_, WRITE_FLAGS, W_MASK); if (this->handle_ == ACE_INVALID_HANDLE) { - this->error (JAWS_File::OPEN_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: open"); + } + else if (ACE_OS::lseek (this->handle_, this->size_ - 1, SEEK_SET) + == -1) + { + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: lseek"); + ACE_DEBUG ((LM_DEBUG, "hey--> %d, %u, %d\n", this->handle_, this->size_, SEEK_SET)); + ACE_OS::close (this->handle_); + } + else if (ACE_OS::write (this->handle_, "", 1) != 1) + { + this->error (JAWS_File::WRITE_FAILED, + "JAWS_File::acquire: write"); + ACE_OS::close (this->handle_); } else if (this->mmap_.map (this->handle_, this->size_, PROT_RDWR, MAP_SHARED) != 0) { - this->error (JAWS_File::MEMMAP_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::MEMMAP_FAILED, + "JAWS_File::acquire: map"); ACE_OS::close (this->handle_); } break; @@ -497,7 +518,7 @@ JAWS_File::error (void) const int JAWS_File::error (int error_value, const char * s) { - ACE_ERROR ((LM_ERROR, "%p memory mapping for read.\n", s)); + ACE_ERROR ((LM_ERROR, "%p.\n", s)); return (this->error_ = error_value); } diff --git a/apps/JAWS/server/JAWS_File.h b/apps/JAWS/server/JAWS_File.h index 318f408e0fc..a327b57c444 100644 --- a/apps/JAWS/server/JAWS_File.h +++ b/apps/JAWS/server/JAWS_File.h @@ -35,7 +35,7 @@ class JAWS_File_Handle // E.g. 1, // { // JAWS_File_Handle foo("foo.html"); - // this->peer ().send (foo.file ().map (), foo.file ().size ()); + // this->peer ().send (foo.address (), foo.size ()); // } // E.g. 2, @@ -47,7 +47,7 @@ class JAWS_File_Handle // E.g. 3, // { // JAWS_File_Handle foo("foo.html", content_length); - // this->peer ().recv (foo.map (), content_length); + // this->peer ().recv (foo.address (), content_length); // } { public: @@ -142,7 +142,8 @@ private: class JAWS_File // = TITLE // Abstraction over a real file. This is what the Virtual Filesystem - // contains. + // contains. This class is not intended for general consumption. + // Please consult a physician before attempting to use this class. { public: diff --git a/apps/JAWS/server/Parse_Headers.cpp b/apps/JAWS/server/Parse_Headers.cpp index 6c20f671b09..545843938b3 100644 --- a/apps/JAWS/server/Parse_Headers.cpp +++ b/apps/JAWS/server/Parse_Headers.cpp @@ -60,6 +60,10 @@ Headers::complete_header_line (char * const header_line) // Else, if the next character is printable, we have a complete header line. // Else, presumably the next character is '\0', so the header is incomplete. + // return -1 if end of line but not complete header line + // return 0 if no end of line marker + // return 1 if complete header line + ptr = header_line; if (! this->end_of_line (ptr, offset)) return 0; @@ -83,7 +87,7 @@ Headers::complete_header_line (char * const header_line) default: if (isalpha (ptr[offset])) return 1; - else return 0; + else return -1; } } while (this->end_of_line (ptr, offset)); diff --git a/apps/JAWS/server/Parse_Headers.h b/apps/JAWS/server/Parse_Headers.h index 2baec2862f9..e06cde86a16 100644 --- a/apps/JAWS/server/Parse_Headers.h +++ b/apps/JAWS/server/Parse_Headers.h @@ -78,7 +78,11 @@ public: void recognize (const char * const header); void parse_header_line (char * const header_line); + int complete_header_line (char * const header_line); + // -1 -> end of line but not complete header line + // 0 -> no end of line marker + // 1 -> complete header line int end_of_headers (void) const; diff --git a/examples/IOStream/client/iostream_client.cpp b/examples/IOStream/client/iostream_client.cpp index 1d909d17853..f544aa391b3 100644 --- a/examples/IOStream/client/iostream_client.cpp +++ b/examples/IOStream/client/iostream_client.cpp @@ -3,10 +3,11 @@ int main (int argc, char *argv[]) { +#if !defined (ACE_LACKS_ACE_IOSTREAM) char *server_host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; u_short server_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT; - ACE_IOStream<ACE_SOCK_Stream> server; + ACE_IOStream_T<ACE_SOCK_Stream> server; ACE_SOCK_Connector connector; ACE_INET_Addr addr (server_port, server_host); @@ -39,11 +40,16 @@ int main (int argc, char *argv[]) if (server.close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); +#else + ACE_ERROR ((LM_ERROR, "ACE_IOSTREAM not supported on this platform\n")); +#endif /* !ACE_LACKS_ACE_IOSTREAM */ return 0; } +#if !defined (ACE_LACKS_ACE_IOSTREAM) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_IOStream <ACE_SOCK_Stream>; -template class ACE_Streambuf <ACE_SOCK_Stream>; +template class ACE_IOStream_T <ACE_SOCK_Stream>; +template class ACE_Streambuf_T <ACE_SOCK_Stream>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/examples/IOStream/server/iostream_server.cpp b/examples/IOStream/server/iostream_server.cpp index 149d5a61eb7..3bd7c6482f3 100644 --- a/examples/IOStream/server/iostream_server.cpp +++ b/examples/IOStream/server/iostream_server.cpp @@ -1,5 +1,5 @@ -// This is a simple example of using the ACE_IOStream and -// ACE_streambuf templates to create an object based on ACE_*_Stream +// This is a simple example of using the ACE_IOStream_T and +// ACE_Streambuf_T templates to create an object based on ACE_*_Stream // classes which mimic a C++ iostream. #include "ace/Acceptor.h" @@ -7,11 +7,13 @@ #include "ace/Service_Config.h" #include "ace/IOStream.h" +#if !defined (ACE_LACKS_ACE_IOSTREAM) + // Declare a new type which will case an ACE_SOCK_Stream to behave // like an iostream. The new type (ACE_SOCK_IOStream) can be used // anywhere an ACE_SOCK_Stream is used. -typedef ACE_IOStream<ACE_SOCK_Stream> ACE_SOCK_IOStream ; +typedef ACE_IOStream_T<ACE_SOCK_Stream> ACE_SOCK_IOStream ; // Create a service handler object based on our new // iostream/SOCK_Stream hybrid. @@ -101,10 +103,12 @@ public: // create handler objects for us. typedef ACE_Acceptor<Handler, ACE_SOCK_ACCEPTOR> Logging_Acceptor; +#endif /* !ACE_LACKS_ACE_IOSTREAM */ int main (int argc, char *argv []) { +#if !defined (ACE_LACKS_ACE_IOSTREAM) ACE_Service_Config daemon; // Create an adapter to end the event loop. @@ -134,13 +138,18 @@ main (int argc, char *argv []) ACE_DEBUG ((LM_DEBUG, " (%P|%t) shutting down server daemon\n")); +#else + ACE_ERROR ((LM_ERROR, "ACE_IOSTREAM not supported on this platform\n")); +#endif /* !ACE_LACKS_ACE_IOSTREAM */ return 0; } +#if !defined (ACE_LACKS_ACE_IOSTREAM) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) template class ACE_Acceptor <Handler, ACE_SOCK_ACCEPTOR>; -template class ACE_IOStream <ACE_SOCK_Stream>; -template class ACE_Streambuf <ACE_SOCK_Stream>; +template class ACE_IOStream_T <ACE_SOCK_Stream>; +template class ACE_Streambuf_T <ACE_SOCK_Stream>; template class ACE_Svc_Handler <ACE_SOCK_IOStream, ACE_INET_Addr, ACE_NULL_SYNCH>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/examples/Reactor/Misc/Makefile b/examples/Reactor/Misc/Makefile index 07a7e1a548a..21e1a449821 100644 --- a/examples/Reactor/Misc/Makefile +++ b/examples/Reactor/Misc/Makefile @@ -12,7 +12,6 @@ BIN = pingpong \ notification \ test_demuxing \ test_event_handler_t \ - test_handle_set \ test_reactors \ test_signals_1 \ test_signals_2 \ @@ -293,20 +292,6 @@ include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU $(WRAPPER_ROOT)/ace/Log_Record.i \ $(WRAPPER_ROOT)/ace/ACE.i \ $(WRAPPER_ROOT)/ace/Event_Handler.i -.obj/test_handle_set.o .shobj/test_handle_set.so: test_handle_set.cpp \ - $(WRAPPER_ROOT)/ace/Handle_Set.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/OS.i \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/Handle_Set.i .obj/test_reactors.o .shobj/test_reactors.so: test_reactors.cpp \ $(WRAPPER_ROOT)/ace/Reactor.h \ $(WRAPPER_ROOT)/ace/Handle_Set.h \ diff --git a/examples/Reactor/Misc/test_handle_set.cpp b/examples/Reactor/Misc/test_handle_set.cpp deleted file mode 100644 index cfd4791f6e8..00000000000 --- a/examples/Reactor/Misc/test_handle_set.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// $Id$ - -#include "ace/Handle_Set.h" - -void -test1 (int count) -{ - int duplicates = 0; - int sets = 0; - int clears = 0; - - ACE_Handle_Set handle_set; - - ACE_OS::srand (ACE_OS::time (0L)); - - for (int j = 0; j < count; j++) - { - int i = int (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE); - - if (ACE_ODD (i)) - { - if (handle_set.is_set (i)) - duplicates++; - - handle_set.set_bit (i); - sets++; - } - else - { - if (handle_set.is_set (i)) - duplicates--; - - handle_set.clr_bit (i); - clears++; - } - } - - ACE_DEBUG ((LM_DEBUG, "count = %d, set_size = %d, duplicates = %d\n", - count, handle_set.num_set (), (sets - clears) == duplicates)); -} - -void -test2 (void) -{ - ACE_Handle_Set handle_set; - ACE_HANDLE handle; - - handle_set.set_bit (0); - handle_set.set_bit (1); - handle_set.set_bit (32); - handle_set.set_bit (63); - handle_set.set_bit (64); - handle_set.set_bit (65); - handle_set.set_bit (122); - handle_set.set_bit (129); - handle_set.set_bit (245); - handle_set.set_bit (255); - - for (ACE_Handle_Set_Iterator fi (handle_set); - (handle = fi ()) != -1; - ++fi) - ACE_DEBUG ((LM_DEBUG, "handle = %d\n", handle)); -} - -int -main (int argc, char *argv[]) -{ - int count = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_Handle_Set::MAXSIZE; - test1 (count); - test2 (); -} - diff --git a/include/makeinclude/platform_chorus.GNU b/include/makeinclude/platform_chorus.GNU index 92ad506784f..973c7f90c67 100644 --- a/include/makeinclude/platform_chorus.GNU +++ b/include/makeinclude/platform_chorus.GNU @@ -1,11 +1,12 @@ # Chorus 3.1b with GNU g++ 2.7.2 -# *not* using Orbix +include $(CLASSIXDIR)/dtool/htgt-cf.rf INC_DIR = $(CLASSIXDIR)/include BIN_DIR = LIB_DIR = $(CLASSIXDIR)/lib -CC = gcc -CXX = g++ +#CC = gcc +#CXX = g++ +CXX = $(CC) CFLAGS += $(DCFLAGS) -w -O2 CCFLAGS += $(CFLAGS) -fno-implicit-templates \ -fno-strict-prototypes \ @@ -17,20 +18,24 @@ INCLDIRS += -I$(INC_DIR)/posix \ -I$(INC_DIR)/stdc \ -I$(INC_DIR)/chorus/ \ -I$(INC_DIR)/chorus/iom \ - -I$(INC_DIR)/CC -DLD = -LD = $(CXX) + -I$(INC_DIR)/CC +DLD = +LD = $(CXX) LDFLAGS += -r -Ur -nostdlib \ -L$(LIB_DIR)/CC \ -L$(LIB_DIR)/classix -LIBS += -lC -lcx.u +#LIBS += -lC -lcx.u PIC = -fPIC -AR = ar -ARFLAGS = rv -RANLIB = /bin/true +#AR = ar +AR = $(XDIR)/bin/ar +#ARFLAGS = rv +ARFLAGS = srv +#RANLIB = /bin/true +RANLIB = $(XDIR)/bin/ranlib PRELIB = (echo "main() { }" > gcctemp.c && \ $(COMPILE.cc) -o gcctemp.o gcctemp.c && \ $(LD) $^ $(LDFLAGS) $(LIBS); \ status=$$?; rm -f gcctemp.* a.out; exit $$status) #### don't build shared objects: BUILD = $(VOBJS) $(VLIB) $(VBIN) + diff --git a/include/makeinclude/platform_sunos5_sunc++_orbix.GNU b/include/makeinclude/platform_sunos5_sunc++_orbix.GNU index 915029d7039..6647d397485 100644 --- a/include/makeinclude/platform_sunos5_sunc++_orbix.GNU +++ b/include/makeinclude/platform_sunos5_sunc++_orbix.GNU @@ -10,7 +10,7 @@ LD = $(CXX) INCLDIRS = -I$(ORBIX_ROOT)/include PIC = -PIC LDFLAGS += $(PIC) -L$(ORBIX_ROOT)/lib -R $(WRAPPER_ROOT)/ace -R $(ORBIX_ROOT)/lib -LIBS += -orbixmt -lsocket -ldl -lnsl -lthread -lgen +LIBS += -lorbixmt -lsocket -ldl -lnsl -lthread -lgen AR = CC ARFLAGS = -xar -o RANLIB = echo diff --git a/java/ImageProcessing/framework/BaseButton.java b/java/ImageProcessing/framework/BaseButton.java index e7956dde646..8071bc8671a 100644 --- a/java/ImageProcessing/framework/BaseButton.java +++ b/java/ImageProcessing/framework/BaseButton.java @@ -154,13 +154,15 @@ class HelpButton extends BaseButton public HelpButton (String title, String desc, ImageApp parent) { super (title, desc, parent); + this.parent_ = parent; } public boolean action (Event e, Object arg) { - System.out.println ("Help selected"); + DialogManager.popDialog (DialogType.HELP, null, this.parent_); return true; } + ImageApp parent_ = null; } class ChoicePanel extends Panel @@ -206,7 +208,7 @@ class ChoicePanel extends Panel String displayString = null; String filterName = this.choice_.getSelectedItem (); - if (filterName.compareTo ("None") == 0) + if (filterName.compareTo ("Filters:") == 0) displayString = "No filter selected"; else { diff --git a/java/ImageProcessing/framework/DialogManager.java b/java/ImageProcessing/framework/DialogManager.java index e712a994b4a..eb8fac39940 100644 --- a/java/ImageProcessing/framework/DialogManager.java +++ b/java/ImageProcessing/framework/DialogManager.java @@ -2,9 +2,19 @@ package imaging.framework; import java.awt.*; import java.awt.image.*; +import java.applet.*; +import java.util.*; +import java.io.*; +import java.net.*; class DialogManager { + public static void popDialog (int type, String message, Applet parent) + { + codeBase_ = parent.getCodeBase ().toString (); + popDialog (type, message); + } + public static void popDialog (int type, String message) { Frame frame = null; @@ -14,6 +24,9 @@ class DialogManager case DialogType.ABOUT: frame = new AboutFrame (); break; + case DialogType.HELP: + frame = new HelpFrame (codeBase_); + break; case DialogType.MALFORMED_URL: case DialogType.NOT_SUPPORTED: case DialogType.URL_NOT_FOUND: @@ -28,6 +41,7 @@ class DialogManager (d.height - frame.size ().height)/2); frame.show (); } + private static String codeBase_ = ""; } class MessageFrame extends Frame @@ -84,9 +98,7 @@ class AboutFrame extends Frame public AboutFrame () { super ("About"); - this.setText (); - - this.resize (500,700); + this.resize (300,300); this.setLayout (new BorderLayout ()); Panel okButtonPanel = new Panel (); @@ -97,17 +109,42 @@ class AboutFrame extends Frame public void paint (Graphics g) { - g.clearRect (0, 0, this.size ().width, this.size ().height); - g.setFont (new Font ("TimesRoman", Font.PLAIN, 18)); - this.setBackground (Color.white); - int x = 20; + int width = this.size ().width; + int height = this.size ().height; + + g.clearRect (0, 0, width, height); + this.setBackground (Color.cyan); + + // First draw the title + g.setFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 48)); + FontMetrics fontMetrics = g.getFontMetrics (); + int x = (width - fontMetrics.stringWidth (title_))/2; int y = 100; - for (int i = 0; i < AboutFrame.MAXROWS; i++) - { - g.drawString(this.text_[i], x, y); - y += g.getFont ().getSize () + 5; - } + Color color = g.getColor (); + g.setColor (Color.orange); + g.drawString(title_, x+2, y+2); + g.setColor (color); + g.drawString(title_, x, y); + + // Then draw author's name + g.setFont (new Font ("TimesRoman", Font.ITALIC, 24)); + fontMetrics = g.getFontMetrics (); + x = (width - fontMetrics.stringWidth (by_))/2; + y += 50; + g.drawString(by_, x, y); + + x = (width - fontMetrics.stringWidth (author_))/2; + y += 50; + g.drawString(author_, x, y); + + // Finally draw other information -- version number etc. + g.setFont (new Font ("TimesRoman", Font.ITALIC, 18)); + fontMetrics = g.getFontMetrics (); + x = (width - fontMetrics.stringWidth (info_))/2; + y += 50; + g.drawString(info_, x, y); + } // Handle window destroy events @@ -136,35 +173,97 @@ class AboutFrame extends Frame return false; } - private void setText () + private String title_ = "MedJava"; + private String by_ = "by"; + private String author_ = "Prashant Jain"; + private String info_ = "Version 1.0"; + private Button okButton_ = new Button (" ok "); +} + +class HelpFrame extends Frame +{ + public HelpFrame (String codeBase) + { + super ("Help"); + this.setBackground (Color.cyan); + this.text_.setEditable (false); + Font defaultFont = new Font ("TimesRoman", Font.PLAIN, 14); + this.text_.setFont (defaultFont); + + try + { + URL url = new URL (codeBase + "../ImageProcessing/framework/help.conf"); + String delim = "\n"; + + // Get the input stream and pipe it to a DataInputStream + DataInputStream iStream = new DataInputStream (url.openStream ()); + + // Keep reading the data until we are done + String tempString = iStream.readLine (); + while (tempString != null) + { + if (tempString.startsWith ("<START>")) + delim = ""; + else if (tempString.startsWith ("<END>")) + delim = "\n"; + else if (tempString.startsWith ("<TAB>")) + this.text_.appendText ("\t"); + else if (tempString.startsWith ("<P>")) + this.text_.appendText ("\n"); + else + { + this.text_.appendText (tempString); + this.text_.appendText (delim); + } + tempString = iStream.readLine (); + } + } + catch (MalformedURLException e) + { + System.err.println (e); + } + catch (IOException e) + { + System.err.println (e); + } + + this.resize (600,700); + this.setLayout (new BorderLayout ()); + + Panel okButtonPanel = new Panel (); + okButtonPanel.add (this.okButton_); + this.add ("South", okButtonPanel); + this.add ("Center", this.text_); + } + + // Handle window destroy events + public boolean handleEvent (Event evt) + { + if (evt.id == Event.WINDOW_DESTROY) + { + this.dispose (); + return true; + } + return super.handleEvent (evt); + } + + // Handle all action events + public boolean action (Event e, Object arg) { - text_[0] = "This is a prototype of a large scale distributed medical"; - text_[1] = "imaging system. It has been developed using Java, in"; - text_[2] = "particular, several components of Java ACE."; - text_[3] = ""; - text_[4] = "The prototype allows images to be downloaded across the"; - text_[5] = "network. It then provides several filters that can be"; - text_[6] = "used to do image processing. The image filters are"; - text_[7] = "configured into the system dynamically using the Service"; - text_[8] = "Configurator pattern. In the current implementation, the"; - text_[9] = "filters are specified via a configuration file located at"; - text_[10] = "server. The file can be modified at runtime to add"; - text_[11] = "additional filters or to remove some filters. This allows"; - text_[12] = "filters to be configured and reconfigured dynamically."; - text_[13] = ""; - text_[14] = "Currently, images can not be uploaded. This is mainly due"; - text_[15] = "to security restrictions imposed by current servers. Our"; - text_[16] = "goal is to use the prototpe in conjunction with JAWS, an"; - text_[17] = "adaptive web server we are currently developing in which we"; - text_[18] = "plan to provide support for image uploading."; - text_[19] = ""; - text_[20] = "For more information about this prototype, please contact"; - text_[21] = "Prashant Jain (pjain@cs.wustl.edu)."; + if (e.target instanceof Button) + { + if (e.target == this.okButton_) + { + this.dispose (); + } + return true; + } + else + return false; } - private final static int MAXROWS = 22; + private Vector helpInfo_ = new Vector (); private Button okButton_ = new Button (" ok "); - private TextArea textArea_ = null; - private String [] text_ = new String [AboutFrame.MAXROWS]; + private TextArea text_ = new TextArea (); } diff --git a/java/ImageProcessing/framework/DialogType.java b/java/ImageProcessing/framework/DialogType.java index eddd7d0a4e2..c95372c08e1 100644 --- a/java/ImageProcessing/framework/DialogType.java +++ b/java/ImageProcessing/framework/DialogType.java @@ -6,5 +6,6 @@ public class DialogType public static final int MALFORMED_URL = 1; public static final int URL_NOT_FOUND = 2; public static final int NOT_SUPPORTED = 3; + public static final int HELP = 4; public static final int NOT_YET_IMPLEMENTED = 10; } diff --git a/java/ImageProcessing/framework/FilePanel.java b/java/ImageProcessing/framework/FilePanel.java index 86bc5e50c3e..ac5589d7862 100644 --- a/java/ImageProcessing/framework/FilePanel.java +++ b/java/ImageProcessing/framework/FilePanel.java @@ -144,9 +144,6 @@ class HelpPanel extends Panel this.add (this.aboutButton_); this.add (this.helpButton_); - // Disable the Help button for now - this.helpButton_.disable (); - this.resize (100, 100); } diff --git a/java/ImageProcessing/framework/ImageApp.java b/java/ImageProcessing/framework/ImageApp.java index aa50fd3105f..5cfe8835b42 100644 --- a/java/ImageProcessing/framework/ImageApp.java +++ b/java/ImageProcessing/framework/ImageApp.java @@ -157,7 +157,7 @@ public class ImageApp extends Applet Choice choice = new Choice (); // Add the default choice first - choice.addItem ("None"); + choice.addItem ("Filters:"); // Now do the file processing -- to determine which filters need // to be loaded. @@ -170,11 +170,6 @@ public class ImageApp extends Applet if (this.configFile_ == null) this.configFile_ = "http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/framework/filter.conf"; - if (this.filterContext_ == null) - this.filterContext_ = getParameter ("filterContext"); - if (this.filterContext_ == null) - this.filterContext_ = "http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/"; - URL url; String configInfo= null; try @@ -223,7 +218,6 @@ public class ImageApp extends Applet fullFilterName = tokens.nextToken (); filterName = this.extractFilterName (fullFilterName); - // URL filter = new URL (this.filterContext_ + fullFilterName + ".class"); System.out.println ("Loading: " + fullFilterName); // Load the filter class Class c = Class.forName (fullFilterName); @@ -270,7 +264,6 @@ public class ImageApp extends Applet private Panel centerPanel_ = new Panel (); private String configFile_ = null; - private String filterContext_ = null; private Choice choice_ = null; private ImageCanvas imageCanvas_ = new ImageCanvas (); private FilePanel filePanel_; diff --git a/java/ImageProcessing/framework/ImageCanvas.java b/java/ImageProcessing/framework/ImageCanvas.java index f527accf545..182bd54bf9b 100644 --- a/java/ImageProcessing/framework/ImageCanvas.java +++ b/java/ImageProcessing/framework/ImageCanvas.java @@ -143,10 +143,13 @@ class ImageCanvas extends Canvas // Check if mouse is within the bounds of the image private boolean inBounds (int x, int y) { - return (x >= this.x_) && - (y >= this.y_) && - (x <= (this.x_ + this.zoom_ * this.image_.getWidth (this))) && - (y <= (this.y_ + this.zoom_ * this.image_.getHeight (this))); + if (this.image_ == null) + return false; + else + return (x >= this.x_) && + (y >= this.y_) && + (x <= (this.x_ + this.zoom_ * this.image_.getWidth (this))) && + (y <= (this.y_ + this.zoom_ * this.image_.getHeight (this))); } private MediaTracker tracker_ = new MediaTracker(this); diff --git a/netsvcs/lib/Server_Logging_Handler.cpp b/netsvcs/lib/Server_Logging_Handler.cpp index 0fa8089a820..e9cc86f1255 100644 --- a/netsvcs/lib/Server_Logging_Handler.cpp +++ b/netsvcs/lib/Server_Logging_Handler.cpp @@ -100,8 +100,10 @@ template class ACE_Thr_Server_Logging_Handler<Synch_Receiver>; template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_SYNCH>; #if defined (ACE_HAS_TLI) - template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_NULL_SYNCH>; - // else LOGGING_PEER_STREAM is ACE_SOCK_STREAM, + #if defined (ACE_HAS_THREADS) + template class ACE_Svc_Handler<LOGGING_PEER_STREAM, ACE_NULL_SYNCH>; + #endif /* ACE_HAS_THREADS */ + // else if ! ACE_HAS_TLI, LOGGING_PEER_STREAM is ACE_SOCK_STREAM, // and the specialization would be // template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; // That specialization is in TS_Server_Handler.cpp, so we don't need it diff --git a/netsvcs/lib/Server_Logging_Handler_T.cpp b/netsvcs/lib/Server_Logging_Handler_T.cpp index d330b0a8eac..5d85bc14a8f 100644 --- a/netsvcs/lib/Server_Logging_Handler_T.cpp +++ b/netsvcs/lib/Server_Logging_Handler_T.cpp @@ -244,8 +244,7 @@ ACE_Thr_Server_Logging_Handler<LMR>::ACE_Thr_Server_Logging_Handler (ACE_Thread_ { } -template<class LMR> -int +template<class LMR> int ACE_Thr_Server_Logging_Handler<LMR>::open (void *) { // call base class open_common diff --git a/performance-tests/Misc/test_naming.cpp b/performance-tests/Misc/test_naming.cpp index ea2b00c1124..41e09f541ff 100644 --- a/performance-tests/Misc/test_naming.cpp +++ b/performance-tests/Misc/test_naming.cpp @@ -131,8 +131,11 @@ void do_testing (int argc, char *argv[], int light) } else // Use NO-SYNC { - name_options->database (ACE_OS::strcat ("light", ACE::basename (name_options->process_name (), - ACE_DIRECTORY_SEPARATOR_CHAR))); + const char *p = ACE::basename (name_options->process_name (), + ACE_DIRECTORY_SEPARATOR_CHAR); + char s[5 /* strlen ("light") */ + MAXNAMELEN + 1]; + ACE_OS::sprintf (s, "light%s", p); + name_options->database (s); ns_context.open (ACE_Naming_Context::PROC_LOCAL, 1); } diff --git a/tests/Buffer_Stream_Test.cpp b/tests/Buffer_Stream_Test.cpp index 2ba15d15cc3..4444b1ed070 100644 --- a/tests/Buffer_Stream_Test.cpp +++ b/tests/Buffer_Stream_Test.cpp @@ -112,11 +112,11 @@ Producer::svc (void) ACE_NEW_THREAD; // Keep reading stdin, until we reach EOF. - for (char c = 'a'; c <= 'z'; c++) + for (char *c = ACE_ALPHABET; *c != '\0'; c++) { // Allocate a new message. char d[2]; - d[0] = c; + d[0] = *c; d[1] = '\0'; ACE_Message_Block *mb; @@ -152,7 +152,7 @@ Consumer::svc (void) ACE_Message_Block *mb = 0; int result = 0; - char c = 'a'; + char *c = ACE_ALPHABET; char *output; // Keep looping, reading a message out of the queue, until we @@ -171,7 +171,7 @@ Consumer::svc (void) if (length > 0) { output = mb->rd_ptr (); - ACE_ASSERT (c == output[0]); + ACE_ASSERT (*c == output[0]); c++; } mb->release (); diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp index b5482267d31..d5b6dd3ef5d 100644 --- a/tests/Conn_Test.cpp +++ b/tests/Conn_Test.cpp @@ -66,8 +66,8 @@ Svc_Handler::send_data (void) { // Send data to server. - for (char c = 'a'; c <= 'z'; c++) - if (this->peer ().send_n (&c, 1) == -1) + for (char *c = ACE_ALPHABET; *c != '\0'; c++) + if (this->peer ().send_n (c, 1) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "send_n")); } @@ -79,7 +79,7 @@ Svc_Handler::recv_data (void) ACE_Handle_Set handle_set; handle_set.set_bit (new_stream.get_handle ()); - char t = 'a'; + char *t = ACE_ALPHABET; // Read data from client (terminate on error). @@ -97,13 +97,13 @@ Svc_Handler::recv_data (void) while ((r_bytes = new_stream.recv (&c, 1)) > 0) { - ACE_ASSERT (t == c); + ACE_ASSERT (*t == c); // We need to guard against cached connections, which // will send multiple sequences of letters from 'a' -> // 'z' through the same connection. - if (t == 'z') - t = 'a'; + if (*t == 'z') + t = ACE_ALPHABET; else t++; } diff --git a/tests/Future_Test.cpp b/tests/Future_Test.cpp index 6c42e795d08..6bededf0c32 100644 --- a/tests/Future_Test.cpp +++ b/tests/Future_Test.cpp @@ -12,8 +12,8 @@ // This example tests the ACE Future. // // = AUTHOR -// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> +// Andres Kruse <Andres.Kruse@cern.ch>, Douglas C. Schmidt +// <schmidt@cs.wustl.edu> and Per Andersson <pera@ipso.se> // // ============================================================================ @@ -36,15 +36,12 @@ static ATOMIC_INT task_count (0); // a counter for the futures.. static ATOMIC_INT future_count (0); -static ATOMIC_INT future_no (0); // a counter for the capsules.. static ATOMIC_INT capsule_count (0); -static ATOMIC_INT capsule_no (0); // a counter for the method objects... static ATOMIC_INT methodobject_count (0); -static ATOMIC_INT methodobject_no (0); class Scheduler : public ACE_Task<ACE_MT_SYNCH> // = TITLE @@ -92,10 +89,10 @@ Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, u_long new_param, int new_count, ACE_Future<u_long> &new_result) - : scheduler_ (new_Scheduler), - param_ (new_param), - count_ (new_count), - future_result_ (new_result) + : scheduler_ (new_Scheduler), + param_ (new_param), + count_ (new_count), + future_result_ (new_result) { ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work created\n")); @@ -103,14 +100,17 @@ Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, Method_Object_work::~Method_Object_work (void) { - ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work will be deleted.\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) Method_Object_work will be deleted.\n")); } int Method_Object_work::call (void) { - return this->future_result_.set (this->scheduler_->work_i (this->param_, this->count_)); + return this->future_result_.set + (this->scheduler_->work_i (this->param_, + this->count_)); } class Method_Object_name : public ACE_Method_Object @@ -118,7 +118,8 @@ class Method_Object_name : public ACE_Method_Object // Reification of the <name> method. { public: - Method_Object_name (Scheduler *, ACE_Future<const char*> &); + Method_Object_name (Scheduler *, + ACE_Future<const char*> &); virtual ~Method_Object_name (void); virtual int call (void); @@ -153,27 +154,36 @@ class Method_Object_end : public ACE_Method_Object // Reification of the <end> method. { public: - Method_Object_end (Scheduler *new_Scheduler): scheduler_ (new_Scheduler) {} + Method_Object_end (Scheduler *new_Scheduler) + : scheduler_ (new_Scheduler) {} virtual ~Method_Object_end (void) {} - virtual int call (void) { this->scheduler_->close (); return -1; } + virtual int call (void) { + this->scheduler_->close (); + return -1; + } private: Scheduler *scheduler_; }; // constructor -Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) +Scheduler::Scheduler (const char *newname, + Scheduler *new_Scheduler) { ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); ACE_OS::strcpy ((char *) this->name_, newname); this->scheduler_ = new_Scheduler; - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s created\n", this->name_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s created\n", + this->name_)); } // Destructor Scheduler::~Scheduler (void) { - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s will be destroyed\n", this->name_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s will be destroyed\n", + this->name_)); delete[] this->name_; } @@ -182,7 +192,10 @@ int Scheduler::open (void *) { task_count++; - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s open\n", this->name_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s open\n", + this->name_)); + // Become an Active Object. return this->activate (THR_BOUND); } @@ -190,7 +203,9 @@ Scheduler::open (void *) int Scheduler::close (u_long) { - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s close\n", this->name_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) Scheduler %s close\n", + this->name_)); task_count--; return 0; } @@ -269,7 +284,8 @@ Scheduler::work (u_long newparam, int newcount) ACE_Future<u_long> new_future; this->activation_queue_.enqueue - (new Method_Object_work (this, newparam, newcount, new_future)); + (new Method_Object_work (this, newparam, + newcount, new_future)); return new_future; } } @@ -281,10 +297,12 @@ static int n_loops = 100; #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) template class ACE_Future<const char *>; +template class ACE_Future<int>; template class ACE_Future<u_long>; -template class auto_ptr<ACE_Method_Object>; template class ACE_Future_Rep<char const *>; -template class ACE_Future_Rep<unsigned long>; +template class ACE_Future_Rep<int>; +template class ACE_Future_Rep<u_long>; +template class auto_ptr<ACE_Method_Object>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ #endif /* ACE_HAS_THREADS */ @@ -317,7 +335,8 @@ main (int, char *[]) ACE_Future<u_long> fresulta, fresultb, fresultc, fresultd, fresulte; ACE_Future<const char*> fname; - ACE_DEBUG ((LM_DEBUG, "(%t) going to do a non-blocking call\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) going to do a non-blocking call\n")); fresulta = andres->work (9013); fresultb = peter->work (9013); @@ -327,9 +346,11 @@ main (int, char *[]) // see if the result is available... if (fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG, "(%t) wow.. work is ready.....\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) wow.. work is ready.....\n")); - ACE_DEBUG ((LM_DEBUG, "(%t) non-blocking call done... now blocking...\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) non-blocking call done... now blocking...\n")); // Save the result of fresulta. @@ -390,7 +411,86 @@ main (int, char *[]) (int) capsule_count, (int) methodobject_count)); - ACE_DEBUG ((LM_DEBUG,"(%t) th' that's all folks!\n")); + { + // Check if set then get works, older versions of ACE_Future + // will lock forever (or until the timer expires), will use a small + // timer value to avoid blocking the process. + + ACE_Future<int> f1; + f1.set(100); + + ACE_Time_Value timeout(1); + int value = 0; + + if (f1.get (value, &timeout) == 0 && value == 100) + ACE_DEBUG ((LM_DEBUG, + "Ace_Future<T>::Set followed by Ace_Future<T>::Get works.\n")); + else + ACE_DEBUG ((LM_DEBUG, + "ACE_Future<T>::Set followed by Ace_Future<T>::Get does " + "not work, broken Ace_Future<> implementation.\n")); + } + { + ACE_DEBUG ((LM_DEBUG, + "Checking if Ace_Future<T>::operator= is implemented " + "incorrectly this might crash the program.\n")); + + ACE_Future<int> f1; + { + ACE_Future<int> f2 (f1); // To ensure that a rep object is created + } + // Now it is one ACE_Future<int> referencing the rep instance + + ACE_DEBUG ((LM_DEBUG, "0.\n")); + //check that self assignment works + f1 = f1; + // Is there any repesentation left, and if so what is the ref + // count older ACE_Future<> implementations have deleted the rep + // instance at this moment + + // The stuff below might crash the process if the op= + // implementation was bad + int value = 0; + ACE_Time_Value timeout (1); + + f1.set (100); + f1.get (value, &timeout); + + ACE_DEBUG ((LM_DEBUG, "1.\n")); + { // Might delete the same data a couple of times + ACE_Future<int> f2 (f1); + f1.set (100); + f1.get (value, &timeout); + } + + ACE_DEBUG ((LM_DEBUG, "2.\n")); + { + ACE_Future<int> f2 (f1); + f1.set (100); + f1.get (value, &timeout); + } + + ACE_DEBUG ((LM_DEBUG, "3.\n")); + { + ACE_Future<int> f2 (f1); + f1.set (100); + f1.get (value, &timeout); + } + ACE_DEBUG ((LM_DEBUG, "4.\n")); + { + ACE_Future<int> f2 (f1); + f1.set (100); + f1.get (value, &timeout); + } + ACE_DEBUG ((LM_DEBUG, "5.\n")); + { + ACE_Future<int> f2 (90); + f2.get (value, &timeout); + f1.get (value, &timeout); + } + } + ACE_DEBUG ((LM_DEBUG, + "No it did not crash the program.\n")); ACE_OS::sleep (5); diff --git a/tests/Handle_Set_Test.cpp b/tests/Handle_Set_Test.cpp index d8803dfb137..599b35ca5fc 100644 --- a/tests/Handle_Set_Test.cpp +++ b/tests/Handle_Set_Test.cpp @@ -18,50 +18,123 @@ // // ============================================================================ - +#include "ace/Profile_Timer.h" #include "ace/Handle_Set.h" #include "test_config.h" -#define IS_ODD(X) (((X) & 1) != 0) - static void -run_test (int count) +test_duplicates (size_t count) { - int duplicates = 0; - int sets = 0; - int clears = 0; + size_t duplicates = 0; + size_t sets = 0; + size_t clears = 0; ACE_Handle_Set handle_set; ACE_OS::srand (ACE_OS::time (0L)); - for (int i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) { - int j = int (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE); + size_t handle = size_t (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE); - if (IS_ODD (j)) + if (ACE_ODD (handle)) { - if (handle_set.is_set ((ACE_HANDLE) j)) + if (handle_set.is_set ((ACE_HANDLE) handle)) duplicates++; - handle_set.set_bit ((ACE_HANDLE) j); + handle_set.set_bit ((ACE_HANDLE) handle); sets++; } else { - if (handle_set.is_set ((ACE_HANDLE) j)) + if (handle_set.is_set ((ACE_HANDLE) handle)) duplicates--; - handle_set.clr_bit ((ACE_HANDLE) j); + handle_set.clr_bit ((ACE_HANDLE) handle); clears++; } } ACE_ASSERT (count == sets + clears); ACE_ASSERT (handle_set.num_set () + duplicates == sets); +} + +static void +test_boundaries (void) +{ + ACE_Handle_Set handle_set; + + ACE_HANDLE handle; + + // First test an empty set. -// ACE_DEBUG ((LM_DEBUG, "count = %d, set_size = %d, duplicates = %d\n", -// count, handle_set.num_set (), (sets - clears) == duplicates)); + ACE_Handle_Set_Iterator i1 (handle_set); + + while ((handle = i1 ()) != ACE_INVALID_HANDLE) + ACE_ASSERT (!"this shouldn't get called since the set is empty!\n"); + + // Insert a bunch of HANDLEs into the set, testing for boundary + // conditions. + + handle_set.set_bit ((ACE_HANDLE) 0); + handle_set.set_bit ((ACE_HANDLE) 1); + handle_set.set_bit ((ACE_HANDLE) 32); + handle_set.set_bit ((ACE_HANDLE) 63); + handle_set.set_bit ((ACE_HANDLE) 64); + handle_set.set_bit ((ACE_HANDLE) 65); + handle_set.set_bit ((ACE_HANDLE) 127); + handle_set.set_bit ((ACE_HANDLE) 128); + handle_set.set_bit ((ACE_HANDLE) 129); + handle_set.set_bit ((ACE_HANDLE) 255); + + int count = 0; + + ACE_Handle_Set_Iterator i2 (handle_set); + + while ((handle = i2 ()) != ACE_INVALID_HANDLE) + count++; + + ACE_ASSERT (count == handle_set.num_set ()); +} + +static void +test_performance (size_t max_handles, + size_t max_iterations) +{ + ACE_Handle_Set handle_set; + size_t i; + + for (i = 0; i < max_handles; i++) + handle_set.set_bit ((ACE_HANDLE) i); + + ACE_Profile_Timer timer; + ACE_HANDLE handle; + size_t count = 0; + + timer.start (); + + for (i = 0; i < max_iterations; i++) + { + ACE_Handle_Set_Iterator iter (handle_set); + + // Only iterate up to <handle_set.max_set ()>. + while ((handle = iter ()) != ACE_INVALID_HANDLE) + count++; + } + + timer.stop (); + + ACE_ASSERT (count == max_handles * max_iterations); + + ACE_Profile_Timer::ACE_Elapsed_Time et; + + timer.elapsed_time (et); + + ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", + et.real_time, et.user_time, et.system_time)); + + ACE_DEBUG ((LM_DEBUG, "time per each of the %d calls = %f usecs\n", + count, (et.real_time / double (count)) * 1000000)); } int @@ -70,7 +143,12 @@ main (int argc, char *argv[]) ACE_START_TEST ("Handle_Set_Test"); int count = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_Handle_Set::MAXSIZE; - run_test (count); + size_t max_handles = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_Handle_Set::MAXSIZE; + size_t max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_MAX_ITERATIONS; + + test_duplicates (count); + test_boundaries (); + test_performance (max_handles, max_iterations); ACE_END_TEST; return 0; diff --git a/tests/IOStream_Test.cpp b/tests/IOStream_Test.cpp index be0cfc1c683..32f9a0a3019 100644 --- a/tests/IOStream_Test.cpp +++ b/tests/IOStream_Test.cpp @@ -21,11 +21,12 @@ #include "ace/Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" -#include "ace/INET_Addr.h" #include "ace/IOStream.h" #include "test_config.h" -typedef ACE_IOStream<ACE_SOCK_Stream> ACE_SOCK_IOStream; +#if !defined (ACE_LACKS_ACE_IOSTREAM) + +typedef ACE_IOStream_T<ACE_SOCK_Stream> ACE_SOCK_IOStream; /* The biggest drawback to an iostream is that it generally eats up whitespace when performing a get (>>) operation. @@ -374,19 +375,26 @@ spawn (void) #endif /* ACE_HAS_THREADS */ return 0; } +#endif /* !ACE_LACKS_ACE_IOSTREAM */ int main (int, char *[]) { ACE_START_TEST ("IOStream_Test"); +#if !defined (ACE_LACKS_ACE_IOSTREAM) spawn (); - +#else + ACE_ERROR ((LM_ERROR, "ACE_IOSTREAM not supported on this platform\n")); +#endif /* !ACE_LACKS_ACE_IOSTREAM */ ACE_END_TEST; return 0; } + +#if !defined (ACE_LACKS_ACE_IOSTREAM) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_IOStream<ACE_SOCK_Stream>; -template class ACE_Streambuf<ACE_SOCK_Stream>; +template class ACE_IOStream_T<ACE_SOCK_Stream>; +template class ACE_Streambuf_T<ACE_SOCK_Stream>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#endif /* !ACE_LACKS_ACE_IOSTREAM */ diff --git a/tests/MM_Shared_Memory_Test.cpp b/tests/MM_Shared_Memory_Test.cpp index b20083a1d22..6149e201fda 100644 --- a/tests/MM_Shared_Memory_Test.cpp +++ b/tests/MM_Shared_Memory_Test.cpp @@ -42,13 +42,13 @@ client (void *) #endif /* ACE_WIN32 */ ACE_OS::sleep (3); - char t = 'a'; + char *t = ACE_ALPHABET; ACE_Shared_Memory_MM shm_client (shm_key); char *shm = (char *) shm_client.malloc (); for (char *s = shm; *s != '\0'; s++) { - ACE_ASSERT (t == s[0]); + ACE_ASSERT (*t == s[0]); t++; } *shm = '*'; @@ -72,8 +72,8 @@ server (void *) char *shm = (char *) shm_server.malloc (); char *s = shm; - for (char c = 'a'; c <= 'z'; c++) - *s++ = c; + for (char *c = ACE_ALPHABET; *c != '\0'; c++) + *s++ = *c; *s = '\0'; diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp index fa9078bc608..3ad9cc12a97 100644 --- a/tests/Mem_Map_Test.cpp +++ b/tests/Mem_Map_Test.cpp @@ -57,8 +57,8 @@ create_test_file (int size, int num_lines) char *mybuf; ACE_NEW_RETURN (mybuf, char[size + 1], -1); - char c = 'a'; - char d = c; + char *c = ACE_ALPHABET; + char *d = c; ACE_HANDLE file_handle = ACE_OS::open (ACE_DEFAULT_TEST_FILE, O_RDWR | O_CREAT | O_TRUNC, @@ -71,7 +71,7 @@ create_test_file (int size, int num_lines) { for (int i = 0; i < size; i++) { - mybuf[i] = c; + mybuf[i] = *c; c++; } diff --git a/tests/Priority_Buffer_Test.cpp b/tests/Priority_Buffer_Test.cpp index 3a1134c63a2..7fe6d7cd33a 100644 --- a/tests/Priority_Buffer_Test.cpp +++ b/tests/Priority_Buffer_Test.cpp @@ -94,14 +94,14 @@ producer (void *args) ACE_Message_Block *mb = 0; - for (char c = 'a'; c <= 'z'; c++) + for (char *c = ACE_ALPHABET; *c != '\0'; c++) { count++; // Allocate a new message ACE_NEW_RETURN (mb, ACE_Message_Block (1), 0); - *mb->rd_ptr () = c; + *mb->rd_ptr () = *c; // Set the priority. mb->msg_priority (count); diff --git a/tests/Priority_Task_Test.cpp b/tests/Priority_Task_Test.cpp index eeec7377c2c..e7d6f4fb2b0 100644 --- a/tests/Priority_Task_Test.cpp +++ b/tests/Priority_Task_Test.cpp @@ -29,7 +29,6 @@ class Priority_Task : public ACE_Task<ACE_MT_SYNCH> public: Priority_Task (void); - int close (u_long = 0); int open (void *); int svc (void); @@ -44,13 +43,6 @@ Priority_Task::Priority_Task (void) } int -Priority_Task::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) leaving Task with priority %d\n", this->priority_)); - return 0; -} - -int Priority_Task::open (void *arg) { this->priority_ = *(int *) arg; @@ -137,11 +129,12 @@ main (int, char *[]) ACE_SCOPE_THREAD); } + ACE_DEBUG ((LM_DEBUG, "(%t) %d tasks spawned, wait for them to exit . . .\n", + ACE_MAX_ITERATIONS)); + // Wait for all tasks to exit. ACE_Service_Config::thr_mgr ()->wait (); - for (i = 0; i < ACE_MAX_ITERATIONS; i++) - tasks[i].close (); #else ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ diff --git a/tests/SOCK_Test.cpp b/tests/SOCK_Test.cpp index 08b8683ad76..4dfc0ac5023 100644 --- a/tests/SOCK_Test.cpp +++ b/tests/SOCK_Test.cpp @@ -71,8 +71,8 @@ client (void *arg) // Send data to server (correctly handles "incomplete writes"). - for (char c = 'a'; c <= 'z'; c++) - if (cli_stream.send_n (&c, 1) == -1) + for (char *c = ACE_ALPHABET; *c != '\0'; c++) + if (cli_stream.send_n (c, 1) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "send_n")); // Explicitly close the writer-side of the connection. @@ -119,7 +119,7 @@ server (void *arg) for (;;) { char buf[BUFSIZ]; - char t = 'a'; + char *t = ACE_ALPHABET; handle_set.reset (); handle_set.set_bit (peer_acceptor->get_handle ()); @@ -163,7 +163,7 @@ server (void *arg) while ((r_bytes = new_stream.recv (buf, 1)) > 0) { - ACE_ASSERT (t == buf[0]); + ACE_ASSERT (*t == buf[0]); t++; } diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp index c06dded2721..f47368c9e71 100644 --- a/tests/SPIPE_Test.cpp +++ b/tests/SPIPE_Test.cpp @@ -51,8 +51,8 @@ client (void *) if (con.connect (cli_stream, ACE_SPIPE_Addr (ACE_WIDE_STRING (rendezvous))) == -1) ACE_ERROR ((LM_ERROR, "%p\n", rendezvous)); - for (char c = 'a'; c <= 'z'; c++) - if (cli_stream.send (&c, 1) == -1) + for (char *c = ACE_ALPHABET; *c != '\0'; c++) + if (cli_stream.send (c, 1) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); if (cli_stream.close () == -1) @@ -74,7 +74,7 @@ server (void *) ACE_SPIPE_Acceptor acceptor; ACE_SPIPE_Stream new_stream; char buf[BUFSIZ]; - char t = 'a'; + char *t = ACE_ALPHABET; const char *rendezvous = PIPE_NAME; @@ -93,7 +93,7 @@ server (void *) while (new_stream.recv (buf, 1) > 0) { - ACE_ASSERT (t == buf[0]); + ACE_ASSERT (*t == buf[0]); t++; } ACE_DEBUG ((LM_DEBUG, "End of connection. Closing handle\n")); diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp index e5d7348c26a..e7e9eee727c 100644 --- a/tests/SV_Shared_Memory_Test.cpp +++ b/tests/SV_Shared_Memory_Test.cpp @@ -28,7 +28,9 @@ static ACE_Malloc<ACE_SHARED_MEMORY_POOL, ACE_SV_Semaphore_Simple> allocator; const int SEM_KEY_1 = ACE_DEFAULT_SEM_KEY + 1; const int SEM_KEY_2 = ACE_DEFAULT_SEM_KEY + 2; + const int SHMSZ = 27; +const char SHMDATA[SHMSZ] = "abcdefghijklmnopqrstuvwxyz"; static int parent (char *shm) @@ -42,12 +44,8 @@ parent (char *shm) ACE_ASSERT (synch.open (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); - char *s = shm; - - for (char c = 'a'; c <= 'z'; c++) - *s++ = c; - - *s = '\0'; + for (int i = 0; i < SHMSZ; i++) + shm[i] = SHMDATA[i]; if (mutex.release () == -1) ACE_ERROR ((LM_ERROR, "(%P) %p", "parent mutex.release")); @@ -81,12 +79,8 @@ child (char *shm) else ACE_ERROR_RETURN ((LM_ERROR, "(%P) child mutex.tryacquire"), 1); - char t = 'a'; - for (char *s = (char *) shm; *s != '\0'; s++) - { - ACE_ASSERT (t == s[0]); - t++; - } + for (int i = 0; i < SHMSZ; i++) + ACE_ASSERT (SHMDATA[i] == shm[i]); if (synch.release () == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P) child synch.release"), 1); diff --git a/tests/Tokens_Test.cpp b/tests/Tokens_Test.cpp index 90c939ba79f..2c5605c3065 100644 --- a/tests/Tokens_Test.cpp +++ b/tests/Tokens_Test.cpp @@ -214,6 +214,11 @@ main (int, char *[]) server_host, server_port)); ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); + delete A; + delete B; + delete R; + delete W; + ACE_NEW_RETURN (A, ACE_Remote_Mutex ("R Mutex A", 0, 1), -1); ACE_NEW_RETURN (B, ACE_Remote_Mutex ("R Mutex B", 0, 1), -1); ACE_NEW_RETURN (R, ACE_Remote_RLock ("R Reader Lock", 0, 1), -1); @@ -228,6 +233,11 @@ main (int, char *[]) if (new_process.kill () == -1) ACE_ERROR_RETURN ((LM_ERROR, "Kill failed.\n"), -1); + delete A; + delete B; + delete R; + delete W; + ACE_DEBUG ((LM_DEBUG, "(%t) main thread exiting.\n")); #else ACE_ERROR ((LM_ERROR, diff --git a/tests/test_config.h b/tests/test_config.h index 0608be4ca34..cec49951d40 100644 --- a/tests/test_config.h +++ b/tests/test_config.h @@ -135,6 +135,8 @@ const int ACE_MAX_INTERVAL = 0; const int ACE_MAX_ITERATIONS = 10; const int ACE_MAX_PROCESSES = 10; +char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + class ACE_Test_Output { public: |