summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-02-25 23:51:06 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-02-25 23:51:06 +0000
commit9779acb5be7882bb2a4358dbb2b706b0ea77b51c (patch)
tree697cf1c0db5c69e308a1320bd143b7b4ee77d086
parentfba4ccf4f3c9ebd9c3cdab3607aef0fcbbb05b42 (diff)
downloadATCD-9779acb5be7882bb2a4358dbb2b706b0ea77b51c.tar.gz
foo
-rw-r--r--ChangeLog-97a19
-rw-r--r--README1
-rw-r--r--ace/ACE.cpp113
-rw-r--r--ace/ACE.h4
-rw-r--r--ace/Log_Msg.cpp26
-rw-r--r--examples/Connection/non_blocking/CPP-acceptor.cpp3
6 files changed, 150 insertions, 16 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a
index 38bc6c2f581..9e55055eaaa 100644
--- a/ChangeLog-97a
+++ b/ChangeLog-97a
@@ -1,3 +1,22 @@
+Tue Feb 25 17:40:57 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
+
+ * ace/Log_Msg.cpp: Updated the 'p' option of the log() method to
+ use the new ACE::sock_error() method for cases where
+ FormatMessage() fails.
+
+ * ace/ACE: Added a new sock_error() method to class ACE which
+ returns the appropriate message for each WinSock error code.
+ This makes up for an apparent oversight in Win32. Thanks to
+ Michael R. MacFaden" <mrm@cisco.com> for this.
+
+Tue Feb 25 01:33:06 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * ace/OS.h: Moved <netinet/tcp.h> outside of the VXWORKS #ifdef
+ since it seems to be available on other platforms (e.g.,
+ Solaris). If people find this not to be the case on all
+ platforms please let me know and I'll #ifdef it. Thanks to
+ Sumedh Mungee <sumedh@cs.wustl.edu> for reporting this.
+
Tue Feb 25 16:20:29 1997 Irfan Pyarali <irfan@flamenco.cs.wustl.edu>
* examples/Connection/non_blocking/CPP-acceptor.cpp: Added a
diff --git a/README b/README
index 7818ee66025..65f24d77806 100644
--- a/README
+++ b/README
@@ -478,6 +478,7 @@ Dave Mayerhoefer <m210229@svappl36.mdc.com>
Bert Craytor <Bert_Craytor@peoplesoft.com>
Joey Zhu <joey.zhu@wcom.com>
Arthur J. Lewis" <hfdh99a@prodigy.com>
+Michael R. MacFaden" <mrm@cisco.com>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson and is now at ObjectSpace. Paul devised the recursive
diff --git a/ace/ACE.cpp b/ace/ACE.cpp
index e329a233e72..63e060a48b1 100644
--- a/ace/ACE.cpp
+++ b/ace/ACE.cpp
@@ -1228,17 +1228,116 @@ ACE::is_prime (const u_long n,
if (n > 3)
{
for (u_long factor = min_factor; factor <= max_factor; ++factor)
- {
- if (n / factor * factor == n)
- {
- return factor;
- }
- }
+ if (n / factor * factor == n)
+ return factor;
return 0;
}
else
+ return 0;
+}
+
+const char *
+ACE::sock_error (int error)
+{
+#if defined (ACE_WIN32)
+ switch (error)
{
- return 0;
+ case WSAVERNOTSUPPORTED:
+ return "version of WinSock not supported";
+ /* NOTREACHED */
+ case WSASYSNOTREADY:
+ return "WinSock not present or not responding";
+ /* NOTREACHED */
+ case WSAEINVAL:
+ return "app version not supported by DLL";
+ /* NOTREACHED */
+ case WSAHOST_NOT_FOUND:
+ return "Authoritive: Host not found";
+ /* NOTREACHED */
+ case WSATRY_AGAIN:
+ return "Non-authoritive: host not found or server failure";
+ /* NOTREACHED */
+ case WSANO_RECOVERY:
+ return "Non-recoverable: refused or not implemented";
+ /* NOTREACHED */
+ case WSANO_DATA:
+ return "Valid name, no data record for type";
+ /* NOTREACHED */
+ /*
+ case WSANO_ADDRESS:
+ return "Valid name, no MX record";
+ /* NOTREACHED */
+ */
+ case WSANOTINITIALISED:
+ return "WSA Startup not initialized";
+ /* NOTREACHED */
+ case WSAENETDOWN:
+ return "Network subsystem failed";
+ /* NOTREACHED */
+ case WSAEINPROGRESS:
+ return "Blocking operation in progress";
+ /* NOTREACHED */
+ case WSAEINTR:
+ return "Blocking call cancelled";
+ /* NOTREACHED */
+ case WSAEAFNOSUPPORT:
+ return "address family not supported";
+ /* NOTREACHED */
+ case WSAEMFILE:
+ return "no file descriptors available";
+ /* NOTREACHED */
+ case WSAENOBUFS:
+ return "no buffer space available";
+ /* NOTREACHED */
+ case WSAEPROTONOSUPPORT:
+ return "specified protocol not supported";
+ /* NOTREACHED */
+ case WSAEPROTOTYPE:
+ return "protocol wrong type for this socket";
+ /* NOTREACHED */
+ case WSAESOCKTNOSUPPORT:
+ return "socket type not supported for address family";
+ /* NOTREACHED */
+ case WSAENOTSOCK:
+ return "descriptor is not a socket";
+ /* NOTREACHED */
+ case WSAEWOULDBLOCK:
+ return "socket marked as non-blocking and SO_LINGER set not 0";
+ /* NOTREACHED */
+ case WSAEADDRINUSE:
+ return "address already in use";
+ /* NOTREACHED */
+ case WSAECONNABORTED:
+ return "connection aborted";
+ /* NOTREACHED */
+ case WSAECONNRESET:
+ return "connection reset";
+ /* NOTREACHED */
+ case WSAENOTCONN:
+ return "not connected";
+ /* NOTREACHED */
+ case WSAETIMEDOUT:
+ return "connection timed out";
+ /* NOTREACHED */
+ case WSAECONNREFUSED:
+ return "connection refused";
+ /* NOTREACHED */
+ case WSAEHOSTDOWN:
+ return "host down";
+ /* NOTREACHED */
+ case WSAEHOSTUNREACH:
+ return "host unreachable";
+ /* NOTREACHED */
+ case WSAEADDRNOTAVAIL:
+ return "address not available";
+ /* NOTREACHED */
+ default:
+ return "unknown error";
+ /* NOTREACHED */
}
+#else
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_WIN32 */
}
+
diff --git a/ace/ACE.h b/ace/ACE.h
index 85787e9ad73..f51cd50a155 100644
--- a/ace/ACE.h
+++ b/ace/ACE.h
@@ -345,6 +345,10 @@ public:
// Map troublesome win32 errno values to values that standard C
// strerr function understands. Thank you Microsoft.
+ static const char *sock_error (int error);
+ // Returns a string containing the error message corresponding to a
+ // WinSock error. This works around an omission in the Win32 API...
+
private:
ACE (void);
// Ensure we can't define an instance of this class...
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp
index 490da4f68e6..eedc00a3fe9 100644
--- a/ace/Log_Msg.cpp
+++ b/ace/Log_Msg.cpp
@@ -511,7 +511,7 @@ ACE_Log_Msg::log (const char *format_str,
else
{
#if defined (ACE_WIN32)
- LPVOID lpMsgBuf;
+ LPTSTR lpMsgBuf;
::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
@@ -521,11 +521,25 @@ ACE_Log_Msg::log (const char *format_str,
0,
NULL);
- ACE_OS::sprintf (bp, "%s: %s",
- va_arg (argp, char *), lpMsgBuf);
-
- // Free the buffer.
- LocalFree (lpMsgBuf);
+ // If we don't get a valid response from
+ // <FormatMessage>, we'll assume this is a
+ // WinSock error and so we'll try to convert
+ // it into a string. If this doesn't work it
+ // returns "unknown error" which is fine for
+ // our purposes.
+ if (lpMsgBuf == 0)
+ {
+ lpMsgBuf = ACE::sock_error (errno);
+ ACE_OS::sprintf (bp, "%s: %s",
+ va_arg (argp, char *), lpMsgBuf);
+ }
+ else
+ {
+ ACE_OS::sprintf (bp, "%s: %s",
+ va_arg (argp, char *), lpMsgBuf);
+ // Free the buffer.
+ ::LocalFree (lpMsgBuf);
+ }
#else
ACE_OS::sprintf (bp, "%s: <unknown error> = %d",
va_arg (argp, char *), errno);
diff --git a/examples/Connection/non_blocking/CPP-acceptor.cpp b/examples/Connection/non_blocking/CPP-acceptor.cpp
index 0703bf516f2..a6494e73804 100644
--- a/examples/Connection/non_blocking/CPP-acceptor.cpp
+++ b/examples/Connection/non_blocking/CPP-acceptor.cpp
@@ -152,9 +152,6 @@ IPC_Server<SH, PR_AC_2>::svc (void)
{
if (errno == EWOULDBLOCK && this->reactor ())
this->reactor ()->handle_events ();
- else if (errno == ETIMEDOUT)
- ACE_ERROR ((LM_ERROR, "accept timed out on handle %d\n",
- this->acceptor ().get_handle ()));
else
ACE_ERROR ((LM_ERROR, "%p on handle %d\n",
"accept", this->acceptor ().get_handle ()));