summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-19 13:01:36 +0000
committerjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-19 13:01:36 +0000
commit18ad9dd5fbffd727d82f439693c68362639d9ac6 (patch)
tree4522dca7f9b577a166a81be247aaacd15fd8a878 /apps
parentaf98af5492c60f8df94b16dae34398c3e2df008a (diff)
downloadATCD-18ad9dd5fbffd727d82f439693c68362639d9ac6.tar.gz
Integrating new Filecache implementation.
Diffstat (limited to 'apps')
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp11
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/FILE.cpp31
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/FILE.h19
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/Filecache.cpp58
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/Filecache.h25
-rw-r--r--apps/JAWS/PROTOTYPE/JAWS/IO.cpp44
6 files changed, 127 insertions, 61 deletions
diff --git a/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp b/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp
index b50157121a2..d2264c7cefd 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp
+++ b/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp
@@ -230,10 +230,10 @@ JAWS_Cache_Manager<KEY,FACTORY,HASH_FUNC,EQ_FUNC>
result = this->MAKE (data, size, obj);
if (result == -1)
{
- if (obj)
- this->DROP_i (obj);
- else
+ if (size/1024 <= this->maxobjsize_)
cerr << "MAKE failed. Bummer!" << endl;
+ else
+ this->DROP_i (obj);
return -1;
}
@@ -268,10 +268,6 @@ JAWS_Cache_Manager<KEY,FACTORY,HASH_FUNC,EQ_FUNC>
return -1;
}
-#ifdef ENTERA_VERBOSE_TRACE
- cerr << "*** bound: " << key << endl;
-#endif
-
this->waterlevel_ += size;
// Acquire this one for the putter.
@@ -386,7 +382,6 @@ JAWS_Cache_Manager<KEY,FACTORY,HASH_FUNC,EQ_FUNC>
#else
// The above is a little tricky to implement. Think about it
// some more.
- cerr << "*** " << size << " is too large to cache" << endl;
obj = this->factory_->create (data, size);
return -1;
diff --git a/apps/JAWS/PROTOTYPE/JAWS/FILE.cpp b/apps/JAWS/PROTOTYPE/JAWS/FILE.cpp
index e036019f49c..16a2e0e0efc 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/FILE.cpp
+++ b/apps/JAWS/PROTOTYPE/JAWS/FILE.cpp
@@ -1,29 +1,35 @@
// $Id$
+#include "ace/OS.h"
+#include "ace/Synch.h"
+
#include "JAWS/FILE.h"
JAWS_FILE::JAWS_FILE (void)
- : map_handle_ (ACE_INVALID_HANDLE),
- map_ (0)
-{
-}
-
-JAWS_FILE::JAWS_FILE (ACE_HANDLE map_handle)
- : map_handle_ (map_handle),
- map_ (0)
+ : map_ (0)
{
}
ACE_Mem_Map *
-JAWS_FILE::mem_map (void) const
+JAWS_FILE::mem_map (int length,
+ int prot,
+ int share,
+ void *addr,
+ off_t offset,
+ LPSECURITY_ATTRIBUTES sa) const
{
JAWS_FILE *mutable_this = (JAWS_FILE *) this;
- return mutable_this->mem_map ();
+ return mutable_this->mem_map (length, prot, share, addr, offset, sa);
}
ACE_Mem_Map *
-JAWS_FILE::mem_map (void)
+JAWS_FILE::mem_map (int length,
+ int prot,
+ int share,
+ void *addr,
+ off_t offset,
+ LPSECURITY_ATTRIBUTES sa)
{
if (this->map_ == 0)
{
@@ -34,7 +40,8 @@ JAWS_FILE::mem_map (void)
this->map_ = new ACE_Mem_Map;
if (this->map_ != 0)
{
- int r = this->map_->map (this->map_handle_);
+ int r = this->map_->map (this->get_handle (),
+ length, prot, share, addr, offset, sa);
if (r < 0)
{
delete this->map_;
diff --git a/apps/JAWS/PROTOTYPE/JAWS/FILE.h b/apps/JAWS/PROTOTYPE/JAWS/FILE.h
index a7f12707e5d..93ab721379f 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/FILE.h
+++ b/apps/JAWS/PROTOTYPE/JAWS/FILE.h
@@ -8,6 +8,8 @@
#include "ace/FILE_IO.h"
#include "ace/Mem_Map.h"
+#include "JAWS/Export.h"
+
class JAWS_Export JAWS_FILE : public ACE_FILE_IO
//
// Like ACE_FILE_IO, but support for ACE_Mem_Map;
@@ -15,17 +17,24 @@ class JAWS_Export JAWS_FILE : public ACE_FILE_IO
public:
JAWS_FILE (void);
- JAWS_FILE (ACE_HANDLE map_handle);
- ACE_Mem_Map *mem_map (void);
- ACE_Mem_Map *mem_map (void) const;
+ ACE_Mem_Map *mem_map (int length = -1,
+ int prot = PROT_RDWR,
+ int share = ACE_MAP_PRIVATE,
+ void *addr = 0,
+ off_t offset = 0,
+ LPSECURITY_ATTRIBUTES sa = 0);
+ ACE_Mem_Map *mem_map (int length = -1,
+ int prot = PROT_RDWR,
+ int share = ACE_MAP_PRIVATE,
+ void *addr = 0,
+ off_t offset = 0,
+ LPSECURITY_ATTRIBUTES sa = 0) const;
ACE_Mem_Map *map (void) const;
private:
- ACE_HANDLE map_handle_;
-
ACE_SYNCH_MUTEX lock_;
ACE_Mem_Map *map_;
diff --git a/apps/JAWS/PROTOTYPE/JAWS/Filecache.cpp b/apps/JAWS/PROTOTYPE/JAWS/Filecache.cpp
index 08e9bdcb6cb..fc17424ba86 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/Filecache.cpp
+++ b/apps/JAWS/PROTOTYPE/JAWS/Filecache.cpp
@@ -1,27 +1,28 @@
// $Id$
#include "JAWS/Filecache.h"
+#include "JAWS/Cache_List_T.h"
void
-JAWS_Referenced_Filecache_Factory::destroy (ACE_Cache_Object *object)
+JAWS_Referenced_Filecache_Factory::destroy (JAWS_Cache_Object *object)
{
JAWS_FILE *file = (JAWS_FILE *) object->data ();
file->close ();
if (file->map ())
file->map ()->close ();
delete file;
- this->ACE_Referenced_Cache_Object_Factory::destroy (object);
+ this->JAWS_Referenced_Cache_Object_Factory::destroy (object);
}
void
-JAWS_Counted_Filecache_Factory::destroy (ACE_Cache_Object *object)
+JAWS_Counted_Filecache_Factory::destroy (JAWS_Cache_Object *object)
{
JAWS_FILE *file = (JAWS_FILE *) object->data ();
file->close ();
if (file->map ())
file->map ()->close ();
delete file;
- this->ACE_Counted_Cache_Object_Factory::destroy (object);
+ this->JAWS_Counted_Cache_Object_Factory::destroy (object);
}
JAWS_Cached_FILE::JAWS_Cached_FILE (const char *const &filename,
@@ -31,13 +32,13 @@ JAWS_Cached_FILE::JAWS_Cached_FILE (const char *const &filename,
ACE_HANDLE handle = ACE_INVALID_HANDLE;
if (this->data () != 0)
- handle = ACE_OS::dup (this->date ()->get_handle ());
+ handle = ACE_OS::dup (this->data ()->get_handle ());
- this->file_->set_handle (handle);
+ this->file_.set_handle (handle);
}
JAWS_Cached_FILE::JAWS_Cached_FILE (const char *const &filename,
- ACE_FILE_IO *&file,
+ JAWS_FILE *&file,
size_t size,
JAWS_Filecache_Proxy::Cache_Manager *cm)
: JAWS_Filecache_Proxy (filename, file, size, cm)
@@ -60,3 +61,46 @@ JAWS_Cached_FILE::mmap (void)
{
return this->data ()->mem_map ();
}
+
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+template class JAWS_Cache_List_Item<JAWS_Strdup_String,
+ JAWS_Referenced_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_List_Item<JAWS_Strdup_String,
+ JAWS_Counted_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_List<JAWS_Strdup_String,
+ JAWS_Referenced_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_List<JAWS_Strdup_String,
+ JAWS_Counted_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_Manager<JAWS_Strdup_String,
+ JAWS_Referenced_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_Manager<JAWS_Strdup_String,
+ JAWS_Counted_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>;
+template class JAWS_Cache_Proxy<char const *,
+ JAWS_FILE,
+ JAWS_Referenced_Filecache_Manager>;
+template class JAWS_Cache_Proxy<char const *,
+ JAWS_FILE,
+ JAWS_Counted_Filecache_Manager>;
+template class ACE_Singleton<JAWS_Referenced_Filecache_Manager,
+ ACE_Thread_Mutex>;
+template class ACE_Singleton<JAWS_Counted_Filecache_Manager,
+ ACE_Thread_Mutex>;
+template class ACE_Singleton<JAWS_Referenced_Filecache_Factory,
+ ACE_Thread_Mutex>;
+template class ACE_Singleton<JAWS_Counted_Filecache_Factory, ACE_Thread_Mutex>;
+
+#endif
diff --git a/apps/JAWS/PROTOTYPE/JAWS/Filecache.h b/apps/JAWS/PROTOTYPE/JAWS/Filecache.h
index 037611f66bd..c55fa498a7a 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/Filecache.h
+++ b/apps/JAWS/PROTOTYPE/JAWS/Filecache.h
@@ -8,6 +8,7 @@
#include "ace/FILE_IO.h"
#include "JAWS/Cache_Manager.h"
+#include "JAWS/FILE.h"
#include "JAWS/Export.h"
class JAWS_Export JAWS_Referenced_Filecache_Factory
@@ -15,7 +16,7 @@ class JAWS_Export JAWS_Referenced_Filecache_Factory
{
public:
- virtual void destroy (ACE_Cache_Object *);
+ virtual void destroy (JAWS_Cache_Object *);
};
@@ -24,26 +25,26 @@ class JAWS_Export JAWS_Counted_Filecache_Factory
{
public:
- virtual void destroy (ACE_Cache_Object *);
+ virtual void destroy (JAWS_Cache_Object *);
};
-typedef ACE_Cache_Manager<ACE_Strdup_String,
- JAWS_Referenced_Filecache_Factory,
- ACE_String_Hash_Functor,
- ACE_String_Equal_Functor>
+typedef JAWS_Cache_Manager<JAWS_Strdup_String,
+ JAWS_Referenced_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>
JAWS_Referenced_Filecache_Manager;
-typedef ACE_Cache_Manager<ACE_Strdup_String,
- JAWS_Counted_Filecache_Factory,
- ACE_String_Hash_Functor,
- ACE_String_Equal_Functor>
+typedef JAWS_Cache_Manager<JAWS_Strdup_String,
+ JAWS_Counted_Filecache_Factory,
+ JAWS_String_Hash_Functor,
+ JAWS_String_Equal_Functor>
JAWS_Counted_Filecache_Manager;
typedef JAWS_Referenced_Filecache_Manager JAWS_Filecache_Manager;
-typedef ACE_Cache_Proxy<const char *,
- JAWS_FILE, JAWS_Filecache_Manager>
+typedef JAWS_Cache_Proxy<const char *,
+ JAWS_FILE, JAWS_Filecache_Manager>
JAWS_Filecache_Proxy;
class JAWS_Export JAWS_Cached_FILE : private JAWS_Filecache_Proxy
diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO.cpp b/apps/JAWS/PROTOTYPE/JAWS/IO.cpp
index 959f8eec830..e5542efc15d 100644
--- a/apps/JAWS/PROTOTYPE/JAWS/IO.cpp
+++ b/apps/JAWS/PROTOTYPE/JAWS/IO.cpp
@@ -10,6 +10,7 @@
#include "JAWS/IO.h"
#include "JAWS/IO_Handler.h"
#include "JAWS/IO_Acceptor.h"
+#include "JAWS/Filecache.h"
// #include "HTTP_Helpers.h"
@@ -67,7 +68,7 @@ JAWS_Synch_IO::~JAWS_Synch_IO (void)
void
JAWS_Synch_IO::accept (JAWS_IO_Handler *ioh,
ACE_Message_Block *,
- unsigned int size)
+ unsigned int)
{
ACE_SOCK_Stream new_stream;
new_stream.set_handle (ACE_INVALID_HANDLE);
@@ -107,7 +108,7 @@ JAWS_Synch_IO::receive_file (JAWS_IO_Handler *ioh,
unsigned int entire_length)
{
ACE_Filecache_Handle handle (filename,
- ACE_reinterpret_cast(int, entire_length));
+ (int) entire_length);
int result = handle.error ();
@@ -187,11 +188,17 @@ JAWS_Synch_IO::transmit_file (JAWS_IO_Handler *ioh,
const char *trailer,
unsigned int trailer_size)
{
- ACE_Filecache_Handle handle (filename);
+ int result = 0;
- int result = handle.error ();
+ if (filename == 0)
+ {
+ ioh->transmit_file_error (-1);
+ return;
+ }
- if (result == ACE_Filecache_Handle::ACE_SUCCESS)
+ JAWS_Cached_FILE cf (filename);
+
+ if (cf.file ()->get_handle () != ACE_INVALID_HANDLE)
{
#if defined (ACE_JAWS_BASELINE) || defined (ACE_WIN32)
ACE_SOCK_Stream stream;
@@ -215,10 +222,13 @@ JAWS_Synch_IO::transmit_file (JAWS_IO_Handler *ioh,
iov[iovcnt].iov_len = header_size;
iovcnt++;
}
- if (handle.size () > 0)
+
+ ACE_FILE_Info info;
+ cf.file ()->get_info (info);
+ if (cf.file ()->get_info (info) == 0 && info.size_ > 0)
{
- iov[iovcnt].iov_base = ACE_reinterpret_cast(char*,handle.address ());
- iov[iovcnt].iov_len = handle.size ();
+ iov[iovcnt].iov_base = (char *) cf.mmap ()->addr ();
+ iov[iovcnt].iov_len = info.size_;
iovcnt++;
}
if (trailer_size > 0)
@@ -234,7 +244,7 @@ JAWS_Synch_IO::transmit_file (JAWS_IO_Handler *ioh,
#endif /* ACE_JAWS_BASELINE */
}
- if (result != ACE_Filecache_Handle::ACE_SUCCESS)
+ if (result != 0)
ioh->transmit_file_error (result);
}
@@ -434,6 +444,8 @@ JAWS_Asynch_IO::transmit_file (JAWS_IO_Handler *ioh,
const char *trailer,
unsigned int trailer_size)
{
+ int result = 0;
+
JAWS_TRACE ("JAWS_Asynch_IO::transmit_file");
ioh->idle ();
@@ -442,11 +454,9 @@ JAWS_Asynch_IO::transmit_file (JAWS_IO_Handler *ioh,
ACE_dynamic_cast (JAWS_Asynch_IO_Handler *, ioh);
ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer = 0;
- ACE_Filecache_Handle *handle = new ACE_Filecache_Handle (filename, ACE_NOMAP);
-
- int result = handle->error ();
+ JAWS_Cached_FILE *cf = new JAWS_Cached_FILE (filename);
- if (result == ACE_Filecache_Handle::ACE_SUCCESS)
+ if (cf->file ()->get_handle () != ACE_INVALID_HANDLE)
{
ACE_Message_Block hdr_mb (header, header_size);
ACE_Message_Block trl_mb (trailer, trailer_size);
@@ -457,23 +467,23 @@ JAWS_Asynch_IO::transmit_file (JAWS_IO_Handler *ioh,
ACE_Asynch_Transmit_File tf;
if (tf.open (*(aioh->handler ()), aioh->handle ()) == -1
- || tf.transmit_file (handle->handle (), // file handle
+ || tf.transmit_file (cf->file ()->get_handle (), // file handle
header_and_trailer, // header and trailer data
0, // bytes_to_write
0, // offset
0, // offset_high
0, // bytes_per_send
0, // flags
- handle // act
+ cf // act
) == -1)
result = -1;
}
- if (result != ACE_Filecache_Handle::ACE_SUCCESS)
+ if (result != 0)
{
ioh->transmit_file_error (result);
delete header_and_trailer;
- delete handle;
+ delete cf;
}
}