MCPcopy Create free account
hub / github.com/defold/defold / RecvTimeout

Function RecvTimeout

engine/dlib/src/dlib/sslsocket_mbedtls.cpp:112–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112static int RecvTimeout(void* _ctx, unsigned char* buf, size_t len, uint32_t timeout)
113{
114 CustomNetContext* ctx = (CustomNetContext*)_ctx;
115 int fd = ctx->m_Context.fd;
116
117 if (fd < 0)
118 return MBEDTLS_ERR_NET_INVALID_CONTEXT;
119
120 if (timeout == 0 && ctx->m_Timeout != 0)
121 {
122 timeout = ctx->m_Timeout / 1000;
123 }
124
125 dmFileDescriptor::Poller poller;
126 dmFileDescriptor::PollerSetEvent(&poller, dmFileDescriptor::EVENT_READ, fd);
127 int ret = dmFileDescriptor::Wait(&poller, timeout == 0 ? -1 : timeout);
128
129 if (ret == 0)
130 return MBEDTLS_ERR_SSL_TIMEOUT;
131
132 if (ret < 0)
133 {
134#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && !defined(EFI32)
135 if (WSAGetLastError() == WSAEINTR)
136 return MBEDTLS_ERR_SSL_WANT_READ;
137#else
138 if (errno == EINTR)
139 return MBEDTLS_ERR_SSL_WANT_READ;
140#endif
141 return MBEDTLS_ERR_NET_RECV_FAILED;
142 }
143
144 return mbedtls_net_recv(ctx, buf, len);
145}
146
147namespace
148{

Callers

nothing calls this directly

Calls 3

PollerSetEventFunction · 0.85
mbedtls_net_recvFunction · 0.85
WaitFunction · 0.70

Tested by

no test coverage detected