<commit_before>
/*!
 * socket.io-node
 * Copyright(c) 2011 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module requirements.
 */

var Transport = require('../transport')
  , parser = require('../parser')
  , util = require('util')
  , qs = require('querystring');

/**
 * Exports the constructor.
 */

module.exports = Polling;

/**
 * HTTP polling constructor.
 *
 * @api public.
 */

function Polling (mng, data, req) {
  Transport.call(this, mng, data, req);
}

/**
 * Inherits from Transport.
 *
 * @api public.
 */

util.inherits(Polling, Transport);

/**
 * Transport name
 *
 * @api public
 */

Polling.prototype.name = 'polling';

/**
 * Do some initialization when connection is established
 *
 * @api private
 */

Polling.prototype.onConnect = function () {
  this.setup();
  this.readyState = Transport.CONNECTED;
};

/**
 * Start to query client data from Queue
 * 
 * @api private
 */

Polling.prototype.setup = function() {
  var self = this;
  this.log.debug('set close timeout');
  this.store.getFromRecvQ(this.id, function(isTimeout, data) {
    if (self.readyState !== Transport.CONNECTED) {
      return;
    }

    if (isTimeout) {
      self.log.debug('close timeout fired');
      self.disconnect('close timeout');<commit_msg>check readyState before reading from recvQ.<commit_after>
/*!
 * socket.io-node
 * Copyright(c) 2011 LearnBoost <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module requirements.
 */

var Transport = require('../transport')
  , parser = require('../parser')
  , util = require('util')
  , qs = require('querystring');

/**
 * Exports the constructor.
 */

module.exports = Polling;

/**
 * HTTP polling constructor.
 *
 * @api public.
 */

function Polling (mng, data, req) {
  Transport.call(this, mng, data, req);
}

/**
 * Inherits from Transport.
 *
 * @api public.
 */

util.inherits(Polling, Transport);

/**
 * Transport name
 *
 * @api public
 */

Polling.prototype.name = 'polling';

/**
 * Do some initialization when connection is established
 *
 * @api private
 */

Polling.prototype.onConnect = function () {
  this.setup();
  this.readyState = Transport.CONNECTED;
};

/**
 * Start to query client data from Queue
 * 
 * @api private
 */

Polling.prototype.setup = function() {
  if (this.readyState === Transport.DISCONNECTED
      || this.readyState === Transport.DISCONNECTING) {
    return;
  }

  var self = this;
  this.log.debug('set close timeout');
  this.store.getFromRecvQ(this.id, function(isTimeout, data) {
    if (self.readyState !== Transport.CONNECTED) {
      return;
    }

    if (isTimeout) {
      self.log.debug('close timeout fired');
      self.disconnect('close timeout');
{'fraction_non_alphanumeric': 0.16114457831325302, 'fraction_numerical': 0.0030120481927710845, 'mean_word_length': 3.184251968503937, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6479407', 'n_tokens_mistral': 876, 'n_tokens_neox': 856, 'n_words': 202}