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

Comments

Projects
None yet
5 participants
@tompaana
Member

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

This comment has been minimized.

Show comment
Hide comment
@tompaana

tompaana Apr 27, 2016

Member

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.

Member

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