Skip to content

Commit 159dcc4

Browse files
committed
Merge branch 'fix/SDK-4220_Adapt-maxds-int64_t' into 'release/v7.7.0'
SDK-4220. Adapt maxds usage to its type int64_t (release/v7.7.0) See merge request sdk/sdk!5735
2 parents 55aec69 + 85b7560 commit 159dcc4

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

examples/megacli.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9828,7 +9828,7 @@ dstime DemoApp::pread_failure(const Error &e, int retry, void* /*appdata*/, dsti
98289828
delete pread_file;
98299829
pread_file = NULL;
98309830
}
9831-
return ~(dstime)0;
9831+
return NEVER;
98329832
}
98339833
}
98349834

include/mega/megaapp.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ struct MEGA_API MegaApp
222222
virtual void openfilelink_result(handle, const byte*, m_off_t, string*, string*, int) { }
223223

224224
// pread result
225-
virtual dstime pread_failure(const Error&, int, void*, dstime) { return ~(dstime)0; }
225+
virtual dstime pread_failure(const Error&, int, void*, dstime)
226+
{
227+
return NEVER;
228+
}
226229
virtual bool pread_data(byte*, m_off_t, m_off_t, m_off_t, m_off_t, void*) { return false; }
227230

228231
// event reporting result

src/posix/waiter.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ bool PosixWaiter::fd_filter(int nfds, mega_fd_set_t* fds, mega_fd_set_t* ignoref
8585
}
8686

8787
// wait for supplied events (sockets, filesystem changes), plus timeout + application events
88-
// maxds specifies the maximum amount of time to wait in deciseconds (or ~0 if no timeout scheduled)
89-
// returns application-specific bitmask. bit 0 set indicates that exec() needs to be called.
88+
// maxds specifies the maximum amount of time to wait in deciseconds (or
89+
// NEVER if no timeout scheduled) returns application-specific bitmask.
90+
// bit 0 set indicates that exec() needs to be called.
9091
int PosixWaiter::wait()
9192
{
9293
int numfd = 0;
@@ -97,7 +98,7 @@ int PosixWaiter::wait()
9798

9899
bumpmaxfd(m_pipe[0]);
99100

100-
if (maxds + 1)
101+
if (EVER(maxds))
101102
{
102103
dstime us = 1000000 / 10 * maxds;
103104

@@ -108,8 +109,7 @@ int PosixWaiter::wait()
108109
#ifdef USE_POLL
109110
// wait infinite (-1) if maxds is max dstime OR it would overflow platform's int
110111
int timeoutInMs = -1;
111-
if (maxds != std::numeric_limits<dstime>::max() &&
112-
maxds <= std::numeric_limits<int>::max() / 100)
112+
if (EVER(maxds) && maxds <= std::numeric_limits<int>::max() / 100)
113113
{
114114
timeoutInMs = static_cast<int>(maxds) * 100;
115115
}
@@ -139,7 +139,7 @@ int PosixWaiter::wait()
139139
}
140140
numfd = poll(fds, total, timeoutInMs);
141141
#else
142-
numfd = select(maxfd + 1, &rfds, &wfds, &efds, maxds + 1 ? &tv : NULL);
142+
numfd = select(maxfd + 1, &rfds, &wfds, &efds, EVER(maxds) ? &tv : NULL);
143143
#endif
144144

145145
// empty pipe

src/win32/consolewaiter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ WinConsoleWaiter::WinConsoleWaiter(WinConsole* con)
4141
}
4242

4343
// wait for events (socket, I/O completion, timeout + application events)
44-
// ds specifies the maximum amount of time to wait in deciseconds (or ~0 if no
45-
// timeout scheduled)
44+
// ds specifies the maximum amount of time to wait in deciseconds (or
45+
// NEVER if no timeout scheduled)
4646
int WinConsoleWaiter::wait()
4747
{
4848
int r;

src/win32/waiter.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ WinWaiter::~WinWaiter()
3535
}
3636

3737
// wait for events (socket, I/O completion, timeout + application events)
38-
// ds specifies the maximum amount of time to wait in deciseconds (or ~0 if no
39-
// timeout scheduled)
40-
// (this assumes that the second call to addhandle() was coming from the
41-
// network layer)
38+
// ds specifies the maximum amount of time to wait in deciseconds (or
39+
// NEVER if no timeout scheduled) (this assumes that the second call to
40+
// addhandle() was coming from the network layer)
4241
int WinWaiter::wait()
4342
{
4443
int r = 0;
@@ -47,11 +46,14 @@ int WinWaiter::wait()
4746
if (index <= MAXIMUM_WAIT_OBJECTS)
4847
{
4948
assert(!handles.empty());
50-
DWORD dwWaitResult = WaitForMultipleObjectsEx(static_cast<DWORD>(index),
51-
&handles.front(),
52-
FALSE,
53-
static_cast<DWORD>(maxds * 100),
54-
TRUE);
49+
DWORD dwWaitResult = WaitForMultipleObjectsEx(
50+
static_cast<DWORD>(index),
51+
&handles.front(),
52+
FALSE,
53+
(maxds > static_cast<dstime>(std::numeric_limits<DWORD>::max() / 100)) ?
54+
std::numeric_limits<DWORD>::max() :
55+
static_cast<DWORD>(maxds * 100),
56+
TRUE);
5557

5658
assert(dwWaitResult != WAIT_FAILED);
5759

0 commit comments

Comments
 (0)