diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-11 00:45:19 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-11 00:45:19 +0000 |
commit | a9bf571972ac2c5eee629ef061437f5a41090fde (patch) | |
tree | 1f09df5ac1ebfbf4309b5fb9751cb4bfb859f44d /ace | |
parent | 9b71450b19be4d024fbfc9a90c2ab136e53002a1 (diff) | |
download | ATCD-a9bf571972ac2c5eee629ef061437f5a41090fde.tar.gz |
.
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Local_Name_Space_T.cpp | 16 | ||||
-rw-r--r-- | ace/Mem_Map.cpp | 31 | ||||
-rw-r--r-- | ace/Memory_Pool.cpp | 14 | ||||
-rw-r--r-- | ace/OS.cpp | 8 | ||||
-rw-r--r-- | ace/OS.h | 10 | ||||
-rw-r--r-- | ace/OS.i | 162 | ||||
-rw-r--r-- | ace/Process.cpp | 27 | ||||
-rw-r--r-- | ace/Signal.i | 10 | ||||
-rw-r--r-- | ace/Synch.cpp | 13 | ||||
-rw-r--r-- | ace/config-chorus.h | 12 |
10 files changed, 270 insertions, 33 deletions
diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index 806af41cf8c..7ad9d92266c 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -395,7 +395,15 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void) ACE_OS::strcat (this->context_file_, ACE_DIRECTORY_SEPARATOR_STR); ACE_OS::strcat (this->context_file_, database); +#if !defined (CHORUS) ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ()); +#else + // Use base address == 0, don't use a fixed address. + ACE_MEM_POOL_OPTIONS options (0, + 0, + 0, + ACE_CHORUS_LOCAL_NAME_SPACE_T_SIZE); +#endif /* CHORUS */ TCHAR lock_name_for_local_name_space [MAXNAMELEN + MAXPATHLEN]; TCHAR lock_name_for_backing_store [MAXPATHLEN + MAXNAMELEN]; @@ -429,10 +437,14 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void) ACE_NEW_RETURN (this->lock_, ACE_LOCK (lock_name_for_local_name_space), -1); +#if !defined (ACE_LACKS_ACCESS) // Now check if the backing store has been created successfully if (ACE_OS::access (this->context_file_, F_OK) != 0) - ACE_ERROR_RETURN ((LM_ERROR, "create_manager\n"), -1); - + ACE_ERROR_RETURN ((LM_ERROR, + "create_manager\n"), + -1); +#endif /* ACE_LACKS_ACCESS */ + void *ns_map = 0; // This is the easy case since if we find the Name Server Map diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp index e7d290d9ba0..786dd566965 100644 --- a/ace/Mem_Map.cpp +++ b/ace/Mem_Map.cpp @@ -89,16 +89,16 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle, this->length_ = len_request; } else - { - // Set length to file_request - this->length_ = file_len; - } + // Set length to file_request + this->length_ = file_len; - if (extend_backing_store) + if (extend_backing_store // Extend the backing store. - if (ACE_OS::pwrite (this->handle_, "", 1, - this->length_ > 0 ? this->length_ - 1 : 0) == -1) - return -1; + && ACE_OS::pwrite (this->handle_, + "", + 1, + this->length_ > 0 ? this->length_ - 1 : 0) == -1) + return -1; #if defined (__Lynx__) // Set flag that indicates whether PROT_WRITE has been enabled. @@ -125,9 +125,15 @@ ACE_Mem_Map::open (LPCTSTR file_name, { ACE_TRACE ("ACE_Mem_Map::open"); - ACE_OS::strncpy (this->filename_, file_name, MAXPATHLEN); + ACE_OS::strncpy (this->filename_, + file_name, + MAXPATHLEN); +#if defined (CHORUS) + this->handle_ = ACE_OS::shm_open (file_name, flags, mode, sa); +#else this->handle_ = ACE_OS::open (file_name, flags, mode, sa); +#endif /* CHORUS */ if (this->handle_ == ACE_INVALID_HANDLE) return -1; @@ -226,7 +232,12 @@ ACE_Mem_Map::remove (void) this->close (); if (this->filename_[0] != '\0') - return ACE_OS::unlink (this->filename_); +#if defined (CHORUS) + return ACE_OS::shm_unlink (this->filename_); +#else + return ACE_OS::unlink (this->filename_); +#endif /* CHORUS */ + else return 0; } diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index f4e8d655cec..4f0082d5725 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -187,6 +187,9 @@ ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, { ACE_TRACE ("ACE_MMAP_Memory_Pool::commit_backing_store_name"); +#if defined (CHORUS) + file_offset = rounded_bytes; +#else size_t seek_len; if (this->write_each_page_) @@ -208,12 +211,15 @@ ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, file_offset = ACE_OS::lseek (this->mmap_.handle () , seek_len - 1, SEEK_END); if (file_offset == -1 || ACE_OS::write (this->mmap_.handle (), "", 1) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), - this->backing_store_name_), -1); + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("(%P|%t) %p\n"), + this->backing_store_name_), + -1); } // Increment by one to put us at the beginning of the next chunk... file_offset++; +#endif /* CHORUS */ return 0; } @@ -296,7 +302,11 @@ ACE_MMAP_Memory_Pool::init_acquire (size_t nbytes, errno = 0; // Reopen file *without* using O_EXCL... if (this->mmap_.map (this->backing_store_name_, +#if defined (CHORUS) + nbytes, +#else -1, +#endif /* CHORUS */ O_RDWR, ACE_DEFAULT_FILE_PERMS, PROT_RDWR, diff --git a/ace/OS.cpp b/ace/OS.cpp index fb807f478d6..310761f3f72 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -3444,7 +3444,7 @@ ACE_OS::fork_exec (ASYS_TCHAR *argv[]) // CreateProcess failed. return -1; # elif defined (CHORUS) - return -1; // do it later!!! + return ACE_OS::execv (argv[0], argv); # else pid_t result = ACE_OS::fork (); @@ -4089,9 +4089,7 @@ ACE_OS::pwrite (ACE_HANDLE handle, # else /* ACE_WIN32 */ return ::pwrite (handle, buf, nbytes, offset); - # endif /* ACE_WIN32 */ - # else /* ACE_HAS_P_READ_WRITE */ ACE_MT (ACE_Thread_Mutex *ace_os_monitor_lock = @@ -4103,7 +4101,6 @@ ACE_OS::pwrite (ACE_HANDLE handle, off_t original_position = ACE_OS::lseek (handle, 0, SEEK_SET); - if (original_position == -1) return -1; @@ -4111,14 +4108,12 @@ ACE_OS::pwrite (ACE_HANDLE handle, off_t altered_position = ACE_OS::lseek (handle, offset, SEEK_SET); - if (altered_position == -1) return -1; ssize_t bytes_written = ACE_OS::write (handle, buf, nbytes); - if (bytes_written == -1) return -1; @@ -4128,7 +4123,6 @@ ACE_OS::pwrite (ACE_HANDLE handle, return -1; return bytes_written; - # endif /* ACE_HAD_P_READ_WRITE */ } @@ -4360,6 +4360,10 @@ public: ACE_HANDLE handle_; // Handle to the underlying file. + +#if defined (CHORUS) + ACE_mutex_t *processLock_; +#endif /* CHORUS */ }; #if defined (ACE_WIN32) @@ -5502,6 +5506,12 @@ public: // This is necessary to deal with POSIX pthreads and their use of // structures for TSS keys. +#if defined (CHORUS) + KnCap actorcaps_[ACE_CHORUS_MAX_ACTORS]; + // This is used to map an actor's id into a KnCap for killing and + // waiting actors. +#endif /* CHORUS */ + # if defined (ACE_WIN32) static int socket_initialized_; // Keeps track of whether we've already initialized WinSock... @@ -2351,12 +2351,26 @@ ACE_OS::sema_destroy (ACE_sema_t *s) } else # endif /* ! ACE_LACKS_NAMED_POSIX_SEM */ +# if defined(CHORUS) + { + if (s->name_) + { + // Only destroy the semaphore if we're the ones who + // initialized it. + ACE_OSCALL (ACE_ADAPT_RETVAL (::sem_destroy (s->sema_), result), int, -1, result); + ACE_OS::shm_unlink (s->name_); + delete s->name_; + return result; + } + } +# else { ACE_OSCALL (ACE_ADAPT_RETVAL (::sem_destroy (s->sema_), result), int, -1, result); delete s->sema_; s->sema_ = 0; return result; } +#endif /* CHORUS */ # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), ace_result_), int, -1); @@ -2417,12 +2431,71 @@ ACE_OS::sema_init (ACE_sema_t *s, } else # endif /*ACE_LACKS_NAMED_POSIX_SEM */ +# if defined(CHORUS) + { + s->name_ = 0; + if (type == USYNC_PROCESS) + { + // Let's see if it already exists. + ACE_HANDLE fd = ACE_OS::shm_open (name, + O_RDWR | O_CREAT | O_EXCL, + ACE_DEFAULT_FILE_PERMS); + if (fd == ACE_INVALID_HANDLE) + { + if (errno == EEXIST) + fd = ACE_OS::shm_open (name, + O_RDWR | O_CREAT, + ACE_DEFAULT_FILE_PERMS); + else + return -1; + } + else + { + // We own this shared memory object! Let's set its + // size. + if (ACE_OS::ftruncate (fd, + sizeof (ACE_sema_t)) == -1) + return -1; + s->name_ = ACE_OS::strnew (name); + if (s->name_ == 0) + return -1; + } + if (fd == -1) + return -1; + + s->sema_ = (sem_t *) + ACE_OS::mmap (0, + sizeof (ACE_sema_t), + PROT_RDWR, + MAP_SHARED, + fd, + 0); + ACE_OS::close (fd); + if (s->sema_ == MAP_FAILED) + return -1; + if (s->name_ + // Only initialize it if we're the one who created it + && if (::sem_init (s->sema_, USYNC_THREAD, count) != 0)) + return -1; + return 0; + } + ACE_NEW_RETURN (s->sema_, + sem_t, + -1); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sem_init (s->sema_, + type != USYNC_THREAD, + count), + ace_result_), + int, -1); + } +#else { s->name_ = 0; ACE_NEW_RETURN (s->sema_, sem_t, -1); ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sem_init (s->sema_, type != USYNC_THREAD, count), ace_result_), int, -1); } +#endif /* CHORUS */ # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) ACE_UNUSED_ARG (name); @@ -5487,9 +5560,14 @@ ACE_OS::thr_getspecific (ACE_OS_thread_key_t key, void **data) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); # elif defined (ACE_HAS_PTHREADS) # if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - return pthread_getspecific(key, data); + return pthread_getspecific (key, data); # else /* this is ACE_HAS_PTHREADS_DRAFT7 or STD */ +#if (pthread_getspecific) + // This is a macro on some platforms, e.g., CHORUS! + *data = pthread_getspecific (key); +#else *data = ::pthread_getspecific (key); +#endif /* pthread_getspecific */ # endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ return 0; # elif defined (ACE_HAS_WTHREADS) @@ -8023,6 +8101,52 @@ ACE_OS::flock_init (ACE_OS::ace_flock_t *lock, mode_t perms) { // ACE_TRACE ("ACE_OS::flock_init"); +#if defined (CHORUS) + lock->lockname_ = 0; + // Let's see if it already exists. + lock->handle_ = ACE_OS::shm_open (name, + flags | O_CREAT | O_EXCL, + perms); + if (lock->handle_ == ACE_INVALID_HANDLE) + { + if (errno == EEXIST) + lock->handle_ = ACE_OS::shm_open (name, + flags | O_CREAT, + ACE_DEFAULT_FILE_PERMS); + else + return -1; + } + else + { + // We own this shared memory object! Let's set its size. + if (ACE_OS::ftruncate (lock->handle_, + sizeof (ACE_mutex_t)) == -1) + return -1; + + ACE_ALLOCATOR_RETURN (lock->lockname_, + ACE_OS::strdup (name), + -1); + } + if (lock->handle_ == ACE_INVALID_HANDLE) + return -1; + + lock->processLock_ = + (ACE_mutex_t *) ACE_OS::mmap (0, + sizeof (ACE_mutex_t), + PROT_RDWR, + MAP_SHARED, + lock->handle_, + 0); + if (lock->processLock_ == MAP_FAILED) + return -1; + + if (lock->lockname_ + // Only initialize it if we're the one who created it. + && ACE_OS::mutex_init (lock->processLock_, USYNC_PROCESS, name, 0) != 0) + return -1; + + return lock->handle_; +#else #if defined (ACE_WIN32) // Once initialized, these values are never changed. lock->overlapped_.Internal = 0; @@ -8044,11 +8168,15 @@ ACE_OS::flock_init (ACE_OS::ace_flock_t *lock, } else return 0; +#endif /* CHORUS */ } #if defined (ACE_WIN32) ACE_INLINE void -ACE_OS::adjust_flock_params (ACE_OS::ace_flock_t *lock, short whence, off_t &start, off_t &len) +ACE_OS::adjust_flock_params (ACE_OS::ace_flock_t *lock, + short whence, + off_t &start, + off_t &len) { switch (whence) { @@ -8063,12 +8191,16 @@ ACE_OS::adjust_flock_params (ACE_OS::ace_flock_t *lock, short whence, off_t &sta } lock->overlapped_.Offset = start; if (len == 0) - len = ::GetFileSize (lock->handle_, NULL) - start; + len = ::GetFileSize (lock->handle_, + NULL) - start; } #endif /* ACE_WIN32 */ ACE_INLINE int -ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, off_t len) +ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) { // ACE_TRACE ("ACE_OS::flock_wrlock"); #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) @@ -8294,6 +8426,12 @@ ACE_OS::execv (const char *path, char *const argv[]) ACE_UNUSED_ARG (argv); ACE_NOTSUP_RETURN (-1); +#elif defined (CHORUS) + KnCap cactorcap; + int result = ::afexecv (path, &cactorcap, 0, argv); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; #elif defined (ACE_WIN32) # if defined (__BORLANDC__) // VSB return ::execv (path, argv); @@ -8317,6 +8455,12 @@ ACE_OS::execve (const char *path, char *const argv[], char *const envp[]) ACE_UNUSED_ARG (envp); ACE_NOTSUP_RETURN (-1); +#elif defined(CHORUS) + KnCap cactorcap; + int result = ::afexecve (path, &cactorcap, 0, argv, envp); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; #elif defined (ACE_WIN32) # if defined (__BORLANDC__) // VSB return ::execve (path, argv, envp); @@ -8339,6 +8483,12 @@ ACE_OS::execvp (const char *file, char *const argv[]) ACE_UNUSED_ARG (argv); ACE_NOTSUP_RETURN (-1); +#elif defined(CHORUS) + KnCap cactorcap; + int result = ::afexecvp (file, &cactorcap, 0, argv); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; #elif defined (ACE_WIN32) # if defined (__BORLANDC__) // VSB return ::execvp (file, argv); @@ -8861,12 +9011,14 @@ ACE_INLINE pid_t ACE_OS::waitpid (pid_t pid, int *stat_loc, int options) { // ACE_TRACE ("ACE_OS::waitpid"); -#if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (stat_loc); ACE_UNUSED_ARG (options); ACE_NOTSUP_RETURN (0); +#elif defined (CHORUS) + ACE_OSCALL_RETURN (::await (&ACE_OS::actorcaps_[pid]), pid_t, -1); #else ACE_OSCALL_RETURN (::waitpid (pid, stat_loc, options), pid_t, -1); diff --git a/ace/Process.cpp b/ace/Process.cpp index 82b54091e8b..226bf1755c7 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -52,6 +52,33 @@ ACE_Process::spawn (ACE_Process_Options &options) else // CreateProcess failed. return -1; +#elif defined (CHORUS) + // This only works if we exec. Chorus does not really support + // forking + if (ACE_BIT_ENABLED (options.creation_flags (), + ACE_Process_Options::NO_EXEC)) + ACE_NOTSUP_RETURN (-1); + + // These are all currently unsupported. + if (options.get_stdin () != ACE_INVALID_HANDLE) + ACE_NOTSUP_RETURN (-1); + if (options.get_stdout () != ACE_INVALID_HANDLE) + ACE_NOTSUP_RETURN (-1); + if (options.get_stderr () != ACE_INVALID_HANDLE) + ACE_NOTSUP_RETURN (-1); + if (options.working_directory () != 0) + ACE_NOTSUP_RETURN (-1); + + if (options.env_argv ()[0] == 0) + // command-line args + this->child_id_ = ACE_OS::execvp (options.command_line_argv ()[0], + options.command_line_argv ()); + else + // Command-line args and environment variables + this->child_id_ = ACE_OS::execve (options.command_line_argv ()[0], + options.command_line_argv (), + options.env_argv ()); + return this->child_id_; #else /* ACE_WIN32 */ // Fork the new process. this->child_id_ = ACE_OS::fork (options.command_line_argv ()[0]); diff --git a/ace/Signal.i b/ace/Signal.i index cd0236b5f1e..e9711a640c8 100644 --- a/ace/Signal.i +++ b/ace/Signal.i @@ -261,11 +261,17 @@ ACE_INLINE ACE_Sig_Guard::~ACE_Sig_Guard (void) { //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard"); +#if !defined (ACE_LACKS_UNIX_SIGNALS) #if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) - ACE_OS::sigprocmask (SIG_SETMASK, (sigset_t *) this->omask_, 0); + ACE_OS::sigprocmask (SIG_SETMASK, + (sigset_t *) this->omask_, + 0); #else - ACE_OS::thr_sigsetmask (SIG_SETMASK, (sigset_t *) this->omask_, 0); + ACE_OS::thr_sigsetmask (SIG_SETMASK, + (sigset_t *) this->omask_, + 0); #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ +#endif /* !ACE_LACKS_UNIX_SIGNALS */ } #if defined (ACE_HAS_WINCE) diff --git a/ace/Synch.cpp b/ace/Synch.cpp index 1fd5927c6fa..6ec5b3ebd84 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -246,7 +246,9 @@ ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h) { // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); if (ACE_OS::flock_init (&this->lock_) == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT("%p\n"), ASYS_TEXT("ACE_File_Lock::ACE_File_Lock"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT("%p\n"), + ASYS_TEXT("ACE_File_Lock::ACE_File_Lock"))); this->set_handle (h); } @@ -257,7 +259,10 @@ ACE_File_Lock::ACE_File_Lock (LPCTSTR name, // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); if (this->open (name, flags, perms) == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT("%p\n"), ASYS_TEXT("ACE_File_Lock::ACE_File_Lock"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p %s\n"), + ASYS_TEXT("ACE_File_Lock::ACE_File_Lock")), + name); } int @@ -363,7 +368,9 @@ ACE_Mutex::ACE_Mutex (int type, LPCTSTR name, void *arg) // ACE_TRACE ("ACE_Mutex::ACE_Mutex"); if (ACE_OS::mutex_init (&this->lock_, type, name, arg) != 0) - ACE_ERROR ((LM_ERROR, ASYS_TEXT("%p\n"), ASYS_TEXT("ACE_Mutex::ACE_Mutex"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Mutex::ACE_Mutex"))); } ACE_Mutex::~ACE_Mutex (void) diff --git a/ace/config-chorus.h b/ace/config-chorus.h index 2e35d6f25ba..ea2dc2facd8 100644 --- a/ace/config-chorus.h +++ b/ace/config-chorus.h @@ -48,8 +48,14 @@ #define ACE_LACKS_UNIX_SIGNALS #define ACE_HAS_IP_MULTICAST #define ACE_CHORUS_DEFAULT_MIN_STACK_SIZE 0x2000 + +// Chorus cannot grow shared memory, so this is the default size for a local name space +#define ACE_CHORUS_LOCAL_NAME_SPACE_T_SIZE 128000 + +// Used in OS.i to map an actor id into a KnCap. +#define ACE_CHORUS_MAX_ACTORS 64 + #define ACE_LACKS_MPROTECT -//#define ACE_LACKS_SOCKETPAIR #define ACE_LACKS_ACCESS #define ACE_LACKS_SBRK #define ACE_LACKS_GETHOSTENT @@ -59,7 +65,6 @@ #define ACE_LACKS_SYSV_SHMEM #define ACE_LACKS_SYSV_MSG_H #define ACE_LACKS_KEY_T -#define ACE_LACKS_EXEC #define ACE_LACKS_FORK #define ACE_LACKS_SIGSET // #define ACE_LACKS_FILELOCKS @@ -129,4 +134,7 @@ # define ACE_USE_RCSID 0 #endif /* #if !defined (ACE_USE_RCSID) */ +// Needed to wait for "processes" to exit. +#include <am/await.h> + #endif /* ACE_CONFIG_H */ |