summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-98b28
-rw-r--r--ace/FILE.cpp48
-rw-r--r--ace/FILE.h38
-rw-r--r--ace/FILE_Addr.cpp7
-rw-r--r--ace/FILE_Addr.h3
-rw-r--r--ace/FILE_Connector.cpp11
-rw-r--r--ace/FILE_Connector.h4
-rw-r--r--ace/FILE_IO.cpp30
-rw-r--r--ace/FILE_IO.h11
-rw-r--r--ace/Mem_Map.cpp5
-rw-r--r--ace/Mem_Map.h4
-rw-r--r--tests/Conn_Test.cpp2
-rw-r--r--tests/Notify_Performance_Test.cpp2
-rw-r--r--tests/Priority_Reactor_Test.cpp2
14 files changed, 124 insertions, 71 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b
index 0182cffe58b..1c023c12f1e 100644
--- a/ChangeLog-98b
+++ b/ChangeLog-98b
@@ -1,6 +1,25 @@
Sun Jan 3 14:39:49 1999 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
- * ace/FILE_Connector.h: Updated the comments.
+ * ace/Mem_Map.cpp: mmap() will fail if the length of the file
+ mapping is 0, which will be the case if we've just created the
+ file. Therefore, don't even bother trying to mmap() in this
+ case and return a successful result.
+
+ * ace/FILE: Moved the get_remote_addr() and get_local_addr()
+ methods from the FILE_IO class to the FILE class since that's
+ more properly where they belong. Also added a new remove()
+ method that unlinks the file.
+
+ * tests/Priority_Reactor_Test.cpp,
+ tests/Conn_Test.cpp,
+ tests/Notify_Performance_Test.cpp,
+ Priority_Reactor_Test.cpp,
+ Reactor_Performance_Test.cpp: Since the default is to skip argv0
+ there's no sense explicitly saying this in the constructor of
+ ACE_Get_Opt.
+
+ * ace/FILE_Connector.h: Updated the comments to reflect recent
+ changes.
* ace/FILE.h: Added a new get_info() method that takes a reference
to an ACE_FILE_Info rather than a pointer. This is a cleaner
@@ -8,8 +27,11 @@ Sun Jan 3 14:39:49 1999 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
* ace/FILE_Connector.cpp (connect): When the <remote_sap> argument
is ACE_Addr::sap_any, then connect will select a temporary
- filename using the new ACE_DEFAULT_TEMP_FILE macro and
- ACE_OS::mktemp().
+ filename using the new feature of ACE_FILE_Addr described below.
+
+ * ace/FILE_Addr.cpp (set): When the address is ACE_Addr::sap_any,
+ then we'll select a new temporary filename using the new
+ ACE_DEFAULT_TEMP_FILE macro and ACE_OS::mktemp().
* ace/OS.h: Added a new ACE_DEFAULT_TEMP_FILE macro that defaults
to "/tmp/ace-file-XXXXXX" and is used by the ACE_FILE_Connector
diff --git a/ace/FILE.cpp b/ace/FILE.cpp
index db2ef4b09d1..2c39321cd89 100644
--- a/ace/FILE.cpp
+++ b/ace/FILE.cpp
@@ -87,3 +87,51 @@ ACE_FILE::position (void)
ACE_TRACE ("ACE_FILE::position");
return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR);
}
+
+// Return the local endpoint address.
+
+int
+ACE_FILE::get_local_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_FILE::get_local_addr");
+
+ // Perform the downcast since <addr> had better be an
+ // <ACE_FILE_Addr>.
+ ACE_FILE_Addr *file_addr =
+ ACE_dynamic_cast (ACE_FILE_Addr *, &addr);
+
+ if (file_addr == 0)
+ return -1;
+ else
+ {
+ *file_addr = this->addr_;
+ return 0;
+ }
+}
+
+// Return the same result as <get_local_addr>.
+
+int
+ACE_FILE::get_remote_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_FILE::get_remote_addr");
+
+ return this->get_local_addr (addr);
+}
+
+int
+ACE_FILE::remove (void)
+{
+ ACE_TRACE ("ACE_FILE::remove");
+
+ this->close ();
+ return ACE_OS::unlink (this->addr_.get_path_name ());
+}
+
+int
+ACE_FILE::unlink (void)
+{
+ ACE_TRACE ("ACE_FILE::unlink");
+
+ return ACE_OS::unlink (this->addr_.get_path_name ());
+}
diff --git a/ace/FILE.h b/ace/FILE.h
index e80188c6e59..f21795e9c22 100644
--- a/ace/FILE.h
+++ b/ace/FILE.h
@@ -56,11 +56,18 @@ public:
class ACE_Export ACE_FILE : public ACE_IO_SAP
{
// = TITLE
- // Defines the member functions for the base class of the
- // ACE_FILE abstraction.
+ // Defines the core methods of the <ACE_FILE> abstraction.
public:
int close (void);
- // Close down the ACE_FILE
+ // Close the <ACE_FILE> handle without removing the <ACE_FILE> from
+ // the file system.
+
+ int remove (void);
+ // Close and remove the <ACE_FILE> from the file system.
+
+ int unlink (void);
+ // Remove the <ACE_FILE> from the file system without closing the
+ // <ACE_FILE> handle.
int get_info (ACE_FILE_Info *finfo);
// Get information on this <ACE_FILE>.
@@ -69,28 +76,39 @@ public:
// Get information on this <ACE_FILE>.
int truncate (off_t length);
- // set filesize to length byte
+ // Set filesize to length byte.
off_t position (long offset, int startpos);
- // set the filepointer to the specified position
+ // Set the filepointer to the specified position.
off_t position (void);
- // get current filepointer
-
- void dump (void) const;
- // Dump the state of an object.
+ // Get current filepointer.
int disable (int signum) const ;
// Disable signal <signum>
// This is here to prevent Win32 from
// disabling SPIPE using socket calls
+ int get_local_addr (ACE_Addr &) const;
+ // Return the local endpoint address in the referenced <ACE_Addr>.
+ // Returns 0 if successful, else -1.
+
+ int get_remote_addr (ACE_Addr &) const;
+ // Return the same thing as <get_local_addr>.
+
+ void dump (void) const;
+ // Dump the state of an object.
+
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
protected:
ACE_FILE (void);
- // Ensure that this class is an abstract base class
+ // Ensure that this class is only created by the
+ // <ACE_FILE_Connector>.
+
+ ACE_FILE_Addr addr_;
+ // File we are "connected" with...
};
#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
diff --git a/ace/FILE_Addr.cpp b/ace/FILE_Addr.cpp
index 3aa24e4796a..3d59973d1f9 100644
--- a/ace/FILE_Addr.cpp
+++ b/ace/FILE_Addr.cpp
@@ -23,7 +23,12 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa)
this->base_set (sa.get_type (), sa.get_size ());
if (sa.get_type () == AF_ANY)
- this->filename_[0] = '\0';
+ {
+ // Create a temporary file.
+ ACE_OS::strcpy (this->filename_,
+ ACE_DEFAULT_TEMP_FILE);
+ ACE_OS::mktemp (this->filename_);
+ }
else
(void) ACE_OS::strncpy (this->filename_,
sa.filename_,
diff --git a/ace/FILE_Addr.h b/ace/FILE_Addr.h
index cb2111e55ef..c03a655289d 100644
--- a/ace/FILE_Addr.h
+++ b/ace/FILE_Addr.h
@@ -38,7 +38,8 @@ public:
// Copy constructor.
int set (const ACE_FILE_Addr &sa);
- // Acts like a copy constructor.
+ // Acts like a copy constructor. If <sa> == ACE_Addr::sap_any then
+ // create a temporary filename using <ACE_OS::mktemp>.
ACE_FILE_Addr (LPCTSTR filename);
// Create a ACE_FILE_Addr from a pathname.
diff --git a/ace/FILE_Connector.cpp b/ace/FILE_Connector.cpp
index e4a63b72824..3b77d2538db 100644
--- a/ace/FILE_Connector.cpp
+++ b/ace/FILE_Connector.cpp
@@ -43,14 +43,9 @@ ACE_FILE_Connector::connect (ACE_FILE_IO &new_io,
if (ACE_reinterpret_cast (const ACE_Addr &,
ACE_const_cast (ACE_FILE_Addr &,
remote_sap)) == ACE_Addr::sap_any)
- {
- ACE_FILE_Addr temp_sap (ACE_DEFAULT_TEMP_FILE);
-
- // Create a temporary file.
- ACE_OS::mktemp (ACE_const_cast (TCHAR *,
- temp_sap.get_path_name ()));
- new_io.addr_ = temp_sap; // class copy.
- }
+ // Create a new temporary file.
+ new_io.addr_ =
+ ACE_FILE_Addr (ACE_sap_any_cast (ACE_FILE_Addr &)); // class copy.
else
new_io.addr_ = remote_sap; // class copy.
diff --git a/ace/FILE_Connector.h b/ace/FILE_Connector.h
index 1f5a7b88e17..68da4f2a269 100644
--- a/ace/FILE_Connector.h
+++ b/ace/FILE_Connector.h
@@ -85,9 +85,9 @@ public:
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
- // = Meta-type info
+ // = Meta-type "trait" information.
typedef ACE_FILE_Addr PEER_ADDR;
- typedef ACE_FILE_IO PEER_STREAM;
+ typedef ACE_FILE_IO PEER_STREAM;
};
#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp
index a3fa8e7c4ce..594f59d6ca1 100644
--- a/ace/FILE_IO.cpp
+++ b/ace/FILE_IO.cpp
@@ -98,34 +98,4 @@ ACE_FILE_IO::recv (size_t n, ...) const
return result;
}
-// Return the local endpoint address.
-int
-ACE_FILE_IO::get_local_addr (ACE_Addr &addr) const
-{
- ACE_TRACE ("ACE_FILE_IO::get_local_addr");
-
- // Perform the downcast since <addr> had better be an
- // <ACE_FILE_Addr>.
- ACE_FILE_Addr *file_addr =
- ACE_dynamic_cast (ACE_FILE_Addr *, &addr);
-
- if (file_addr == 0)
- return -1;
- else
- {
- *file_addr = this->addr_;
- return 0;
- }
-}
-
-// Return the address of the remotely connected peer (if there is
-// one).
-
-int
-ACE_FILE_IO::get_remote_addr (ACE_Addr &addr) const
-{
- ACE_TRACE ("ACE_FILE_IO::get_remote_addr");
-
- return this->get_local_addr (addr);
-}
diff --git a/ace/FILE_IO.h b/ace/FILE_IO.h
index de8277823eb..37bd120df2e 100644
--- a/ace/FILE_IO.h
+++ b/ace/FILE_IO.h
@@ -106,17 +106,6 @@ public:
// = Meta-type info
typedef ACE_FILE_Addr PEER_ADDR;
-
- int get_local_addr (ACE_Addr &) const;
- // Return the local endpoint address in the referenced ACE_Addr.
- // Returns 0 if successful, else -1.
-
- int get_remote_addr (ACE_Addr &) const;
- // Return the same thing as <get_local_addr>.
-
-private:
- ACE_FILE_Addr addr_;
- // File we are "connected" with...
};
#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp
index e79a5cabf7e..aa0d54cb188 100644
--- a/ace/Mem_Map.cpp
+++ b/ace/Mem_Map.cpp
@@ -206,6 +206,11 @@ ACE_Mem_Map::map (LPCTSTR file_name,
mode,
sa) == -1)
return -1;
+ else if (ACE_BIT_ENABLED (flags, O_CREAT)
+ && len <= 0)
+ // <mmap> will fail if the length of the file mapping is 0, which
+ // will be the case if we've just created the file.
+ return 0;
else
return this->map_it (this->handle (),
len,
diff --git a/ace/Mem_Map.h b/ace/Mem_Map.h
index 650137c075b..d7de0ca1011 100644
--- a/ace/Mem_Map.h
+++ b/ace/Mem_Map.h
@@ -104,7 +104,7 @@ public:
int close_filemapping_handle (void);
// Close down the internal <file_mapping_> if necessary. This is
- // mostly necessary on Win32, that has a different handle for
+ // mostly necessary on Win32, which has a different handle for
// file-mapping kernel object.
int operator () (void *&addr);
@@ -143,7 +143,7 @@ public:
// starting at <addr> up to <len> bytes.
int remove (void);
- // Close down and remove the file from the file system.
+ // Close and remove the file from the file system.
int advise (int behavior, int len = -1);
// Hook into the underlying VM system.
diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp
index dfd5e02ba6f..7ad18826aab 100644
--- a/tests/Conn_Test.cpp
+++ b/tests/Conn_Test.cpp
@@ -648,7 +648,7 @@ main (int argc, ASYS_TCHAR *argv[])
{
ACE_START_TEST (ASYS_TEXT ("Conn_Test"));
- ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("c:i:s:"), 1);
+ ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("c:i:s:"));
for (int c; (c = getopt ()) != -1; )
switch (c)
{
diff --git a/tests/Notify_Performance_Test.cpp b/tests/Notify_Performance_Test.cpp
index 1eb354eee3b..f96947337a9 100644
--- a/tests/Notify_Performance_Test.cpp
+++ b/tests/Notify_Performance_Test.cpp
@@ -147,7 +147,7 @@ main (int argc, ASYS_TCHAR *argv[])
{
ACE_START_TEST (ASYS_TEXT ("Notify_Performance_Test"));
- ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("swdc:l:"), 1);
+ ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("swdc:l:"));
for (int c; (c = getopt ()) != -1; )
switch (c)
{
diff --git a/tests/Priority_Reactor_Test.cpp b/tests/Priority_Reactor_Test.cpp
index 4c09d51e566..ff6c3f5a83d 100644
--- a/tests/Priority_Reactor_Test.cpp
+++ b/tests/Priority_Reactor_Test.cpp
@@ -236,7 +236,7 @@ main (int argc, char *argv[])
{
ACE_START_TEST ("Priority_Reactor_Test");
- ACE_Get_Opt getopt (argc, argv, "dc:l:m:t:", 1);
+ ACE_Get_Opt getopt (argc, argv, "dc:l:m:t:");
for (int c; (c = getopt ()) != -1; )
switch (c)