summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>1999-06-26 21:06:18 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>1999-06-26 21:06:18 +0000
commit21d500e5d05cc21ac75a78747d1d315ef0a3394c (patch)
tree1ce2072e95555578976819f3172c886547ad665e /m4
parentea66eaba7b71ee030d71b9aeb11f3442ec1d2ce5 (diff)
downloadATCD-21d500e5d05cc21ac75a78747d1d315ef0a3394c.tar.gz
Updated asynchronous IO tests.
Diffstat (limited to 'm4')
-rw-r--r--m4/features.m4189
1 files changed, 113 insertions, 76 deletions
diff --git a/m4/features.m4 b/m4/features.m4
index 7e81c3b25e1..89534fb2318 100644
--- a/m4/features.m4
+++ b/m4/features.m4
@@ -62,6 +62,7 @@ if test "$ace_has_aio_funcs" = yes; then
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <iostream.h>
#include <aio.h>
@@ -117,15 +118,19 @@ int
Test_Aio::init (void)
{
// Open the output file.
- this->out_fd_ = open ("conftest.log", O_RDWR | O_CREAT | O_TRUNC, 0666);
+ this->out_fd_ = open ("test_aio.log", O_RDWR | O_CREAT | O_TRUNC, 0666);
if (this->out_fd_ == 0)
{
+ //cout << "Error : Opening file" << endl;
return -1;
}
// Init the buffers.
this->buffer_write_ = strdup ("Welcome to the world of AIO... AIO Rules !!!");
+ // cout << "The buffer : " << this->buffer_write_ << endl;
this->buffer_read_ = new char [strlen (this->buffer_write_)];
+
+ return 0;
}
// Set the necessary things for the AIO stuff.
@@ -186,6 +191,7 @@ Test_Aio::do_aio (void)
return_val = aio_suspend (list_aiocb,
2,
0);
+ cerr << "Return value :" << return_val << endl;
// Analyze return and error values.
if (aio_error (list_aiocb [0]) != EINPROGRESS)
@@ -203,6 +209,8 @@ Test_Aio::do_aio (void)
list_aiocb [0] = 0;
}
}
+ else
+ //cout << "AIO in progress" << endl;
if (aio_error (list_aiocb [1]) != EINPROGRESS)
{
@@ -219,30 +227,40 @@ Test_Aio::do_aio (void)
list_aiocb [1] = 0;
}
}
+ else
+ //cout << "AIO in progress" << endl;
// Is it done?
if ((list_aiocb [0] == 0) && (list_aiocb [1] == 0))
done = 1;
}
+
+ //cout << "Both the AIO operations done." << endl;
+ //cout << "The buffer is :" << this->buffer_read_ << endl;
return 0;
}
int
-main (int argc, char *argv[])
+main (int argc, char **argv)
{
Test_Aio test_aio;
if (test_aio.init () != 0)
{
+ //printf ("AIOCB test failed:\n"
+ // "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n");
return -1;
}
if (test_aio.do_aio () != 0)
{
+ //printf ("AIOCB test failed:\n"
+ // "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n");
return -1;
}
-
+ //printf ("AIOCB test successful:\n"
+ // "ACE_POSIX_AIOCB_PROACTOR should work in this platform\n");
return 0;
}
],
@@ -267,22 +285,25 @@ main (int argc, char *argv[])
#include <aio.h>
+
int file_handle = -1;
char mb1 [BUFSIZ + 1];
char mb2 [BUFSIZ + 1];
aiocb aiocb1, aiocb2;
sigset_t completion_signal;
-/* Function prototypes. */
+// Function prototypes.
int setup_signal_delivery (void);
int issue_aio_calls (void);
int query_aio_completions (void);
int test_aio_calls (void);
+int setup_signal_handler (void);
+int setup_signal_handler (int signal_number);
int
setup_signal_delivery (void)
{
- /* Make the sigset_t consisting of the completion signal. */
+ // Make the sigset_t consisting of the completion signal.
if (sigemptyset (&completion_signal) == -1)
{
perror ("Error:Couldnt init the RT completion signal set\n");
@@ -295,38 +316,20 @@ setup_signal_delivery (void)
return -1;
}
- /* Mask them. */
- if (sigprocmask (SIG_BLOCK, &completion_signal, 0) == -1)
+ // Mask them.
+ if (pthread_sigmask (SIG_BLOCK, &completion_signal, 0) == -1)
{
perror ("Error:Couldnt maks the RT completion signals\n");
return -1;
}
- /* Setting up the handler(!) for these signals. */
- struct sigaction reaction;
- sigemptyset (&reaction.sa_mask); /* Nothing else to mask. */
- reaction.sa_flags = SA_SIGINFO; /* Realtime flag. */
-#if defined (SA_SIGACTION)
- /* Lynx says, it is better to set this bit to be portable. */
- reaction.sa_flags &= SA_SIGACTION;
-#endif /* SA_SIGACTION */
- reaction.sa_sigaction = 0; /* No handler. */
- int sigaction_return = sigaction (SIGRTMIN,
- &reaction,
- 0);
- if (sigaction_return == -1)
- {
- perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL");
- return -1;
- }
-
- return 0;
+ return setup_signal_handler (SIGRTMIN);
}
int
issue_aio_calls (void)
{
- /* Setup AIOCB. */
+ // Setup AIOCB.
aiocb1.aio_fildes = file_handle;
aiocb1.aio_offset = 0;
aiocb1.aio_buf = mb1;
@@ -336,15 +339,15 @@ issue_aio_calls (void)
aiocb1.aio_sigevent.sigev_signo = SIGRTMIN;
aiocb1.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb1;
- /* Fire off the aio write. */
+ // Fire off the aio write.
if (aio_read (&aiocb1) == -1)
{
- /* Queueing failed. */
+ // Queueing failed.
perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n");
return -1;
}
- /* Setup AIOCB. */
+ // Setup AIOCB.
aiocb2.aio_fildes = file_handle;
aiocb2.aio_offset = BUFSIZ + 1;
aiocb2.aio_buf = mb2;
@@ -354,10 +357,10 @@ issue_aio_calls (void)
aiocb2.aio_sigevent.sigev_signo = SIGRTMIN;
aiocb2.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb2;
- /* Fire off the aio write. */
+ // Fire off the aio write.
if (aio_read (&aiocb2) == -1)
{
- /* Queueing failed. */
+ // Queueing failed.
perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n");
return -1;
}
@@ -373,69 +376,69 @@ query_aio_completions (void)
number_of_compleions < 2;
number_of_compleions ++)
{
- /* Wait for <milli_seconds> amount of time. */
- /* @@ Assigning <milli_seconds> to tv_sec. */
+ // Wait for <milli_seconds> amount of time.
+ // @@ Assigning <milli_seconds> to tv_sec.
timespec timeout;
timeout.tv_sec = INT_MAX;
timeout.tv_nsec = 0;
- /* To get back the signal info. */
+ // To get back the signal info.
siginfo_t sig_info;
- /* Await the RT completion signal. */
+ // Await the RT completion signal.
int sig_return = sigtimedwait (&completion_signal,
&sig_info,
&timeout);
- /* Error case. */
- /* If failure is coz of timeout, then return *0* but set */
- /* errno appropriately. This is what the WinNT proactor */
- /* does. */
+ // Error case.
+ // If failure is coz of timeout, then return *0* but set
+ // errno appropriately. This is what the WinNT proactor
+ // does.
if (sig_return == -1)
{
perror ("Error:Error waiting for RT completion signals\n");
return -1;
}
- /* RT completion signals returned. */
+ // RT completion signals returned.
if (sig_return != SIGRTMIN)
{
- printf ("Unexpected signal (%d) has been received while waiting for RT Completion Signals\n",
- sig_return);
+ //printf ("Unexpected signal (%d) has been received while waiting for RT Completion Signals\n",
+ // sig_return);
return -1;
}
- /* @@ Debugging. */
- printf ("Sig number found in the sig_info block : %d\n",
- sig_info.si_signo);
+ // @@ Debugging.
+ //printf ("Sig number found in the sig_info block : %d\n",
+ // sig_info.si_signo);
- /* Is the signo returned consistent? */
+ // Is the signo returned consistent?
if (sig_info.si_signo != sig_return)
{
- printf ("Inconsistent signal number (%d) in the signal info block\n",
- sig_info.si_signo);
+ //printf ("Inconsistent signal number (%d) in the signal info block\n",
+ // sig_info.si_signo);
return -1;
}
- /* @@ Debugging. */
- printf ("Signal code for this signal delivery : %d\n",
- sig_info.si_code);
+ // @@ Debugging.
+ //printf ("Signal code for this signal delivery : %d\n",
+ // sig_info.si_code);
- /* Is the signal code an aio completion one? */
+ // Is the signal code an aio completion one?
if ((sig_info.si_code != SI_ASYNCIO) &&
(sig_info.si_code != SI_QUEUE))
{
- printf ("Unexpected signal code (%d) returned on completion querying\n",
- sig_info.si_code);
+ //printf ("Unexpected signal code (%d) returned on completion querying\n",
+ // sig_info.si_code);
return -1;
}
- /* Retrive the aiocb. */
+ // Retrive the aiocb.
aiocb* aiocb_ptr = (aiocb *) sig_info.si_value.sival_ptr;
- /* Analyze error and return values. Return values are */
- /* actually <errno>'s associated with the <aio_> call */
- /* corresponding to aiocb_ptr. */
+ // Analyze error and return values. Return values are
+ // actually <errno>'s associated with the <aio_> call
+ // corresponding to aiocb_ptr.
int error_code = aio_error (aiocb_ptr);
if (error_code == -1)
{
@@ -445,14 +448,14 @@ query_aio_completions (void)
if (error_code != 0)
{
- /* Error occurred in the <aio_>call. Return the errno */
- /* corresponding to that <aio_> call. */
- printf ("Error:An AIO call has failed:Error code = %d\n",
- error_code);
+ // Error occurred in the <aio_>call. Return the errno
+ // corresponding to that <aio_> call.
+ //printf ("Error:An AIO call has failed:Error code = %d\n",
+ // error_code);
return -1;
}
- /* No error occured in the AIO operation. */
+ // No error occured in the AIO operation.
int nbytes = aio_return (aiocb_ptr);
if (nbytes == -1)
{
@@ -461,15 +464,15 @@ query_aio_completions (void)
}
if (number_of_compleions == 0)
- /* Print the buffer. */
- printf ("Number of bytes transferred : %d\n The buffer : %s \n",
- nbytes,
- mb1);
+ // Print the buffer.
+ //printf ("Number of bytes transferred : %d\n The buffer : %s \n",
+ // nbytes,
+ // mb1);
else
- /* Print the buffer. */
- printf ("Number of bytes transferred : %d\n The buffer : %s \n",
- nbytes,
- mb2);
+ // Print the buffer.
+ //printf ("Number of bytes transferred : %d\n The buffer : %s \n",
+ // nbytes,
+ // mb2);
}
return 0;
}
@@ -477,8 +480,8 @@ query_aio_completions (void)
int
test_aio_calls (void)
{
- /* Set up the input file. */
- /* Open file (in SEQUENTIAL_SCAN mode) */
+ // Set up the input file.
+ // Open file (in SEQUENTIAL_SCAN mode)
file_handle = open ("test_aiosig.cpp", O_RDONLY);
if (file_handle == -1)
@@ -500,11 +503,45 @@ test_aio_calls (void)
}
int
+setup_signal_handler (int signal_number)
+{
+ // Setting up the handler(!) for these signals.
+ struct sigaction reaction;
+ sigemptyset (&reaction.sa_mask); // Nothing else to mask.
+ reaction.sa_flags = SA_SIGINFO; // Realtime flag.
+#if defined (SA_SIGACTION)
+ // Lynx says, it is better to set this bit to be portable.
+ reaction.sa_flags &= SA_SIGACTION;
+#endif /* SA_SIGACTION */
+ reaction.sa_sigaction = null_handler; // Null handler.
+ int sigaction_return = sigaction (SIGRTMIN,
+ &reaction,
+ 0);
+ if (sigaction_return == -1)
+ {
+ perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL");
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+null_handler (int /* signal_number */,
+ siginfo_t * /* info */,
+ void * /* context */)
+{
+}
+
+int
main (int, char *[])
{
- if (test_aio_calls () != 0)
- return -1;
+ if (test_aio_calls () == 0)
+ //printf ("RT SIG test successful:\n"
+ // "ACE_POSIX_SIG_PROACTOR should work in this platform\n");
else
+ //printf ("RT SIG test failed:\n"
+ // "ACE_POSIX_SIG_PROACTOR may not work in this platform\n");
return 0;
}
],