<commit_before>#include <client/dbclient.h>

extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
#include <compat-5.1.h>
#endif
};

#include "common.h"

using namespace mongo;

extern const luaL_Reg dbclient_methods[];

namespace {
inline DBClientConnection* userdata_to_connection(lua_State* L, int index) {
    void *ud = luaL_checkudata(L, index, LUAMONGO_CONNECTION);
    DBClientConnection *connection = *((DBClientConnection **)ud);
    return connection;
}

} // anonymous namespace

/*
 * db,err = mongo.Connection.New({})
 *    accepts an optional table of features:
 *       auto_reconnect   (default = false)
 *       rw_timeout       (default = 0) (mongo >= v1.5)
 */
static int connection_new(lua_State *L) {
    int resultcount = 1;

    try {
        bool auto_reconnect;
        int rw_timeout;
        if (lua_type(L,1) == LUA_TTABLE) {
            // extract arguments from table
            lua_getfield(L, 1, "auto_reconnect");
            auto_reconnect = lua_toboolean(L, -1);
            lua_getfield(L, 1, "rw_timeout");
            int rw_timeout = lua_tointeger(L, -1);<commit_msg>Fixed timeout to be a double, as MongoDB expects, and to ACTUALLY BE USED, since the previous int was shadowing a parameter by the same name (cherry picked from commit b2cd2eda8e0fbd287544a531dac795c6d2f136f1)<commit_after>#include <client/dbclient.h>

extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
#include <compat-5.1.h>
#endif
};

#include "common.h"

using namespace mongo;

extern const luaL_Reg dbclient_methods[];

namespace {
inline DBClientConnection* userdata_to_connection(lua_State* L, int index) {
    void *ud = luaL_checkudata(L, index, LUAMONGO_CONNECTION);
    DBClientConnection *connection = *((DBClientConnection **)ud);
    return connection;
}

} // anonymous namespace

/*
 * db,err = mongo.Connection.New({})
 *    accepts an optional table of features:
 *       auto_reconnect   (default = false)
 *       rw_timeout       (default = 0) (mongo >= v1.5)
 */
static int connection_new(lua_State *L) {
    int resultcount = 1;

    try {
        bool auto_reconnect;
        double rw_timeout;
        if (lua_type(L,1) == LUA_TTABLE) {
            // extract arguments from table
            lua_getfield(L, 1, "auto_reconnect");
            auto_reconnect = lua_toboolean(L, -1);
            lua_getfield(L, 1, "rw_timeout");
            rw_timeout = lua_tonumber(L, -1);
{'fraction_non_alphanumeric': 0.11982825917252146, 'fraction_numerical': 0.0195160031225605, 'mean_word_length': 3.3003355704697985, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '470833', 'n_tokens_mistral': 925, 'n_tokens_neox': 883, 'n_words': 216}