Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52494 - in branches/release: . boost/asio boost/asio/detail
From: chris_at_[hidden]
Date: 2009-04-19 19:00:30


Author: chris_kohlhoff
Date: 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
New Revision: 52494
URL: http://svn.boost.org/trac/boost/changeset/52494

Log:
Merged revisions 52465,52478 from trunk

........
  r52465 | chris_kohlhoff | 2009-04-18 23:27:53 +1000 (Sat, 18 Apr 2009) | 3 lines
  
  POSIX allows successful system calls to modify errno, so always clear the
  error_code if the result indicates success. Fixes #2953.
........
  r52478 | chris_kohlhoff | 2009-04-19 14:15:17 +1000 (Sun, 19 Apr 2009) | 3 lines
  
  Don't include termios.h unless BOOST_ASIO_HAS_SERIAL_PORT is defined.
  Fixes #2917.
........

Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/boost/asio/detail/descriptor_ops.hpp | 45 ++++++++++++++++++----
   branches/release/boost/asio/detail/reactive_serial_port_service.hpp | 10 ++--
   branches/release/boost/asio/detail/socket_ops.hpp | 77 ++++++++++++++++++++++-----------------
   branches/release/boost/asio/serial_port_base.hpp | 22 +++++++++-
   branches/release/boost/asio/serial_port_service.hpp | 8 ---
   5 files changed, 104 insertions(+), 58 deletions(-)

Modified: branches/release/boost/asio/detail/descriptor_ops.hpp
==============================================================================
--- branches/release/boost/asio/detail/descriptor_ops.hpp (original)
+++ branches/release/boost/asio/detail/descriptor_ops.hpp 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
@@ -50,13 +50,19 @@
 inline int open(const char* path, int flags, boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::open(path, flags), ec);
+ int result = error_wrapper(::open(path, flags), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int close(int d, boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::close(d), ec);
+ int result = error_wrapper(::close(d), ec);
+ if (result == 0)
+ clear_error(ec);
+ return result;
 }
 
 inline void init_buf_iov_base(void*& base, void* addr)
@@ -88,33 +94,48 @@
     boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::readv(d, bufs, static_cast<int>(count)), ec);
+ int result = error_wrapper(::readv(d, bufs, static_cast<int>(count)), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int gather_write(int d, const buf* bufs, size_t count,
     boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::writev(d, bufs, static_cast<int>(count)), ec);
+ int result = error_wrapper(::writev(d, bufs, static_cast<int>(count)), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int ioctl(int d, long cmd, ioctl_arg_type* arg,
     boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::ioctl(d, cmd, arg), ec);
+ int result = error_wrapper(::ioctl(d, cmd, arg), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int fcntl(int d, long cmd, boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::fcntl(d, cmd), ec);
+ int result = error_wrapper(::fcntl(d, cmd), ec);
+ if (result != -1)
+ clear_error(ec);
+ return result;
 }
 
 inline int fcntl(int d, long cmd, long arg, boost::system::error_code& ec)
 {
   clear_error(ec);
- return error_wrapper(::fcntl(d, cmd, arg), ec);
+ int result = error_wrapper(::fcntl(d, cmd, arg), ec);
+ if (result != -1)
+ clear_error(ec);
+ return result;
 }
 
 inline int poll_read(int d, boost::system::error_code& ec)
@@ -125,7 +146,10 @@
   fds.events = POLLIN;
   fds.revents = 0;
   clear_error(ec);
- return error_wrapper(::poll(&fds, 1, -1), ec);
+ int result = error_wrapper(::poll(&fds, 1, -1), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int poll_write(int d, boost::system::error_code& ec)
@@ -136,7 +160,10 @@
   fds.events = POLLOUT;
   fds.revents = 0;
   clear_error(ec);
- return error_wrapper(::poll(&fds, 1, -1), ec);
+ int result = error_wrapper(::poll(&fds, 1, -1), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 } // namespace descriptor_ops

Modified: branches/release/boost/asio/detail/reactive_serial_port_service.hpp
==============================================================================
--- branches/release/boost/asio/detail/reactive_serial_port_service.hpp (original)
+++ branches/release/boost/asio/detail/reactive_serial_port_service.hpp 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
@@ -23,11 +23,10 @@
 #include <string>
 #include <boost/asio/detail/pop_options.hpp>
 
-#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+#include <boost/asio/serial_port_base.hpp>
 
-#include <boost/asio/detail/push_options.hpp>
-#include <termios.h>
-#include <boost/asio/detail/pop_options.hpp>
+#if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
+ && !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
 
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
@@ -263,7 +262,8 @@
 } // namespace asio
 } // namespace boost
 
-#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
+ // && !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
 
 #include <boost/asio/detail/pop_options.hpp>
 

Modified: branches/release/boost/asio/detail/socket_ops.hpp
==============================================================================
--- branches/release/boost/asio/detail/socket_ops.hpp (original)
+++ branches/release/boost/asio/detail/socket_ops.hpp 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
@@ -103,10 +103,7 @@
   }
 #endif
 
-#if defined(BOOST_WINDOWS)
   clear_error(ec);
-#endif
-
   return new_s;
 }
 
@@ -123,10 +120,8 @@
   clear_error(ec);
   int result = error_wrapper(call_bind(
         &msghdr::msg_namelen, s, addr, addrlen), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -135,22 +130,20 @@
   clear_error(ec);
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
   int result = error_wrapper(::closesocket(s), ec);
+#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ int result = error_wrapper(::close(s), ec);
+#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
   if (result == 0)
     clear_error(ec);
   return result;
-#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- return error_wrapper(::close(s), ec);
-#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
 inline int shutdown(socket_type s, int what, boost::system::error_code& ec)
 {
   clear_error(ec);
   int result = error_wrapper(::shutdown(s, what), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -167,10 +160,8 @@
   clear_error(ec);
   int result = error_wrapper(call_connect(
         &msghdr::msg_namelen, s, addr, addrlen), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -186,7 +177,10 @@
   return -1;
 #else
   clear_error(ec);
- return error_wrapper(::socketpair(af, type, protocol, sv), ec);
+ int result = error_wrapper(::socketpair(af, type, protocol, sv), ec);
+ if (result == 0)
+ clear_error(ec);
+ return result;
 #endif
 }
 
@@ -194,10 +188,8 @@
 {
   clear_error(ec);
   int result = error_wrapper(::listen(s, backlog), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -281,7 +273,10 @@
   msghdr msg = msghdr();
   msg.msg_iov = bufs;
   msg.msg_iovlen = count;
- return error_wrapper(::recvmsg(s, &msg, flags), ec);
+ int result = error_wrapper(::recvmsg(s, &msg, flags), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
@@ -311,6 +306,8 @@
   msg.msg_iovlen = count;
   int result = error_wrapper(::recvmsg(s, &msg, flags), ec);
   *addrlen = msg.msg_namelen;
+ if (result >= 0)
+ clear_error(ec);
   return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
@@ -337,7 +334,10 @@
 #if defined(__linux__)
   flags |= MSG_NOSIGNAL;
 #endif // defined(__linux__)
- return error_wrapper(::sendmsg(s, &msg, flags), ec);
+ int result = error_wrapper(::sendmsg(s, &msg, flags), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
@@ -366,7 +366,10 @@
 #if defined(__linux__)
   flags |= MSG_NOSIGNAL;
 #endif // defined(__linux__)
- return error_wrapper(::sendmsg(s, &msg, flags), ec);
+ int result = error_wrapper(::sendmsg(s, &msg, flags), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
@@ -409,7 +412,10 @@
 
   return s;
 #else
- return error_wrapper(::socket(af, type, protocol), ec);
+ int s = error_wrapper(::socket(af, type, protocol), ec);
+ if (s >= 0)
+ clear_error(ec);
+ return s;
 #endif
 }
 
@@ -452,10 +458,8 @@
   clear_error(ec);
   int result = error_wrapper(call_setsockopt(&msghdr::msg_namelen,
         s, level, optname, optval, optlen), ec);
-# if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-# endif
   return result;
 #endif // defined(__BORLANDC__)
 }
@@ -544,6 +548,8 @@
     *static_cast<int*>(optval) /= 2;
   }
 #endif // defined(__linux__)
+ if (result == 0)
+ clear_error(ec);
   return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
@@ -564,10 +570,8 @@
   clear_error(ec);
   int result = error_wrapper(call_getpeername(
         &msghdr::msg_namelen, s, addr, addrlen), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -587,10 +591,8 @@
   clear_error(ec);
   int result = error_wrapper(call_getsockname(
         &msghdr::msg_namelen, s, addr, addrlen), ec);
-#if defined(BOOST_WINDOWS)
   if (result == 0)
     clear_error(ec);
-#endif
   return result;
 }
 
@@ -600,12 +602,12 @@
   clear_error(ec);
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
   int result = error_wrapper(::ioctlsocket(s, cmd, arg), ec);
- if (result == 0)
- clear_error(ec);
- return result;
 #else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- return error_wrapper(::ioctl(s, cmd, arg), ec);
+ int result = error_wrapper(::ioctl(s, cmd, arg), ec);
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 }
 
 inline int select(int nfds, fd_set* readfds, fd_set* writefds,
@@ -643,10 +645,8 @@
 #else
   int result = error_wrapper(::select(nfds, readfds,
         writefds, exceptfds, timeout), ec);
-# if defined(BOOST_WINDOWS)
   if (result >= 0)
     clear_error(ec);
-# endif
   return result;
 #endif
 }
@@ -668,7 +668,10 @@
   fds.events = POLLIN;
   fds.revents = 0;
   clear_error(ec);
- return error_wrapper(::poll(&fds, 1, -1), ec);
+ int result = error_wrapper(::poll(&fds, 1, -1), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
@@ -689,7 +692,10 @@
   fds.events = POLLOUT;
   fds.revents = 0;
   clear_error(ec);
- return error_wrapper(::poll(&fds, 1, -1), ec);
+ int result = error_wrapper(::poll(&fds, 1, -1), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 
@@ -713,7 +719,10 @@
   fds.events = POLLOUT;
   fds.revents = 0;
   clear_error(ec);
- return error_wrapper(::poll(&fds, 1, -1), ec);
+ int result = error_wrapper(::poll(&fds, 1, -1), ec);
+ if (result >= 0)
+ clear_error(ec);
+ return result;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 }
 

Modified: branches/release/boost/asio/serial_port_base.hpp
==============================================================================
--- branches/release/boost/asio/serial_port_base.hpp (original)
+++ branches/release/boost/asio/serial_port_base.hpp 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
@@ -22,12 +22,25 @@
 #include <stdexcept>
 #include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
-#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
-# include <termios.h>
-#endif
 #include <boost/system/error_code.hpp>
 #include <boost/asio/detail/pop_options.hpp>
 
+#if !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
+# if defined(BOOST_ASIO_HAS_IOCP) \
+ || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+# define BOOST_ASIO_HAS_SERIAL_PORT 1
+# endif // defined(BOOST_ASIO_HAS_IOCP)
+#endif // !defined(BOOST_ASIO_DISABLE_STREAM_HANDLE)
+
+#if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
+ || defined(GENERATING_DOCUMENTATION)
+
+#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+# include <boost/asio/detail/push_options.hpp>
+# include <termios.h>
+# include <boost/asio/detail/pop_options.hpp>
+#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+
 #include <boost/asio/detail/socket_types.hpp>
 
 #if defined(GENERATING_DOCUMENTATION)
@@ -154,6 +167,9 @@
 
 #undef BOOST_ASIO_OPTION_STORAGE
 
+#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
+ // || defined(GENERATING_DOCUMENTATION)
+
 #include <boost/asio/detail/pop_options.hpp>
 
 #endif // BOOST_ASIO_SERIAL_PORT_BASE_HPP

Modified: branches/release/boost/asio/serial_port_service.hpp
==============================================================================
--- branches/release/boost/asio/serial_port_service.hpp (original)
+++ branches/release/boost/asio/serial_port_service.hpp 2009-04-19 19:00:29 EDT (Sun, 19 Apr 2009)
@@ -25,17 +25,11 @@
 
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
+#include <boost/asio/serial_port_base.hpp>
 #include <boost/asio/detail/service_base.hpp>
 #include <boost/asio/detail/reactive_serial_port_service.hpp>
 #include <boost/asio/detail/win_iocp_serial_port_service.hpp>
 
-#if !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
-# if defined(BOOST_ASIO_HAS_IOCP) \
- || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
-# define BOOST_ASIO_HAS_SERIAL_PORT 1
-# endif // defined(BOOST_ASIO_HAS_IOCP)
-#endif // !defined(BOOST_ASIO_DISABLE_STREAM_HANDLE)
-
 #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
   || defined(GENERATING_DOCUMENTATION)
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk