summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-97a43
-rw-r--r--ace/Mem_Map.cpp3
-rw-r--r--ace/Mem_Map.i8
-rw-r--r--ace/Timer_Heap.cpp11
-rw-r--r--ace/Timer_Heap.h4
-rw-r--r--ace/Timer_List.cpp7
-rw-r--r--ace/Timer_List.h4
-rw-r--r--ace/Timer_Queue.h4
-rw-r--r--ace/config-hpux-10.x.h4
-rw-r--r--examples/Mem_Map/IO-tests/IO_Test.cpp10
-rw-r--r--examples/Mem_Map/IO-tests/test_io.cpp66
11 files changed, 111 insertions, 53 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a
index accc8affd53..d5cfd05f920 100644
--- a/ChangeLog-97a
+++ b/ChangeLog-97a
@@ -1,3 +1,9 @@
+Sun Mar 16 11:31:46 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * ace/Timer_{List,Queue,Heap}.h: Defined copy constructors and
+ assignment operators in the private part of the class so that
+ users won't accidentally make mistakes.
+
Mon Mar 17 06:58:18 1997 David L. Levine <levine@cs.wustl.edu>
* ace/OS.cpp (sched_params): return -1 if not supported,
@@ -16,6 +22,43 @@ Mon Mar 17 06:58:18 1997 David L. Levine <levine@cs.wustl.edu>
comparison, and eventual seg fault because a loop would never
terminate.
+Sat Mar 15 21:44:45 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * ace/Timer_{Queue,List}.cpp (cancel): handle_close() should be
+ called only once (especially when handle_close() implements
+ "delete this;" ). Since it is possible that the EH will be
+ registered more than once, I changed the code to do the
+ following:
+
+ if (number_of_cancellations == 1)
+ // Call the close hook.
+ curr->handler_->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::TIMER_MASK);
+
+ Thanks to Hamutal Yanay <Hamutal_Yanay@mail.icomverse.com> for
+ suggesting this.
+
+ * examples/Mem_Map/IO-tests/test_io.cpp (run_tests): Removed all
+ uses of ::perror and replaced them with calls to ACE_ERROR
+ macros.
+
+ * ace/Mem_Map.i (unmap): The ACE_Mem_Map::close method does not
+ work properly if the value of file_mapping_ is equal to
+ ACE_INVALID_HANDLE. In this case the method calls a useless
+ close (-1). Therefore, I changed:
+
+ if (this->file_mapping_ != this->handle_)
+ ACE_OS::close (this->file_mapping_);
+
+ in:
+
+ if (this->file_mapping_ != this->handle_ &&
+ this->file_mapping_ != ACE_INVALID_HANDLE)
+ ACE_OS::close (this->file_mapping_);
+
+ Thanks to Sandro Doro <alex@aureus.sublink.org> for reporting
+ this.
+
Thu Mar 13 18:21:15 1997 Irfan Pyarali <irfan@flamenco.cs.wustl.edu>
* ace/ReactorEx.h: Change protection of methods/variables of
diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp
index 2da6892070c..257aba5a038 100644
--- a/ace/Mem_Map.cpp
+++ b/ace/Mem_Map.cpp
@@ -34,7 +34,8 @@ ACE_Mem_Map::close (void)
this->unmap ();
- if (this->file_mapping_ != this->handle_)
+ if (this->file_mapping_ != this->handle_
+ && this->file_mapping_ != ACE_INVALID_HANDLE)
ACE_OS::close (this->file_mapping_);
if (this->close_handle_)
diff --git a/ace/Mem_Map.i b/ace/Mem_Map.i
index 62b3cd6daa6..f0941de8d1a 100644
--- a/ace/Mem_Map.i
+++ b/ace/Mem_Map.i
@@ -86,7 +86,9 @@ ACE_INLINE int
ACE_Mem_Map::unmap (int len)
{
ACE_TRACE ("ACE_Mem_Map::unmap");
- if (this->file_mapping_ != this->handle_)
+
+ if (this->file_mapping_ != this->handle_
+ && this->file_mapping_ != ACE_INVALID_HANDLE)
ACE_OS::close (this->file_mapping_);
this->file_mapping_ = ACE_INVALID_HANDLE;
@@ -100,7 +102,9 @@ ACE_INLINE int
ACE_Mem_Map::unmap (void *addr, int len)
{
ACE_TRACE ("ACE_Mem_Map::unmap");
- if (this->file_mapping_ != this->handle_)
+
+ if (this->file_mapping_ != this->handle_
+ && this->file_mapping_ != ACE_INVALID_HANDLE)
ACE_OS::close (this->file_mapping_);
this->file_mapping_ = ACE_INVALID_HANDLE;
diff --git a/ace/Timer_Heap.cpp b/ace/Timer_Heap.cpp
index 059f9f8570b..60e23aeaba7 100644
--- a/ace/Timer_Heap.cpp
+++ b/ace/Timer_Heap.cpp
@@ -512,11 +512,14 @@ ACE_Timer_Heap::cancel (ACE_Event_Handler *handler)
if (this->heap_[i]->handler_ == handler)
{
ACE_Timer_Node *temp = this->remove (i);
- // Call the close hook.
- temp->handler_->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::TIMER_MASK);
- this->free_node (temp);
+
number_of_cancellations++;
+
+ if (number_of_cancellations == 1)
+ // Call the close hook.
+ temp->handler_->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::TIMER_MASK);
+ this->free_node (temp);
}
else
i++;
diff --git a/ace/Timer_Heap.h b/ace/Timer_Heap.h
index 3dee9a4a8ee..5b24e3dcc4e 100644
--- a/ace/Timer_Heap.h
+++ b/ace/Timer_Heap.h
@@ -204,6 +204,10 @@ private:
ACE_Unbounded_Set<ACE_Timer_Node *> preallocated_node_set_;
// Set of pointers to the arrays of preallocated timer nodes.
// Used to delete the allocated memory when required.
+
+ // = Don't allow these operations for now.
+ ACE_Timer_Heap (const ACE_Timer_Heap &);
+ void operator= (const ACE_Timer_Heap &);
};
#endif /* ACE_TIMER_HEAP_H */
diff --git a/ace/Timer_List.cpp b/ace/Timer_List.cpp
index 48599d4e555..bc969e57411 100644
--- a/ace/Timer_List.cpp
+++ b/ace/Timer_List.cpp
@@ -258,9 +258,10 @@ ACE_Timer_List::cancel (ACE_Event_Handler *handler)
{
number_of_cancellations++;
- // Call the close hook.
- curr->handler_->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::TIMER_MASK);
+ if (number_of_cancellations == 1)
+ // Call the close hook.
+ curr->handler_->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::TIMER_MASK);
if (prev == 0)
{
this->head_ = curr->next_;
diff --git a/ace/Timer_List.h b/ace/Timer_List.h
index 379471ae2be..9864fc65b56 100644
--- a/ace/Timer_List.h
+++ b/ace/Timer_List.h
@@ -145,6 +145,10 @@ private:
// Keeps track of the timer id that uniquely identifies each timer.
// This id can be used to cancel a timer via the <cancel (int)>
// method.
+
+ // = Don't allow these operations for now.
+ ACE_Timer_List (const ACE_Timer_List &);
+ void operator= (const ACE_Timer_List &);
};
#endif /* ACE_TIMER_LIST_H */
diff --git a/ace/Timer_Queue.h b/ace/Timer_Queue.h
index b5aa653801c..038eb8533c6 100644
--- a/ace/Timer_Queue.h
+++ b/ace/Timer_Queue.h
@@ -214,6 +214,10 @@ private:
ACE_Time_Value timer_skew_;
// Adjusts for timer skew in various clocks.
+
+ // = Don't allow these operations for now.
+ ACE_Timer_Queue (const ACE_Timer_Queue &);
+ void operator= (const ACE_Timer_Queue &);
};
#if defined (__ACE_INLINE__)
diff --git a/ace/config-hpux-10.x.h b/ace/config-hpux-10.x.h
index b40b27c39ea..9b4307720a7 100644
--- a/ace/config-hpux-10.x.h
+++ b/ace/config-hpux-10.x.h
@@ -56,6 +56,8 @@
// Compiler/platform defines the sig_atomic_t typedef
#define ACE_HAS_SIG_ATOMIC_T
+// If you don't want to use threads make sure to comment out the
+// folowing block of #defines
#define ACE_HAS_THREADS
#define ACE_HAS_PTHREADS
#define ACE_LACKS_RWLOCK_T
@@ -69,8 +71,6 @@
#define ACE_LACKS_KEYDELETE /* new */
#define ACE_LACKS_THREAD_PROCESS_SCOPING
#define ACE_LACKS_THREAD_STACK_ADDR
-
-// Compiler/platform has thread-specific storage
#define ACE_HAS_THREAD_SPECIFIC_STORAGE
// Compiler/platform supports struct strbuf.
diff --git a/examples/Mem_Map/IO-tests/IO_Test.cpp b/examples/Mem_Map/IO-tests/IO_Test.cpp
index aef0b12c597..ceef5e8e39d 100644
--- a/examples/Mem_Map/IO-tests/IO_Test.cpp
+++ b/examples/Mem_Map/IO-tests/IO_Test.cpp
@@ -83,7 +83,7 @@ Block_Read_Write_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp
while (--iterations >= 0)
{
char buf[BUFSIZ];
- int n;
+ ssize_t n;
while ((n = ACE_OS::read (ifd, buf, sizeof buf)) > 0)
::write (ofd, buf, n);
@@ -109,7 +109,7 @@ Block_Fread_Fwrite_Test::run_test (int iterations, FILE *input_fp, FILE *output_
while (--iterations >= 0)
{
char buf[BUFSIZ];
- int n;
+ ssize_t n;
while ((n = ACE_OS::fread (buf, 1, sizeof buf, input_fp)) != 0)
::fwrite (buf, n, 1, output_fp);
@@ -134,7 +134,7 @@ Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp)
void *src = 0;
if (map_input (src) == -1)
- return -1;
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s", this->name ()), -1);
else
{
this->tm_.start ();
@@ -142,7 +142,7 @@ Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp)
while (--iterations >= 0)
{
if (ACE_OS::write (fileno (output_fp), src, map_input.size ()) == -1)
- return -1;
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s", this->name ()), -1);
ACE_OS::lseek (fileno (output_fp), 0, SEEK_SET);
}
@@ -150,7 +150,7 @@ Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp)
}
if (map_input.unmap () == -1)
- return -1;
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s", this->name ()), -1);
else
return 0;
}
diff --git a/examples/Mem_Map/IO-tests/test_io.cpp b/examples/Mem_Map/IO-tests/test_io.cpp
index 0b155fb0631..5e3ad676928 100644
--- a/examples/Mem_Map/IO-tests/test_io.cpp
+++ b/examples/Mem_Map/IO-tests/test_io.cpp
@@ -47,17 +47,6 @@ cleanup (int = 0)
ACE_OS::exit (0);
}
-// Set up the program name used in error messages.
-
-static void
-set_program_name (char name[])
-{
- if ((name = strrchr (name, '/')) == 0)
- program_name = name;
- else
- program_name = name + 1;
-}
-
// Parse the command-line arguments and set options.
static void
@@ -86,33 +75,37 @@ parse_args (int argc, char *argv[])
}
}
-// Vector of pointers to derived classes that inherit from IO_Test base class.
+// Vector of pointers to derived classes that inherit from IO_Test
+// base class.
static IO_Test *test_vector[100];
static void
run_tests (int iterations, FILE *input_fp, FILE *output_fp)
{
- // If HP/UX didn't suck so badly we could initialize in the global scope...
- test_vector[0] = new Stdio_Test ("Stdio_Test", tm);
- test_vector[1] = new Block_Fread_Fwrite_Test ("Block_Fread_Fwrite_Test", tm);
- test_vector[2] = new Block_Read_Write_Test ("Block_Read_Write_Test", tm);
- test_vector[3] = new Mmap1_Test ("Mmap1_Test", tm);
- test_vector[4] = new Mmap2_Test ("Mmap2_Test", tm);
- // test_vector[5] = new Slow_Read_Write_Test ("Slow"Read_Write_Test", tm)
- test_vector[5] = (IO_Test *) 0;
-
- for (int i = 0; test_vector[i] != 0; i++)
+ // If HP/UX didn't suck so badly we could initialize in the global
+ // scope...
+ int i = 0;
+
+ ACE_NEW (test_vector[i++], Stdio_Test ("Stdio_Test", tm));
+ ACE_NEW (test_vector[i++], Block_Fread_Fwrite_Test ("Block_Fread_Fwrite_Test", tm));
+ ACE_NEW (test_vector[i++], Block_Read_Write_Test ("Block_Read_Write_Test", tm));
+ ACE_NEW (test_vector[i++], Mmap1_Test ("Mmap1_Test", tm));
+ ACE_NEW (test_vector[i++], Mmap2_Test ("Mmap2_Test", tm));
+ ACE_NEW (test_vector[i++], Slow_Read_Write_Test ("Slow_Read_Write_Test", tm));
+
+ test_vector[i] = (IO_Test *) 0;
+
+ for (i = 0; test_vector[i] != 0; i++)
{
if (ACE_OS::ftruncate (fileno (output_fp), 0) == -1)
- ::perror ("ftruncate");
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s\n", "ftruncate"));
cerr << "--------------------\n"
<< "starting " << test_vector[i]->name () << " for " << iterations
<< " iteration(s):\n";
- if (test_vector[i]->run_test (iterations, input_fp, output_fp) == -1)
- ::perror (test_vector[i]->name ());
+ test_vector[i]->run_test (iterations, input_fp, output_fp);
ACE_Profile_Timer::ACE_Elapsed_Time et;
tm.elapsed_time (et);
@@ -130,27 +123,28 @@ run_tests (int iterations, FILE *input_fp, FILE *output_fp)
int
main (int argc, char *argv[])
{
- FILE *input_fp;
- FILE *output_fp;
-
- set_program_name (argv[0]);
+ program_name = ACE::basename (argv[0]);
parse_args (argc, argv);
ACE_Sig_Action sa ((ACE_SignalHandler) cleanup, SIGINT);
ACE_UNUSED_ARG (sa);
- if ((input_fp = ACE_OS::fopen (input_filename, "r")) == 0)
- ACE_OS::perror (input_filename), ACE_OS::exit (1);
+ FILE *input_fp = ACE_OS::fopen (input_filename, "r");
+ FILE *output_fp = ACE_OS::fopen (output_filename, "w+");
- ACE_OS::unlink (output_filename);
+ if (input_fp == 0)
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s\n", "input_filename"), -1);
+
+ if (output_fp == 0)
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s\n", "output_filename"), -1);
- if ((output_fp = ACE_OS::fopen (output_filename, "w+")) == 0)
- ACE_OS::perror (output_filename), ACE_OS::exit (1);
+ ACE_OS::unlink (output_filename);
run_tests (iteration_count, input_fp, output_fp);
- if (ACE_OS::fclose (input_fp) == -1 || ACE_OS::fclose (output_fp) == -1)
- ACE_OS::perror ("fclose"), ACE_OS::exit (1);
+ if (ACE_OS::fclose (input_fp) == -1
+ || ACE_OS::fclose (output_fp) == -1)
+ ACE_ERROR_RETURN ((ACE_ERROR, "%s\n", "fclose"), -1);
cleanup ();
return 0;