diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 1999-11-09 21:05:03 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 1999-11-09 21:05:03 +0000 |
commit | 9baedcaeb8d262b760657ff68b9924fe89fba7a6 (patch) | |
tree | 467737b4bb8d15a6b0f2202f2b24ba7b097c796e /m4 | |
parent | eee2d658ed7dba06918fff85cb008a9ab0d86ffa (diff) | |
download | ATCD-9baedcaeb8d262b760657ff68b9924fe89fba7a6.tar.gz |
ChangeLogTag:Tue Nov 9 14:57:51 1999 Ossama Othman <othman@cs.wustl.edu>
Diffstat (limited to 'm4')
-rw-r--r-- | m4/features.m4 | 106 |
1 files changed, 71 insertions, 35 deletions
diff --git a/m4/features.m4 b/m4/features.m4 index 3bfd7b6043c..e4dc2765157 100644 --- a/m4/features.m4 +++ b/m4/features.m4 @@ -28,6 +28,7 @@ AC_DEFUN(ACE_CHECK_ASYNCH_IO, dnl AC_REQUIRE([AC_PROG_CXX]) AC_REQUIRE([AC_PROG_CXXCPP]) AC_REQUIRE([AC_LANG_CPLUSPLUS]) + AC_REQUIRE([ACE_CHECK_THREADS]) dnl In case a library with the asynchronous libraries is found but dnl the asynchronous IO support is not functional then save a copy @@ -41,7 +42,7 @@ AC_DEFUN(ACE_CHECK_ASYNCH_IO, dnl dnl In some cases, the thread library must be linked to in addition to the dnl real-time support library. As such, make sure these checks are done dnl after the thread library checks. - ACE_SEARCH_LIBS(aio_read, aio posix4 rt, dnl + ACE_SEARCH_LIBS(aio_read, aio rt posix4, dnl ace_has_aio_funcs=yes, ace_has_aio_funcs=no) if test "$ace_has_aio_funcs" = yes; then @@ -98,7 +99,8 @@ private: }; Test_Aio::Test_Aio (void) - : aiocb_write_ (new struct aiocb), + : out_fd_ (0), + aiocb_write_ (new struct aiocb), aiocb_read_ (new struct aiocb), buffer_write_ (0), buffer_read_ (0) @@ -109,8 +111,8 @@ Test_Aio::~Test_Aio (void) { delete aiocb_write_; delete aiocb_read_; - delete buffer_write_; - delete buffer_read_; + delete [] buffer_write_; + delete [] buffer_read_; } // Init the output file and init the buffer. @@ -121,14 +123,19 @@ Test_Aio::init (void) this->out_fd_ = open ("test_aio.log", O_RDWR | O_CREAT | O_TRUNC, 0666); if (this->out_fd_ == 0) { - //cout << "Error : Opening file" << endl; + perror ("open"); return -1; } + unlink ("test_aio.log"); // Unlink now so we don't have to do so later. + + const char message[] = "Welcome to the world of AIO... AIO Rules !!!"; + // Init the buffers. - this->buffer_write_ = strdup ("Welcome to the world of AIO... AIO Rules !!!"); + this->buffer_write_ = new char [sizeof (message) + 1]; + strcpy (this->buffer_write_, message); // cout << "The buffer : " << this->buffer_write_ << endl; - this->buffer_read_ = new char [strlen (this->buffer_write_)]; + this->buffer_read_ = new char [sizeof (message) + 1]; return 0; } @@ -185,13 +192,13 @@ Test_Aio::do_aio (void) // Do suspend till all the aiocbs in the list are done. int done = 0; - int return_val = 0; while (!done) { - return_val = aio_suspend (list_aiocb, - 2, - 0); - cerr << "Return value :" << return_val << endl; + if (aio_suspend (list_aiocb, 2, 0) != 0) + { + perror ("aio_suspend"); + return -1; + } // Analyze return and error values. if (aio_error (list_aiocb [0]) != EINPROGRESS) @@ -205,12 +212,12 @@ Test_Aio::do_aio (void) { // Successful. Store the pointer somewhere and make the // entry NULL in the list. - this->aiocb_write_ = list_aiocb [0]; + // @@ no need ----> this->aiocb_write_ = list_aiocb [0]; list_aiocb [0] = 0; } } - else - //cout << "AIO in progress" << endl; +// else +// cout << "AIO in progress" << endl; if (aio_error (list_aiocb [1]) != EINPROGRESS) { @@ -223,12 +230,12 @@ Test_Aio::do_aio (void) { // Successful. Store the pointer somewhere and make the // entry NULL in the list. - this->aiocb_read_ = list_aiocb [1]; + // @@ no need ----> this->aiocb_read_ = list_aiocb [1]; list_aiocb [1] = 0; } } - else - //cout << "AIO in progress" << endl; +// else +// cout << "AIO in progress" << endl; // Is it done? if ((list_aiocb [0] == 0) && (list_aiocb [1] == 0)) @@ -266,6 +273,16 @@ main (int argc, char **argv) ], [ dnl Now try another test + + dnl Create a file for the test program to read. + cat > test_aiosig.txt <<EOF + +******************************************************* +FOO BAR FOO BAR FOO BAR FOO BAR FOO BAR FOO BAR FOO BAR +******************************************************* +EOF + + AC_TRY_RUN( [ #ifndef ACE_LACKS_UNISTD_H @@ -276,6 +293,7 @@ main (int argc, char **argv) # include <sys/types.h> #endif #include <sys/stat.h> +#include <pthread.h> #include <signal.h> #include <string.h> #include <errno.h> @@ -285,6 +303,12 @@ main (int argc, char **argv) #include <aio.h> +#ifdef __cplusplus +extern "C" +#endif +void null_handler (int /* signal_number */, + siginfo_t * /* info */, + void * /* context */); int file_handle = -1; char mb1 [BUFSIZ + 1]; @@ -306,20 +330,20 @@ setup_signal_delivery (void) // Make the sigset_t consisting of the completion signal. if (sigemptyset (&completion_signal) == -1) { - perror ("Error:Couldnt init the RT completion signal set\n"); + perror ("Error:Couldn't init the RT completion signal set\n"); return -1; } if (sigaddset (&completion_signal, SIGRTMIN) == -1) { - perror ("Error:Couldnt init the RT completion signal set\n"); + perror ("Error:Couldn't init the RT completion signal set\n"); return -1; } // Mask them. if (pthread_sigmask (SIG_BLOCK, &completion_signal, 0) == -1) { - perror ("Error:Couldnt maks the RT completion signals\n"); + perror ("Error:Couldn't make the RT completion signals\n"); return -1; } @@ -371,10 +395,10 @@ int query_aio_completions (void) { int result = 0; - size_t number_of_compleions = 0; - for (number_of_compleions = 0; - number_of_compleions < 2; - number_of_compleions ++) + size_t number_of_completions = 0; + for (number_of_completions = 0; + number_of_completions < 2; + number_of_completions++) { // Wait for <milli_seconds> amount of time. // @@ Assigning <milli_seconds> to tv_sec. @@ -459,16 +483,16 @@ query_aio_completions (void) int nbytes = aio_return (aiocb_ptr); if (nbytes == -1) { - perror ("Error:Invalid control block was send to <aio_return>\n"); + perror ("Error:Invalid control block was sent to <aio_return>\n"); return -1; } - if (number_of_compleions == 0) + //if (number_of_completions == 0) // Print the buffer. //printf ("Number of bytes transferred : %d\n The buffer : %s \n", // nbytes, // mb1); - else + //else // Print the buffer. //printf ("Number of bytes transferred : %d\n The buffer : %s \n", // nbytes, @@ -482,14 +506,16 @@ test_aio_calls (void) { // Set up the input file. // Open file (in SEQUENTIAL_SCAN mode) - file_handle = open ("test_aiosig.cpp", O_RDONLY); + file_handle = open ("test_aiosig.txt", O_RDONLY); if (file_handle == -1) { - perror ("Error:Opening the inputfile"); + perror ("open"); return -1; } - + + unlink ("test_aiosig.txt"); // Unlink now so we don't have to do so later. + if (setup_signal_delivery () < 0) return -1; @@ -498,7 +524,13 @@ test_aio_calls (void) if (query_aio_completions () < 0) return -1; - + + if (close (file_handle) != 0) + { + perror ("close"); + return -1; + } + return 0; } @@ -519,7 +551,7 @@ setup_signal_handler (int signal_number) 0); if (sigaction_return == -1) { - perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL"); + perror ("Error:Proactor couldn't do sigaction for the RT SIGNAL"); return -1; } @@ -537,12 +569,17 @@ int main (int, char *[]) { if (test_aio_calls () == 0) + { //printf ("RT SIG test successful:\n" // "ACE_POSIX_SIG_PROACTOR should work in this platform\n"); + return 0; + } else + { //printf ("RT SIG test failed:\n" // "ACE_POSIX_SIG_PROACTOR may not work in this platform\n"); - return 0; + return -1; + } } ], [ @@ -582,6 +619,5 @@ main (int, char *[]) ]) ]) ], AC_DEFINE(ACE_HAS_AIO_CALLS), LIBS="$ace_save_LIBS") - rm -f test_aio.log fi dnl test "$ace_has_aio_funcs" = yes ]) |