示例#1
0
struct skynet_module * 
skynet_module_query(const char * name) {
	struct skynet_module * result = _query(name);
	if (result)
		return result;

	SPIN_LOCK(M)

	result = _query(name); // double check

	if (result == NULL && M->count < MAX_MODULE_TYPE) {
		int index = M->count;
		void * dl = _try_open(M,name);
		if (dl) {
			M->m[index].name = name;
			M->m[index].module = dl;

			if (_open_sym(&M->m[index]) == 0) {
				M->m[index].name = skynet_strdup(name);
				M->count ++;
				result = &M->m[index];
			}
		}
	}

	SPIN_UNLOCK(M)

	return result;
}
示例#2
0
struct skynet_module *
skynet_module_query(const char * name) {
    struct skynet_module * result = _query(name);
    if (result)
        return result;

    while(__sync_lock_test_and_set(&M->lock,1)) {}

    result = _query(name); // double check

    if (result == NULL && M->count < MAX_MODULE_TYPE) {
        int index = M->count;
        void * dl = _try_open(M,name);
        if (dl) {
            M->m[index].name = name;
            M->m[index].module = dl;
            if (_open_sym(&M->m[index])== 0) {
                M->m[index].name = strdup(name);
                M->count ++;
                result = &M->m[index];
            }
        }
    }

    __sync_lock_release(&M->lock);

    return result;
}
示例#3
0
 int _query(int a,int b,int k,int l, int r){
   if(r<=a||b<=l)return INT_MAX;
   if(a<=l&&r<=b)return val[k];
   else{
     int vl=_query(a,b,k*2+1,l,(l+r)/2);
     int vr=_query(a,b,k*2+2,(l+r)/2,r);
     return min(vl,vr);
   }
 }
示例#4
0
/**
 * Returns nonzero if the given optin object has an option by the given name, zero otherwise
 */
int optin_has_option(optin* o, const char* name)    {
    if (!o) {
        return 0;
    }
    
    return _query(o->options, name) != 0;
}
示例#5
0
/**
 * Looks up an option in the option dictionary by the given name.  Creates a new option and adds it to
 * the options dictionary if not found
 */
static _option* _query_or_new(hashtable* options, const char* name)   {
    _option_wrapper* option_wrapper;
    _option* option;
    
    option = _query(options, name);
    if (!option)    {
        /* Not found, create and insert */
        option = (_option*)malloc(sizeof(_option));
        memset(option, 0, sizeof(_option));
        option->name = xp_strdup(name);
        
        /* Key by the long name */
        option_wrapper = (_option_wrapper*)malloc(sizeof(_option_wrapper));
        memset(option_wrapper, 0, sizeof(_option_wrapper));
        option_wrapper->key = xp_strdup(name);
        option_wrapper->alias = 0;              /* We own the option */
        option_wrapper->o = option;
        ht_insert(options, (void*)option_wrapper);
        
        /* Key by the short name */
        _set_shortname(options, name, name[0]);
    }
    
    return option;
}
示例#6
0
/**
 * Sets the one-character shortname of the given option
 *
 * options      - The options dictionary which contains the option
 * name         - The (full) name of the option
 * shortname    - The one-character short name of the option
 *
 * NOTES:
 *  - It is not necessary to call this function unless you wish to override the default short name, which
 *    is the first letter of the long name
 *  - If an existing short name exists (including the default), it will be removed and replaced
 *  - If an identical short name exists, it will be replaced with this one, even if it is for a different
 *    option
 */
void _set_shortname(hashtable* options, const char* name, char shortname)    {
    _option* option;
    _option_wrapper* wrapper, *query_wrapper;
    char* str_shortname;
    
    if (!options) {
        return;
    }
    
    option = _query(options, name);
    if (!option)    {
        return;
    }
    
    xp_asprintf(&str_shortname, "%c", shortname);
    
    wrapper = (_option_wrapper*)malloc(sizeof(_option_wrapper));
    wrapper->key = str_shortname;
    wrapper->alias = 1;             /* We don't own the option */
    query_wrapper = wrapper;
    if (ht_lookup(options, (void*)&wrapper) != 0)    {
        /* It's not in there, just add it */
        wrapper->key = xp_strdup(str_shortname);
        ht_insert(options, (void*)wrapper);
    } else {
        /* Already in there */
        free(query_wrapper->key);
        free(query_wrapper);
    }
    
    wrapper->o = option;
}
示例#7
0
int 
init(
	boost::shared_ptr<cql::cql_session_t> session,
	int n,
	cql::cql_consistency_enum cl,
	bool batch)
{
	std::string query_string = str(boost::format("INSERT INTO %s(k, i) VALUES (0, 0)") % test_utils::SIMPLE_TABLE);	

	if(batch)
	{
		std::string bth;
		bth.append("BEGIN BATCH ");
		bth.append(str(boost::format("INSERT INTO %s(k, i) VALUES (0, 0)") % test_utils::SIMPLE_TABLE));
		bth.append(" APPLY BATCH");
		query_string = bth;
	}

	for (int i = 0; i < n; ++i)
	{
		boost::shared_ptr<cql::cql_query_t> _query(
			new cql::cql_query_t(query_string ,cl));
		boost::shared_future<cql::cql_future_result_t> query_future = session->query(_query);
		query_future.wait();

		cql::cql_future_result_t query_result = query_future.get();

		if(query_result.error.code != 0)
			return query_result.error.code;		
	}
	return 0;
}
示例#8
0
文件: dbase.c 项目: mudchina/fy4
varargs mixed query(string prop, int raw) {
        mixed data, pdata; 
        if(!mapp(dbase)) {
                return 0;
        }
        
        if(undefinedp(dbase[prop]) && (strsrch(prop, '/')!=-1)) {
                data = _query(dbase, explode(prop, "/"));
        } else {
                data = dbase[prop];
        }
        
        if(default_ob) {
                if(undefinedp(data)) {
                        data = default_ob->query(prop, 1);
                } else if(mapp(data)) {
                        pdata = default_ob->query(prop, 1);
                        if(mapp(pdata)) {
                                data = pdata + data;
                        }
                }
        }
        
        if(raw) {
                return data;
        }
        
        return evaluate( data, this_object() );
} 
示例#9
0
void L2Socket::Acceptor( CChar _ip, CChar _port )
{
    if ( ioService == nullptr ) ioService = new io_service();
    if ( acceptor != nullptr )  delete acceptor;
    
    //LOG( "Acceptor ip: "+_ip+" port: "+_port);
    tcp::resolver _resolver(*ioService);
    // tcp::v4() = 127.0.0.1
    // ip::host_name()
    //address_v4 address = address_v4::from_string(_ip);
    //tcp::endpoint endpoint(address, *_port);
    tcp::resolver::query _query( _ip, _port);
    tcp::endpoint endpoint = *_resolver.resolve(_query);
    //LOG( "Acceptor ip: "+_ip+" port: "+endpoint.port());
    //LOG( "Acceptor ip: "+address.to_string()+" port: "+endpoint.port());
    
    acceptor = new tcp::acceptor(*ioService,endpoint);
    //acceptor = new tcp::acceptor(*ioService);
    //acceptor->open(endpoint.protocol());
    //acceptor->set_option(socket_base::reuse_address(config.reuse_address));
    //acceptor->bind(endpoint);
    //acceptor->listen();

    if(acceptor != nullptr )
        LOG( "Acceptor ip: "+endpoint.address().to_string()+" port: "+endpoint.port());
    else
        LOG( "Acceptor acceptor nullptr!!!" );
    OnAccept();

}
示例#10
0
static JSVAL query(JSARGS args) {
    redisContext *c = (redisContext *)JSOPAQUE(args[0]);
    String::Utf8Value _query(args[1]->ToString());
    redisReply *reply = (redisReply *)redisCommand(c, *_query);

    switch (reply->type) {
        case REDIS_REPLY_STATUS:
        case REDIS_REPLY_STRING:
            {
                Handle<String> s = String::New(reply->str, reply->len);
                freeReplyObject(reply);
                return s;
            }
        case REDIS_REPLY_ARRAY:
            {
                Handle<Array> a = Array::New();
                int ndx = 0;
                for (int j=0; j<reply->elements; j++) {
                    redisReply *element = reply->element[j];
                    switch (element->type) {
                        case REDIS_REPLY_STATUS:
                        case REDIS_REPLY_STRING:
                            a->Set(ndx++, String::New(element->str, element->len));
                            break;
                        case REDIS_REPLY_INTEGER:
                            a->Set(ndx++, Number::New(element->integer));
                            break;
                        case REDIS_REPLY_NIL:
                            a->Set(ndx++, Null());
                            break;
                        case REDIS_REPLY_ERROR:
                            {
                                Handle<String>s = String::New(reply->str, reply->len);
                                freeReplyObject(reply);
                                return ThrowException(String::Concat(String::New("Redis query error: "), s));
                            }
                    }
                }
                freeReplyObject(reply);
                return a;
            }
        case REDIS_REPLY_INTEGER:
            {
                Handle<Number>n = Number::New(reply->integer);
                freeReplyObject(reply);
                return n;
            }
        case REDIS_REPLY_NIL:
            freeReplyObject(reply);
            return Null();
        case REDIS_REPLY_ERROR:
            {
                Handle<String>s = String::New(reply->str, reply->len);
                freeReplyObject(reply);
                return ThrowException(String::Concat(String::New("Redis query error: "), s));
            }
    }
}
示例#11
0
int YARPNameClient::query (const YARPString &s, ACE_INET_Addr &addr, int *type)
{
  YNC("YNC %s:%d --> query %s\n",__FILE__,__LINE__,s.c_str());
	int ret = YARP_FAIL;
	mutex_.Wait();
	ret = _query(s, addr, type);
	mutex_.Post();
	return ret;
}
示例#12
0
void L2Socket::ConnectHTTP( size_t _agentOID, CChar _http, CChar _port )
{
    if ( ioService == nullptr ) ioService = new io_service();
    
    tcp::socket* _socket = new tcp::socket(*ioService);
    tcp::resolver  _resolver(*ioService);
    tcp::resolver::query _query(_http, _port);
    LOG( "ConnectHttp start resolve...");
    _resolver.async_resolve(_query, bind(&L2Socket::HandleResolve,this,ref(*_socket),_agentOID,_1,_2));
}
示例#13
0
文件: module.c 项目: zhangjinde/z
void moduleInsert(struct module* mod) {
	while(__sync_lock_test_and_set(&M->lock, 1)) {}

	struct module* m = _query(mod->name);
	assert(m == NULL && M->count < MAX_MODULE_TYPE);
	int index = M->count;
	M->m[index] = *mod;
	++M->count;
	__sync_lock_release(&M->lock);
}
示例#14
0
/** 
 * Returns nonzero if the given option is present and was explicitly set by the user, zero if no
 * such option exists or if the option was not explcitly set by the user
 */
int optin_option_is_set(optin* o, const char* name)    {
    _option* option;
    
    if (!o) {
        return 0;
    }
    
    option = _query(o->options, name);
    return option && option->set;
}
示例#15
0
void L2Socket::ConnectIP( size_t _agentOID, CChar _ip, CChar _port )
{
    if ( ioService == nullptr ) ioService = new io_service();
    
    tcp::socket* _socket = new tcp::socket(*ioService);
    tcp::resolver  _resolver(*ioService);
    tcp::resolver::query _query(_ip, _port);
    tcp::resolver::iterator _it = _resolver.resolve(_query);
    LOG( "ConnectIP start..." );
    async_connect(*_socket,_it,bind(&L2Socket::HandleConnect,this,ref(*_socket),_agentOID,_1,_2));

}
示例#16
0
static JSVAL command(JSARGS args) {
    redisContext *c = (redisContext *)JSOPAQUE(args[0]);
    String::Utf8Value _query(args[1]->ToString());
    char *argstr = strdup(*_query);
    char *in = argstr;
    int n = 0;
    while (*in) {
        while (isspace(*in)) in++;
        if (*in) {
            n++;
            if (*in == '"') {
                in++;
                while (*in && *in != '"') in++;
                if (*in == '"') in++;
            }
            else {
                while (*in && !isspace(*in)) in++;
            }
        }
    }
    in = argstr;
    int argc = n;
    char *argv[n];
    n = 0;
    while (*in) {
        while (isspace(*in)) in++;
        if (*in) {
            if (*in == '"') {
                in++;
                argv[n++] = in;
                while (*in && *in != '"') in++;
                if (*in == '"') {
                    *in = '\0';
                    in++;
                }
            }
            else {
                argv[n++] = in;
                while (*in && !isspace(*in)) {
					in++;
				}
				if (*in != '\0') {
                	*in++ = '\0';
				}
            }
        }
    }
    // printf("%s\n", *_query);
    // redisReply *reply = (redisReply *)redisCommand(c, *_query);
    redisReply *reply = (redisReply *)redisCommandArgv(c, argc, (const char **)argv, NULL);
    free(argstr);
    return Opaque::New(reply);    
}
示例#17
0
KRecord MySQLKDataDriver::
getKRecord(const string& market, const string& code,
          size_t pos, KQuery::KType kType) {
    string func_name(" [MySQLKDataDriver::getKRecord]");
    KRecord result;
    if (!m_mysql) {
        HKU_ERROR("Null m_mysql!" << func_name);
        return result;
    }

    /*if (kType >= KQuery::INVALID_KTYPE ) {
        HKU_WARN("ktype(" << kType << ") is invalid" << func_name);
        return result;
    }*/

    MYSQL_RES *mysql_result;
    MYSQL_ROW row;

    string table(_getTableName(market, code, kType));
    std::stringstream buf (std::stringstream::out);
    buf << "select date, open, high, low, close, amount, count from "
            << table << " order by date limit " << pos << ", 1";
    if (!_query(buf.str())) {
        HKU_ERROR("mysql_query error! " << func_name);
        return result;
    }

    mysql_result = mysql_store_result(m_mysql.get());
    if (!mysql_result) {
        HKU_ERROR("mysql_store_result error!" << func_name);
        return result;
    }

    while ((row = mysql_fetch_row(mysql_result))) {
        try {
            hku_uint64 d = boost::lexical_cast<hku_uint64>(row[0]);
            result.datetime = Datetime(d);
            result.openPrice = boost::lexical_cast<price_t>(row[1]);
            result.highPrice = boost::lexical_cast<price_t>(row[2]);
            result.lowPrice = boost::lexical_cast<price_t>(row[3]);
            result.closePrice = boost::lexical_cast<price_t>(row[4]);
            result.transAmount = boost::lexical_cast<price_t>(row[5]);
            result.transCount = boost::lexical_cast<price_t>(row[6]);
        } catch (...) {
            HKU_INFO("Error get record " << pos << " " << table << func_name);
            result = Null<KRecord>();
        }
    }

    mysql_free_result(mysql_result);
    return result;
}
示例#18
0
文件: dbase.c 项目: mudchina/fy4
varargs mixed query_with_slash(string prop, int raw)
{
        mixed data; 
        if( !mapp(dbase) ) return 0; 
        if( undefinedp(dbase[prop]) && (strsrch(prop, '.')!=-1) )
                data = _query(dbase, explode(prop, "."));
        else
                data = dbase[prop]; 
        if( undefinedp(data) && default_ob )
                data = default_ob->query(prop, 1); 
        if( raw ) return data; 
        return evaluate( data, this_object() );
} 
示例#19
0
shared_ptr<IDbResult> IDbConnection::query(const String &sql)
{
	try
	{		
		return _query(sql);
	}
	catch(std::exception &e)
	{
		logError(sql, e);
		throw(e);

		return nullptr;
	}
}
示例#20
0
/**
 * Sets the callback function for the given option so that a user-function is called whenever an option
 * is set by the user
 * 
 * o            - The optin object to which to add the option
 * name         - The long name of the option (example "haswidth")
 * callback     - Pointer to a function of type optin_fn, which will be called if the given option appears
 *
 * NOTES:
 *  - Calling the function with a null optin object has no effect
 *  - If the option does not exist, this funciton has no effect
 *  - The function will NOT be called for the default value if the user did not explicitly include the option
 *    on the command line
 */
void optin_set_callback(optin* o, const char* name, optin_fn callback)    {   
    _option* option;
    
    if (!o) {
        return;
    }
    
    option = _query(o->options, name);
    if (!option)    {
        return;
    }
    
    option->callback - callback;
}
示例#21
0
文件: module.c 项目: zhoukk/routine
struct module *module_query(const char *name) {
	struct module *module = _query(name);
	if (module) return module;
	spinlock_lock(&M.lock);
	module = _query(name);
	if (!module && M.count < MODULE_SIZE) {
		void *dl = _module_open(name);
		if (dl) {
			module = &M.modules[M.count];
			module->name = (char *)name;
			module->dl = dl;
			if (_module_sym(module) == 0) {
				char *_name = (char *)pixel_alloc(0, strlen(name)+1);
				strcpy(_name, name);
				module->name = _name;
				M.count++;
			} else {
				module = 0;
			}
		}
	}
	spinlock_unlock(&M.lock);
	return module;
}
示例#22
0
json_t *arbplf_trans_run(void *userdata, json_t *root, int *retcode)
{
    json_t *j_out = NULL;
    model_and_data_t m;
    column_reduction_t r_site;
    column_reduction_t r_edge;
    column_reduction_t r_trans;
    int *first_idx;
    int *second_idx;
    int result = 0;

    first_idx = NULL;
    second_idx = NULL;

    model_and_data_init(m);
    column_reduction_init(r_site);
    column_reduction_init(r_edge);
    column_reduction_init(r_trans);

    if (userdata)
    {
        fprintf(stderr, "internal error: unexpected userdata\n");
        result = -1;
        goto finish;
    }

    result = _parse(m, r_site, r_edge, r_trans, &first_idx, &second_idx, root);
    if (result) goto finish;

    j_out = _query(m, r_site, r_edge, r_trans, first_idx, second_idx, &result);
    if (result) goto finish;

finish:

    *retcode = result;

    model_and_data_clear(m);
    column_reduction_clear(r_site);
    column_reduction_clear(r_edge);
    column_reduction_clear(r_trans);

    flint_free(first_idx);
    flint_free(second_idx);

    flint_cleanup();
    return j_out;
}
示例#23
0
文件: fourd.c 项目: famsf/pecl-pdo-4d
FOURD_RESULT* fourd_query(FOURD *cnx,const char *query)
{
	FOURD_RESULT* result;
	
	result=calloc(1,sizeof(FOURD_RESULT));
	result->cnx=cnx;
	if(_query(cnx,3,query,result,cnx->preferred_image_types)==0)
	{
		result->numRow=-1;
		return result;
	}
	else
	{
		fourd_free_result(result);
		return NULL;
	}
}
示例#24
0
size_t MySQLKDataDriver::
getCount(const string& market,
        const string& code,
        KQuery::KType kType) {
    string func_name(" [MySQLKDataDriver::getCount]");
    size_t result = 0;
    if (!m_mysql) {
        HKU_ERROR("Null m_mysql!" << func_name);
        return result;
    }

    /*if (kType >= KQuery::INVALID_KTYPE ) {
        HKU_WARN("ktype(" << kType << ") is invalid" << func_name);
        return result;
    }*/

    MYSQL_RES *mysql_result;
    MYSQL_ROW row;

    string table(_getTableName(market, code, kType));
    std::stringstream buf (std::stringstream::out);
    buf << "select count(1) from " << table;
    if (!_query(buf.str())) {
        HKU_ERROR("mysql_query error! " << func_name);
        return result;
    }

    mysql_result = mysql_store_result(m_mysql.get());
    if (!mysql_result) {
        HKU_ERROR("mysql_store_result error!" << func_name);
        return result;
    }

    while ((row = mysql_fetch_row(mysql_result))) {
        try {
            result = boost::lexical_cast<size_t>(row[0]);
        } catch (...) {
            HKU_INFO("Error get record count of" << table << func_name);
            result = 0;
        }
    }

    mysql_free_result(mysql_result);
    return result;
}
示例#25
0
/**
 * Processes the given option as if it had been given on the command line
 *
 * o        - The optin object that contains the option
 * opt      - The long or short option name (e.g. "velocity" or "v"), do not include dashes
 * value    - The value that the option takes (e.g "35").  Pass NULL if the option takes no value
 *
 * RETURNS: zero if the option was processed successfully, nonzero if there was an error
 */
int optin_process_option(optin* o, const char* opt, const char* value)  {
    _option* option;
    
    /*fprintf(stderr, "Processing option: %s, value: %s\n", opt, value);*/
    
    option = _query(o->options, opt);
    if (!option)    {
        fprintf(stderr, "Unrecognized option: %s\n", opt);
        return OPTIN_ERR_INVALID_OPTION;
    }
    
    switch(option->type)    {
    case OPTION_FLAG:
        if (option->value.intptr != 0)  {
            *option->value.intptr = 1;
        }
        break;
    case OPTION_INT:
        if (option->value.intptr != 0)  {
            *option->value.intptr = atoi(value);
        }
        break;
    case OPTION_FLOAT:
        if (option->value.floatptr != 0)    {
            *option->value.floatptr = atof(value);
        }
        break;
    case OPTION_STRING:
        if (option->value.stringptr != 0)   {
            *option->value.stringptr = xp_strdup(value);
        }
        break;
    }
    
    option->set = 1;
    
    return 0;
}
示例#26
0
int
query(
	boost::shared_ptr<cql::cql_session_t> session,
	int n,
	cql::cql_consistency_enum cl)
{
	for (int i = 0; i < n; ++i)
	{
		boost::shared_ptr<cql::cql_query_t> _query(
			new cql::cql_query_t(str(boost::format("SELECT * FROM %s WHERE k = 0") % test_utils::SIMPLE_TABLE),cl));
        
        boost::shared_future<cql::cql_future_result_t> query_future;

        query_future = session->query(_query);
        if (!(query_future.timed_wait(boost::posix_time::seconds(20)))) {
            BOOST_FAIL("Query timed out");
        }
            
        try {
            cql::cql_future_result_t query_result = query_future.get();
        
            if (query_future.has_value()) {
                std::cout << "Queried endpoint: " << query_result.client->endpoint().to_string() << std::endl;
                add_coordinator(query_result.client->endpoint().address());
                if(query_result.error.code != 0) {
                    return query_result.error.code;
                }
            }
        }
        catch (...) {
            BOOST_MESSAGE("Response contains EXCEPTION");
            throw;
        }
	}
	return 0;
}
示例#27
0
INT32 migExport::_exportCL( const CHAR *pCSName,
                            const CHAR *pCLName,
                            INT32 &total )
{
   INT32 rc = SDB_OK ;
   INT32 clTotal = 0 ;
   bson obj ;

   bson_init( &obj ) ;
   _gCollection = 0 ;
   _gCollectionSpace = 0 ;

   rc = _getCS( pCSName ) ;
   if ( rc )
   {
      PD_LOG ( PDERROR, "Failed to get collection space, rc = %d",
               rc ) ;
      goto error ;
   }
   rc = _getCL( pCLName ) ;
   if ( rc )
   {
      PD_LOG ( PDERROR, "Failed to get collection, rc = %d",
               rc ) ;
      goto error ;
   }
   rc = _query() ;
   if ( rc )
   {
      if ( SDB_DMS_EOC == rc )
      {
         rc = SDB_OK ;
         goto done ;
      }
      else
      {
         PD_LOG ( PDERROR, "Failed to get record, rc = %d",
                  rc ) ;
         goto error ;
      }
   }
   while ( TRUE )
   {
      rc = sdbNext( _gCursor, &obj ) ;
      if ( rc )
      {
         if ( SDB_DMS_EOC != rc )
         {
            PD_LOG ( PDERROR, "Failed to get collection list, rc = %d",
                     rc ) ;
            goto error ;
         }
         else
         {
            rc = SDB_OK ;
            goto done ;
         }
      }
      rc = _writeRecord( &obj ) ;
      if ( rc )
      {
         PD_LOG ( PDERROR, "Failed to write record to file, rc = %d",
                  rc ) ;
         goto error ;
      }
      bson_destroy ( &obj ) ;
      ++clTotal ;
   }
done:
   total += clTotal ;
   bson_destroy ( &obj ) ;
   if ( _gCollection )
   {
      sdbReleaseCollection ( _gCollection ) ;
   }
   if ( _gCollectionSpace )
   {
      sdbReleaseCS ( _gCollectionSpace ) ;
   }
   _gCollection = 0 ;
   _gCollectionSpace = 0 ;
   PD_LOG ( PDEVENT, "%s.%s export record %d in file",pCSName, pCLName, clTotal ) ;
   return rc ;
error:
   goto done ;
}
示例#28
0
				M->count ++;
				result = &M->m[index];
			}
		}
	}

	SPIN_UNLOCK(M)

	return result;
}

void 
skynet_module_insert(struct skynet_module *mod) {
	SPIN_LOCK(M)

	struct skynet_module * m = _query(mod->name);
	assert(m == NULL && M->count < MAX_MODULE_TYPE);
	int index = M->count;
	M->m[index] = *mod;
	++M->count;

	SPIN_UNLOCK(M)
}

void * 
skynet_module_instance_create(struct skynet_module *m) {
	if (m->create) {
		return m->create();
	} else {
		return (void *)(intptr_t)(~0);
	}
示例#29
0
文件: fourd.c 项目: famsf/pecl-pdo-4d
int fourd_exec(FOURD *cnx,const char *query)
{
	return _query(cnx,3,query,NULL,cnx->preferred_image_types);
}
示例#30
0
   INT32 expCLExporter::run( UINT64 &exportedCount, UINT64 &failCount )
   {
      INT32 rc = SDB_OK ;
      sdbCursorHandle hCusor = SDB_INVALID_HANDLE ;
      sdbCollectionHandle hCL = SDB_INVALID_HANDLE ;
      const CHAR *buf = NULL ;
      UINT32 size = 0 ;

      rc = _query( hCL, hCusor ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG ( PDERROR, "Failed to query collection %s.%s, rc = %d", 
                  _cl.csName.c_str(), _cl.clName.c_str(), rc );
         goto error ;
      }

      rc = _out.open() ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "Failed to open output, rc = %d", rc ) ;
         goto error ;
      }

      rc = _convertor.init() ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "Failed to init convertor, rc = %d", rc ) ;
         goto error ;
      }

      rc = _convertor.head( buf, size ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "Failed to get head of convertor, rc = %d", rc ) ;
         goto error ;
      }
      if ( size > 0 )
      {
         rc = _out.output( buf, size );
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "Failed to output the head, rc = %d", rc ) ;
            goto error ;
         }
         buf = _options.delRecord().c_str() ;
         size = (UINT32)_options.delRecord().size() ;
         rc = _out.output( buf, size );
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "Failed to output the record delimiter, rc = %d",
                    rc ) ;
            goto error ;
         }
      }

      rc = _exportRecords( hCusor, exportedCount, failCount ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "Failed to export records, rc = %d", rc ) ;
         goto error ;
      }

      rc = _convertor.tail( buf, size ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "Failed to get tail of convertor, rc = %d", rc ) ;
         goto error ;
      }
      if ( size > 0 )
      {
         rc = _out.output( buf, size );
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "Failed to output the tail, rc = %d", rc ) ;
            goto error ;
         }
      }
      
   done :
      _out.close() ;
      
      if ( SDB_INVALID_HANDLE != hCL )
      {
         sdbReleaseCollection(hCL) ;
      }
      if ( SDB_INVALID_HANDLE != hCusor )
      {
         sdbCloseCursor(hCusor) ;
         sdbReleaseCursor(hCusor) ;
      }
      return rc ;
   error :
      goto done ;
   }