<commit_before>// Copyright 2013 Joyent, Inc.  All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

var domain = require('domain');
var net = require('net');
var util = require('util');

var assert = require('assert-plus');
var clone = require('clone');
var once = require('once');

var dtrace = require('./dtrace');
var errors = require('./errors');
var RpcCall = require('./call').RpcCall;
var RpcParser = require('./parser').RpcParser;
var RpcReply = require('./reply').RpcReply;



///--- Globals

var slice = Function.prototype.call.bind(Array.prototype.slice);
var sprintf = util.format;



///--- Private Methods
// "this" is bound to an RpcServer

function ifError(n) {
    function _ifError(err) {
        if (err) {
            err._rpc_next = n;
            throw err;
        }
    }

    return (_ifError);
}


function onConnection(c) {
    var log = this.log;
    var parser = new RpcParser({
        log: log
    });
    var self = this;

    c.on('error', function (err) {
        log.error(err, 'connection error occurred');
    });

    parser.on('message', function onRpcMessage(msg) {
        assert.ok(msg, 'parsed rpc object is null');

        var err;
        function return_error() {
            err.xid = msg.xid;
            c.write(err.toBuffer());
        }

        log.trace({
            rpc_call: msg
        }, 'call received');

        if (msg.rpcvers !== 2) {
            err = new errors.RpcMismatchError();
            return_error();
        } else if (msg.prog !== self.program) {
            err = new errors.RpcProgramUnavailableError();
            return_error();
        } else if (self.version.indexOf(msg.vers) === -1) {
            err = new errors.RpcProgramMismatchError();
            err.setVersion(self.version[self.version.length - 1]);
            return_error();<commit_msg>MANTA-1844 nfs client can have more than 10 ops running at once<commit_after>// Copyright 2013 Joyent, Inc.  All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

var domain = require('domain');
var net = require('net');
var util = require('util');

var assert = require('assert-plus');
var clone = require('clone');
var once = require('once');

var dtrace = require('./dtrace');
var errors = require('./errors');
var RpcCall = require('./call').RpcCall;
var RpcParser = require('./parser').RpcParser;
var RpcReply = require('./reply').RpcReply;



///--- Globals

var slice = Function.prototype.call.bind(Array.prototype.slice);
var sprintf = util.format;



///--- Private Methods
// "this" is bound to an RpcServer

function ifError(n) {
    function _ifError(err) {
        if (err) {
            err._rpc_next = n;
            throw err;
        }
    }

    return (_ifError);
}


function onConnection(c) {
    var log = this.log;
    var parser = new RpcParser({
        log: log
    });
    var self = this;

    // Clients can have many requests running in parallel
    c.setMaxListeners(256);

    c.on('error', function (err) {
        log.error(err, 'connection error occurred');
    });

    parser.on('message', function onRpcMessage(msg) {
        assert.ok(msg, 'parsed rpc object is null');

        var err;
        function return_error() {
            err.xid = msg.xid;
            c.write(err.toBuffer());
        }

        log.trace({
            rpc_call: msg
        }, 'call received');

        if (msg.rpcvers !== 2) {
            err = new errors.RpcMismatchError();
            return_error();
        } else if (msg.prog !== self.program) {
            err = new errors.RpcProgramUnavailableError();
            return_error();
        } else if (self.version.indexOf(msg.vers) === -1) {
            err = new errors.RpcProgramMismatchError();
            err.setVersion(self.version[self.version.length - 1]);
            return_error();
{'fraction_non_alphanumeric': 0.1433389544688027, 'fraction_numerical': 0.0074680799807275355, 'mean_word_length': 2.308366533864542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5343994', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1232, 'n_words': 357}