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 "Handle_Ops.cpp,v 1.9 2005/10/28 16:14:52 ossama Exp")
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 handle = ACE_OS::open (name,
00035 flags,
00036 perms,
00037 sa);
00038 if (handle == ACE_INVALID_HANDLE
00039 && (errno == EWOULDBLOCK
00040 && (timeout->sec () > 0 || timeout->usec () > 0)))
00041
00042 errno = ETIMEDOUT;
00043
00044 return handle;
00045 }
00046 else
00047 return ACE_OS::open (name, flags, perms, sa);
00048 }
00049
00050 ACE_END_VERSIONED_NAMESPACE_DECL