Skip to content
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

Test case, We provide notification when a listener dies and we recreate it, has a race condition on Android #719

Open
tompaana opened this issue Apr 27, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@tompaana
Copy link
Member

@tompaana tompaana commented Apr 27, 2016

After adding logging to this test case (in thaliMobileNativeWrapper.js) I noticed a possible race condition: Function nonTCPAvaiHandler is called just before recreatedHandler leading to recreatedPort to be null.

Code:

...
      function recreatedHandler(record) {
        t.equal(record.peerIdentifier, peer.peerIdentifier, 'same ids');
        recreatedPort = record.portNumber;
      }
...
      function nonTCPAvaiHandler(record) {
        if (record.peerIdentifier !== peer.peerIdentifier) {
          logger.debug('Peer identifiers do not match: '
            + record.peerIdentifier + ' !== ' + peer.peerIdentifier);
          return;
        }
        if (!recreatedPort ||
          recreatedPort && record.portNumber !== recreatedPort) {
          logger.debug('No recreated port or port numbers do not match: '
            + record.portNumber + ' !== ' + recreatedPort);
          return;
        }
        testUtils.get('127.0.0.1', record.portNumber, testPath, pskIdentity,
                      pskKey)
          .then(function (responseBody) {
            t.equal(responseBody, testData, 'matching bodies');
            exit();
          })
          .catch(function (err) {
            t.fail(err);
            exit();
          });
      }
...

Log:

04-27 04:06:41.387 27171-27321/com.test.thalitest I/jxcore-log: DEBUG createPeerListener: Recreating listener
04-27 04:06:41.394 27171-27321/com.test.thalitest I/jxcore-log: DEBUG createPeerListener: createPeerListener creating new server
04-27 04:06:41.400 27171-27321/com.test.thalitest I/jxcore-log: DEBUG createPeerListener: pleaseConnect= false
04-27 04:06:41.406 27171-27321/com.test.thalitest I/jxcore-log: DEBUG testThaliMobileNativeWrapper: No recreated port or port numbers do not match: 48750 !== null
04-27 04:06:41.408 27171-27321/com.test.thalitest I/jxcore-log: ok 311 same ids
@tompaana tompaana added this to the New Infra milestone Apr 27, 2016
@tompaana
Copy link
Member Author

@tompaana tompaana commented Apr 27, 2016

After commenting out this check

        if (!recreatedPort ||
          recreatedPort && record.portNumber !== recreatedPort) {
          logger.debug('No recreated port or port numbers do not match: '
            + record.portNumber + ' !== ' + recreatedPort);
          return;
        }

...the test passes.

@yaronyg yaronyg removed their assignment Jul 15, 2016
@yaronyg yaronyg added the estimate - 2 label Aug 8, 2016
@artemjackson artemjackson self-assigned this Aug 11, 2016
@artemjackson artemjackson added 3 - Working and removed 2 - Ready labels Aug 11, 2016
@yaronyg yaronyg added 1 - Backlog and removed 3 - Working labels Aug 11, 2016
@artemjackson artemjackson removed their assignment Aug 18, 2016
@yaronyg yaronyg added Android Node and removed Android labels Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.