Skip to content

Commit

Permalink
Merge pull request #1732 from jimklimov/file-stable-timeout
Browse files Browse the repository at this point in the history
Problem: File stable timeout tests still fail
  • Loading branch information
sappo committed Aug 3, 2017
2 parents 01fe4e4 + c14fd5e commit 8551a11
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api/zsys.api
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
that should elapse until we consider that object "stable" at the
current zclock_time() moment.
The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
which generally depends on host OS, with fallback value of 3000.
which generally depends on host OS, with fallback value of 5000.
<argument name = "file stable age msec" type = "msecs" />
</method>

Expand Down
2 changes: 1 addition & 1 deletion bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public int maxMsgsz () {
that should elapse until we consider that object "stable" at the
current zclock_time() moment.
The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
which generally depends on host OS, with fallback value of 3000.
which generally depends on host OS, with fallback value of 5000.
*/
native static void __setFileStableAgeMsec (long fileStableAgeMsec);
public void setFileStableAgeMsec (long fileStableAgeMsec) {
Expand Down
2 changes: 1 addition & 1 deletion bindings/lua_ffi/czmq_ffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ int
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,7 @@ Configure the threshold value of filesystem object age per st_mtime
that should elapse until we consider that object "stable" at the
current zclock_time() moment.
The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
which generally depends on host OS, with fallback value of 3000.
which generally depends on host OS, with fallback value of 5000.

```
msecs my_zsys.fileStableAgeMsec ()
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/czmq/_czmq_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7624,7 +7624,7 @@ def set_file_stable_age_msec(file_stable_age_msec):
that should elapse until we consider that object "stable" at the
current zclock_time() moment.
The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
which generally depends on host OS, with fallback value of 3000.
which generally depends on host OS, with fallback value of 5000.
"""
return lib.zsys_set_file_stable_age_msec(file_stable_age_msec)

Expand Down
8 changes: 4 additions & 4 deletions bindings/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_zdir(self):
initfile.close()

try:
stable_age = float(file_stable_age_msec()) / 1000.0
stable_age = float(file_stable_age_msec()) / 1000.0 + 0.050
except Exception:
stable_age = 3.001
stable_age = 5.050
time.sleep(stable_age) # wait for initial file to become 'stable'

watch.sock().send(b"si", b"TIMEOUT", 100)
Expand Down Expand Up @@ -190,9 +190,9 @@ def test_zfile(self):
del f

try:
stable_age = float(file_stable_age_msec()) / 1000.0
stable_age = float(file_stable_age_msec()) / 1000.0 + 0.050
except Exception:
stable_age = 3.001
stable_age = 5.050

self.assertTrue(file.has_changed())
self.assertFalse(file.is_stable())
Expand Down
2 changes: 1 addition & 1 deletion bindings/python_cffi/czmq_cffi/_cdefs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3727,7 +3727,7 @@ int
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);

Expand Down
2 changes: 1 addition & 1 deletion bindings/python_cffi/czmq_cffi/cdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,7 @@
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);
Expand Down
2 changes: 1 addition & 1 deletion bindings/qml/src/QmlZsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ int QmlZsysAttached::maxMsgsz () {
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void QmlZsysAttached::setFileStableAgeMsec (int64_t fileStableAgeMsec) {
zsys_set_file_stable_age_msec (fileStableAgeMsec);
};
Expand Down
2 changes: 1 addition & 1 deletion bindings/qml/src/QmlZsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public slots:
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void setFileStableAgeMsec (int64_t fileStableAgeMsec);

// Return current threshold value of file stable age in msec.
Expand Down
2 changes: 1 addition & 1 deletion bindings/qt/src/qzsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ int QZsys::maxMsgsz ()
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
void QZsys::setFileStableAgeMsec (int64_t fileStableAgeMsec)
{
zsys_set_file_stable_age_msec (fileStableAgeMsec);
Expand Down
2 changes: 1 addition & 1 deletion bindings/qt/src/qzsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class QT_CZMQ_EXPORT QZsys : public QObject
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
static void setFileStableAgeMsec (int64_t fileStableAgeMsec);

// Return current threshold value of file stable age in msec.
Expand Down
2 changes: 1 addition & 1 deletion bindings/ruby/lib/czmq/ffi/zsys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def self.max_msgsz()
# that should elapse until we consider that object "stable" at the
# current zclock_time() moment.
# The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
# which generally depends on host OS, with fallback value of 3000.
# which generally depends on host OS, with fallback value of 5000.
#
# @param file_stable_age_msec [::FFI::Pointer, #to_ptr]
# @return [void]
Expand Down
2 changes: 1 addition & 1 deletion include/zsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ CZMQ_EXPORT void
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
CZMQ_EXPORT void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);

Expand Down
2 changes: 1 addition & 1 deletion src/czmq_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ CZMQ_PRIVATE char *
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.
CZMQ_PRIVATE void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);

Expand Down
12 changes: 6 additions & 6 deletions src/zdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,9 @@ zdir_test (bool verbose)

// wait for initial file to become 'stable'
#ifdef CZMQ_BUILD_DRAFT_API
zclock_sleep (zsys_file_stable_age_msec() + 1);
zclock_sleep (zsys_file_stable_age_msec() + 50);
#else
zclock_sleep (3001);
zclock_sleep (5050);
#endif

zsock_send (watch, "si", "TIMEOUT", 100);
Expand Down Expand Up @@ -1004,9 +1004,9 @@ zdir_test (bool verbose)
// poll for a certain timeout before giving up and failing the test
void* polled = NULL;
#ifdef CZMQ_BUILD_DRAFT_API
polled = zpoller_wait(watch_poll, zsys_file_stable_age_msec() + 1);
polled = zpoller_wait(watch_poll, zsys_file_stable_age_msec() + 150);
#else
polled = zpoller_wait(watch_poll, 3001);
polled = zpoller_wait(watch_poll, 5150);
#endif
assert (polled == watch);

Expand Down Expand Up @@ -1035,9 +1035,9 @@ zdir_test (bool verbose)

// poll for a certain timeout before giving up and failing the test.
#ifdef CZMQ_BUILD_DRAFT_API
polled = zpoller_wait(watch_poll, zsys_file_stable_age_msec() + 1);
polled = zpoller_wait(watch_poll, zsys_file_stable_age_msec() + 150);
#else
polled = zpoller_wait(watch_poll, 3001);
polled = zpoller_wait(watch_poll, 5150);
#endif
assert (polled == watch);

Expand Down
4 changes: 2 additions & 2 deletions src/zfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ zfile_test (bool verbose)
close (handle);
assert (zfile_has_changed (file));
#ifdef CZMQ_BUILD_DRAFT_API
zclock_sleep (zsys_file_stable_age_msec() + 1);
zclock_sleep (zsys_file_stable_age_msec() + 50);
#else
zclock_sleep (3001);
zclock_sleep (5050);
#endif
assert (zfile_has_changed (file));

Expand Down
15 changes: 11 additions & 4 deletions src/zsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static bool s_initialized = false;
// This is a private tunable that is likely to be replaced or tweaked later
// per comment block at s_zsys_file_stable() implementation, to reflect
// the best stat data granularity available on host OS *and* used by czmq.
#define S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC 3000
#define S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC 5000
#endif

// Default globals for new sockets and other joys; these can all be set
Expand All @@ -78,7 +78,7 @@ static int s_thread_priority = -1; // ZSYS_THREAD_PRIORITY=-1
static size_t s_max_sockets = 1024; // ZSYS_MAX_SOCKETS=1024
static int s_max_msgsz = INT_MAX; // ZSYS_MAX_MSGSZ=INT_MAX
static int s_file_stable_age_msec = S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC;
// ZSYS_FILE_STABLE_AGE_MSEC=3000
// ZSYS_FILE_STABLE_AGE_MSEC=5000
static size_t s_linger = 0; // ZSYS_LINGER=0
static size_t s_sndhwm = 1000; // ZSYS_SNDHWM=1000
static size_t s_rcvhwm = 1000; // ZSYS_RCVHWM=1000
Expand Down Expand Up @@ -720,7 +720,7 @@ s_zsys_file_stable (const char *filename, bool verbose)
// removable media, and only account even seconds in stat data.
// Solutions are two-fold: when using stat fields that are precise
// to a second (or inpredictably two), we should actually check for
// (age > 3000) in rounded-microsecond accounting. Also, for some
// (age > 3000+) in rounded-microsecond accounting. Also, for some
// systems we can have `configure`-time checks on presence of more
// precise (and less standardized) stat timestamp fields, where we
// can presumably avoid rounding to thousands and use (age > 2000).
Expand Down Expand Up @@ -1491,7 +1491,7 @@ zsys_max_msgsz (void)
// that should elapse until we consider that object "stable" at the
// current zclock_time() moment.
// The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
// which generally depends on host OS, with fallback value of 3000.
// which generally depends on host OS, with fallback value of 5000.

void
zsys_set_file_stable_age_msec (int64_t file_stable_age_msec)
Expand All @@ -1511,6 +1511,13 @@ void
// This can be used in code that chooses to wait for this timeout
// before testing if a filesystem object is "stable" or not.

// Note that the OS timer quantization can bite you, so it may be
// reasonably safe to sleep/wait/poll for a larger timeout before
// assuming a fault, e.g. the default timer resolution on Windows
// is 15.6 ms (per timer interrupt 64 times a second), graphed here:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx
// and Unix/Linux OSes also have different-resolution timers.

int64_t
zsys_file_stable_age_msec (void)
{
Expand Down

0 comments on commit 8551a11

Please sign in to comment.