Skip to content

Commit 8fc187b

Browse files
authored
Merge pull request #2325 from oko256/win-fixes-zsock_resolve-ztimerset
Windows fixes for zsock_resolve and ztimerset selftest
2 parents 6b435f5 + b69dc02 commit 8fc187b

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/zsock.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,13 +1845,10 @@ zsock_resolve (void *self)
18451845
if (zsock_is (self))
18461846
return ((zsock_t *) self)->handle;
18471847

1848-
// Check if we have a valid ZMQ socket by probing the socket type
1849-
int type;
1850-
size_t option_len = sizeof (int);
1851-
if (zmq_getsockopt (self, ZMQ_TYPE, &type, &option_len) == 0)
1852-
return self;
1853-
18541848
// Check if self is a valid FD or socket FD
1849+
// We need to check this before zmq_getsockopt, because tag check may
1850+
// cause a segfault if we are checking a native SOCKET (since the data
1851+
// type is smaller than the full object).
18551852
// TODO: this code should move to zsys_isfd () as we don't like
18561853
// non-portable code outside of that class.
18571854
int sock_type = -1;
@@ -1866,6 +1863,13 @@ zsock_resolve (void *self)
18661863
if (rc == 0 || (rc == -1 && errno == ENOTSOCK))
18671864
return NULL; // It's a socket FD or FD
18681865
#endif
1866+
1867+
// Check if we have a valid ZMQ socket by probing the socket type
1868+
int type;
1869+
size_t option_len = sizeof (int);
1870+
if (zmq_getsockopt (self, ZMQ_TYPE, &type, &option_len) == 0)
1871+
return self;
1872+
18691873
// Socket appears to be something else, return it as-is
18701874
return self;
18711875
}

src/ztimerset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ztimerset_test (bool verbose)
181181
assert (!timer_invoked);
182182
int timeout = ztimerset_timeout (self);
183183
assert (timeout > 0);
184-
zclock_sleep (timeout);
184+
zclock_sleep (timeout + 20);
185185
rc = ztimerset_execute (self);
186186
assert (rc == 0);
187187
assert (timer_invoked);

0 commit comments

Comments
 (0)