00001
00002
00003 #include "ace/Handle_Ops.h"
00004
00005 #include "ace/OS_NS_errno.h"
00006 #include "ace/OS_NS_fcntl.h"
00007 #include "ace/Time_Value.h"
00008
00009 ACE_RCSID (ace,
00010 Handle_Ops,
00011 "$Id: Handle_Ops.cpp 78419 2007-05-20 17:53:47Z johnnyw $")
00012
00013
00014 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00015
00016 ACE_HANDLE
00017 ACE::handle_timed_open (ACE_Time_Value *timeout,
00018 const ACE_TCHAR *name,
00019 int flags,
00020 int perms,
00021 LPSECURITY_ATTRIBUTES sa)
00022 {
00023 ACE_TRACE ("ACE::handle_timed_open");
00024
00025 if (timeout != 0)
00026 {
00027 #if !defined (ACE_WIN32)
00028
00029
00030 flags |= ACE_NONBLOCK;
00031 #endif
00032
00033
00034 ACE_HANDLE const handle = ACE_OS::open (name, flags, perms, sa);
00035
00036 if (handle == ACE_INVALID_HANDLE
00037 && (errno == EWOULDBLOCK
00038 && (timeout->sec () > 0 || timeout->usec () > 0)))
00039
00040 errno = ETIMEDOUT;
00041
00042 return handle;
00043 }
00044 else
00045 return ACE_OS::open (name, flags, perms, sa);
00046 }
00047
00048 ACE_END_VERSIONED_NAMESPACE_DECL