-
Notifications
You must be signed in to change notification settings - Fork 143
Added unit test for reentrancy. #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc @pcwalton |
src/test.rs
Outdated
#[derive(Clone, Debug, Eq, PartialEq)] | ||
struct HasWeirdSerializer (Option<String>); | ||
|
||
lazy_static! { static ref WEIRD_CHANNEL: (IpcSender<HasWeirdSerializer>, IpcReceiver<HasWeirdSerializer>) = ipc::channel().unwrap(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A non-reentrant testcase for reentrance? Now that's just lazy! ;-)
I guess it's not really a problem, unless the test harness ever grows an ability to run the same test multiple times in parallel, which seems rather hypothetical...
For what it's worth, this looks good to me. (I'm happy to see a testcase being added for obscure behaviour someone will be relying on -- a very good practice that probably should be employed more often :-) ) |
Travis is displeased:
|
Not sure why I'm not getting this error on my end... I'll put it in a rw mutex or some such and retry. |
@asajeffrey on what platform(s) have you tested this? The definition of |
The test isn't to see if it's thread-safe, it's to see if it's reentrant. Since IPC channels serialize to a fresh buffer each time, it should be reentrant. |
@asajeffrey well, that's not what the test is about -- but since |
Indeed, since it's a global it has to be sync. Rather ironically this is exactly the use case for reentrant locks, which is what got is here in the first place. Probably easiest just to make it thread-local. I'm not at my desk today, I'll do this tomorrow. |
I made Travis happy by making the global thread-local. |
src/test.rs
Outdated
Ok(HasWeirdSerializer(try!(Deserialize::deserialize(deserializer)))) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think it would be more readable to put all this stuff right before the (only) test case using it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
@asajeffrey thanks :-) Please squash the commits -- and then we just need someone with official reviewer status to approve it... |
Squashed. |
Meh, there is an intermittent failure it seems? This definitely shouldn't be affected by these changes... |
Yes, that is odd... timeouts on unrelated tests? |
Just to be clear: I really don't think this test failure has anything to do with this PR. Either the test case in question has intermittent failures, or there was some one-time hiccup on Travis. @pcwalton r? |
☔ The latest upstream changes (presumably #92) made this pull request unmergeable. Please resolve the merge conflicts. |
Looks good once the conflicts are resolved. |
36af002
to
525f6d6
Compare
@bors-servo r=pcwalton |
📌 Commit 3a06775 has been approved by |
Added unit test for reentrancy. IPC channels are reentrant, in that if we call `c.send(a)` and serializing `a` calls `c.send(b)`, then the channel contents are `b` then `a`. (This comes up in the case of logging over channels, since serialization may include logging.) This PR adds a unit test to make sure we don't break reentrancy. Discussion with @nox on IRC.
☀️ Test successful - status-appveyor, status-travis |
IPC channels are reentrant, in that if we call
c.send(a)
and serializinga
callsc.send(b)
, then the channel contents areb
thena
. (This comes up in the case of logging over channels, since serialization may include logging.)This PR adds a unit test to make sure we don't break reentrancy.
Discussion with @nox on IRC.