本文整理汇总了C++中NEWERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ NEWERROR函数的具体用法?C++ NEWERROR怎么用?C++ NEWERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NEWERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m2v2_remote_execute_DESTROY_many
GError*
m2v2_remote_execute_DESTROY_many(gchar **targets, struct oio_url_s *url, guint32 flags)
{
if (!targets)
return NEWERROR(CODE_INTERNAL_ERROR, "invalid target array (NULL)");
// TODO: factorize with sqlx_remote_execute_DESTROY_many
GByteArray *req = m2v2_remote_pack_DESTROY(url, flags | M2V2_DESTROY_LOCAL);
struct gridd_client_s **clients = gridd_client_create_many(targets, req, NULL, NULL);
metautils_gba_unref(req);
req = NULL;
if (clients == NULL)
return NEWERROR(0, "Failed to create gridd clients");
gridd_clients_start(clients);
GError *err = gridd_clients_loop(clients);
for (struct gridd_client_s **p = clients; !err && p && *p ;p++) {
if (!(err = gridd_client_error(*p)))
continue;
GRID_DEBUG("Database destruction attempts failed: (%d) %s",
err->code, err->message);
if (err->code == CODE_CONTAINER_NOTFOUND || err->code == CODE_NOT_FOUND) {
g_clear_error(&err);
continue;
}
}
gridd_clients_free(clients);
return err;
}
示例2: meta2_backend_poll_service
GError*
meta2_backend_poll_service(struct meta2_backend_s *m2,
const gchar *type, struct service_info_s **si)
{
struct grid_lb_iterator_s *iter;
EXTRA_ASSERT(m2 != NULL);
EXTRA_ASSERT(type != NULL);
EXTRA_ASSERT(si != NULL);
if (!(iter = grid_lbpool_get_iterator(m2->backend.lb, type)))
return NEWERROR(CODE_SRVTYPE_NOTMANAGED, "no such service");
struct lb_next_opt_ext_s opt_ext;
memset(&opt_ext, 0, sizeof(opt_ext));
opt_ext.req.distance = 0;
opt_ext.req.max = 1;
opt_ext.req.duplicates = TRUE;
opt_ext.req.stgclass = NULL;
opt_ext.req.strict_stgclass = TRUE;
struct service_info_s **siv = NULL;
if (!grid_lb_iterator_next_set2(iter, &siv, &opt_ext))
return NEWERROR(CODE_SRVTYPE_NOTMANAGED, "no service available");
*si = service_info_dup(siv[0]);
service_info_cleanv(siv, FALSE);
return NULL;
}
示例3: _check
static GError*
_check(GList *working_m1list) {
GError *error = NULL;
if ( working_m1list ) {
working_m1list=g_list_sort(working_m1list,meta0_assign_sort_by_score);
struct meta0_assign_meta1_s *hM1 = working_m1list->data;
struct meta0_assign_meta1_s *lM1 = (g_list_last(working_m1list))->data;
guint highscore = hM1->score;
guint lowscore = lM1->score;
GRID_TRACE("check delta highscore %d ,lowscore %d",highscore,lowscore);
if ( (highscore - lowscore) < (context->avgscore * trigger_assignment )/ 100 ) {
GRID_WARN("New assign not necessary, high score %d , low score %d, average %d", highscore, lowscore, context->avgscore);
error = NEWERROR(0, "New assign not necessary");
return error;
}
}
if ( context->lastAssignTime ) {
GRID_TRACE("last time %s",g_date_time_format (context->lastAssignTime,"%Y-%m-%d %H:%M"));
GDateTime *currentTime, *ltime;
currentTime=g_date_time_new_now_local();
ltime = g_date_time_add_minutes(context->lastAssignTime,period_between_two_assign);
GRID_TRACE("currentTime :%s , last time + %d min :%s, comp :%d",g_date_time_format (currentTime,"%Y-%m-%d %H:%M"),period_between_two_assign,g_date_time_format (ltime,"%Y-%m-%d %H:%M"), g_date_time_compare(ltime,currentTime));
if (g_date_time_compare(ltime,currentTime) > 0 ) {
GRID_WARN("delay between two meta1 assign not respected. Try later. last date [%s]",g_date_time_format (context->lastAssignTime,"%Y-%m-%d %H:%M"));
error = NEWERROR(0,"delay between two meta1 assign not respected. Try later.");
return error;
}
}
return NULL;
}
示例4: org
void
org(int size, char *label, char *op, int *errorPtr)
{
int newLoc;
char backRef;
char *eval();
if (size)
NEWERROR(*errorPtr, INV_SIZE_CODE);
if (!*op) {
NEWERROR(*errorPtr, SYNTAX);
return;
}
op = eval(op, &newLoc, &backRef, errorPtr);
if (*errorPtr < SEVERE && !backRef) {
NEWERROR(*errorPtr, INV_FORWARD_REF);
} else if (*errorPtr < ERROR) {
if (isspace(*op) || !*op) {
/* Check for an odd value, adjust to one higher */
if (newLoc & 1) {
NEWERROR(*errorPtr, ODD_ADDRESS);
newLoc++;
}
loc = newLoc;
/* Define the label attached to this directive, if any */
if (*label)
define(label, loc, pass2, errorPtr);
/* Show new location counter on listing */
listLoc();
} else
NEWERROR(*errorPtr, SYNTAX);
}
}
示例5: _meta2_filter_check_ns_name
static int
_meta2_filter_check_ns_name(struct gridd_filter_ctx_s *ctx,
struct gridd_reply_ctx_s *reply, int optional)
{
(void) reply;
TRACE_FILTER();
const struct meta2_backend_s *backend = meta2_filter_ctx_get_backend(ctx);
const char *req_ns = oio_url_get(meta2_filter_ctx_get_url(ctx), OIOURL_NS);
if (!backend || !backend->ns_name[0]) {
GRID_DEBUG("Missing information for namespace checking");
meta2_filter_ctx_set_error(ctx, NEWERROR(CODE_INTERNAL_ERROR,
"Missing backend information, cannot check namespace"));
return FILTER_KO;
}
if (!req_ns) {
if (optional)
return FILTER_OK;
GRID_DEBUG("Missing namespace name in request");
meta2_filter_ctx_set_error(ctx, NEWERROR(CODE_BAD_REQUEST,
"Bad Request: Missing namespace name information"));
return FILTER_KO;
}
if (0 != g_ascii_strcasecmp(backend->ns_name, req_ns)) {
meta2_filter_ctx_set_error(ctx, NEWERROR(CODE_BAD_REQUEST,
"Request namespace [%s] does not match server namespace [%s]",
req_ns, backend->ns_name));
return FILTER_KO;
}
return FILTER_OK;
}
示例6: branch
/**********************************************************************
*
* Function branch builds the following instructions:
* BCC (BHS) BGT BLT BRA
* BCS (BLO) BHI BMI BSR
* BEQ BLE BNE BVC
* BGE BLS BPL BVS
*
***********************************************************************/
int branch(int mask, int size, opDescriptor *source, opDescriptor *dest,
int *errorPtr)
{
bool shortDisp;
int disp;
disp = source->data - loc - 2;
shortDisp = false;
if ( ((size == SHORT_SIZE) || (size == BYTE_SIZE_M)) ||
(size != LONG_SIZE && size != WORD_SIZE && source->backRef &&
disp >= -128 && disp <= 127 && disp))
shortDisp = true;
if (pass2) {
if (shortDisp) {
output((int) (mask | (disp & 0xFF)), WORD_SIZE);
loc += 2;
if (disp < -128 || disp > 127 || !disp)
NEWERROR(*errorPtr, INV_BRANCH_DISP);
} else {
output((int) (mask), WORD_SIZE);
loc += 2;
output((int) (disp), WORD_SIZE);
loc += 2;
if (disp < -32768 || disp > 32767)
NEWERROR(*errorPtr, INV_BRANCH_DISP);
}
}
else
loc += (shortDisp) ? 2 : 4;
return NORMAL;
}
示例7: gridd_client_exec_and_concat
GError *
gridd_client_exec_and_concat (const gchar *to, gdouble seconds, GByteArray *req,
GByteArray **out)
{
if (!to) {
g_byte_array_unref (req);
return NEWERROR(CODE_INTERNAL_ERROR, "No target");
}
GByteArray *tmp = NULL;
if (out)
tmp = g_byte_array_new();
struct gridd_client_s *client = gridd_client_create(to, req,
out ? tmp : NULL, out ? (client_on_reply)_cb_exec_and_concat : NULL);
g_byte_array_unref (req);
if (!client) {
if (tmp) g_byte_array_free (tmp, TRUE);
return NEWERROR(CODE_INTERNAL_ERROR, "client creation");
}
if (seconds > 0.0)
gridd_client_set_timeout (client, seconds);
GError *err = gridd_client_run (client);
gridd_client_free (client);
if (!err && out) {
*out = tmp;
tmp = NULL;
}
if (tmp)
metautils_gba_unref (tmp);
return err;
}
示例8: _poll_services
static GError*
_poll_services(struct grid_lbpool_s *lbp, const gchar *srvtype,
struct lb_next_opt_ext_s *opt_ext,
GSList **result, gboolean use_beans)
{
struct grid_lb_iterator_s *iter = NULL;
struct service_info_s **psi, **siv = NULL;
if (!lbp || !srvtype)
return NEWERROR(CODE_INTERNAL_ERROR, "Invalid parameter");
if (!(iter = grid_lbpool_get_iterator(lbp, srvtype)))
return NEWERROR(CODE_POLICY_NOT_SATISFIABLE, "No RAWX available");
if (!grid_lb_iterator_next_set2(iter, &siv, opt_ext))
return NEWERROR(CODE_PLATFORM_ERROR, "Cannot get services"
" list for the specified storage policy");
if (use_beans) {
for(psi=siv; *psi; ++psi)
*result = g_slist_prepend(*result, _gen_chunk_bean(*psi));
}
else {
for(psi=siv; *psi; ++psi)
*result = g_slist_prepend(*result, _gen_chunk_info(*psi));
}
service_info_cleanv(siv, FALSE);
return NULL;
}
示例9: location_from_chunk_id
static GError*
location_from_chunk_id(const gchar *chunk_id, const gchar *ns_name,
struct oio_lb_pool_s *pool, oio_location_t *location)
{
g_assert_nonnull(location);
GError *err = NULL;
if (chunk_id == NULL || strlen(chunk_id) <= 0)
return NEWERROR(CODE_INTERNAL_ERROR, "emtpy chunk id");
gchar *netloc = NULL;
oio_parse_chunk_url(chunk_id, NULL, &netloc, NULL);
if (pool) {
gchar *key = oio_make_service_key(ns_name, NAME_SRVTYPE_RAWX, netloc);
struct oio_lb_item_s *item = oio_lb_pool__get_item(pool, key);
g_free(key);
if (item) {
*location = item->location;
g_free(item);
goto out;
}
}
addr_info_t ai = {{0}};
if (!err && !grid_string_to_addrinfo(netloc, &ai))
err = NEWERROR(CODE_INTERNAL_ERROR,
"could not parse [%s] to addrinfo", netloc);
if (!err)
*location = location_from_addr_info(&ai);
out:
g_free(netloc);
return err;
}
示例10: zsocket_resolve
GError*
zsocket_resolve(const gchar *zname, int *ztype)
{
static struct named_type_s { const gchar *zname; int ztype; } defs[] = {
{"PUB", ZMQ_PUB},
{"SUB", ZMQ_SUB},
{"PUSH", ZMQ_PUSH},
{"PULL", ZMQ_PULL},
{NULL,0}
};
g_assert(zname != NULL);
g_assert(ztype != NULL);
if (!g_str_has_prefix(zname, "zmq:"))
return NEWERROR(EINVAL, "Invalid ZMQ socket type [%s]", zname);
zname += sizeof("zmq:")-1;
for (struct named_type_s *nt = defs; nt->zname ;++nt) {
if (!g_ascii_strcasecmp(zname, nt->zname)) {
*ztype = nt->ztype;
return NULL;
}
}
return NEWERROR(EINVAL, "Invalid ZMQ socket type [%s]", zname);
}
示例11: _jarray_to_beans
static GError *
_jarray_to_beans (GSList **out, struct json_object *jv, jbean_mapper map)
{
if (!json_object_is_type(jv, json_type_array))
return NEWERROR(CODE_BAD_REQUEST, "Invalid JSON, exepecting array of beans");
GSList *l = NULL;
int vlen = json_object_array_length (jv);
for (int i=0; i<vlen ;++i) {
struct json_object *j = json_object_array_get_idx (jv, i);
if (!json_object_is_type (j, json_type_object))
return NEWERROR(CODE_BAD_REQUEST, "Invalid JSON for a bean");
gpointer bean = NULL;
GError *err = map(j, &bean);
EXTRA_ASSERT((bean != NULL) ^ (err != NULL));
if (err) {
_bean_cleanl2 (l);
return err;
}
l = g_slist_prepend(l, bean);
}
*out = g_slist_reverse (l);
return NULL;
}
示例12: action_dir_srv_unlink
enum http_rc_e
action_dir_srv_unlink (struct req_args_s *args)
{
const gchar *type = TYPE();
if (!type)
return _reply_format_error (args, NEWERROR( CODE_BAD_REQUEST, "No service type provided"));
GError *hook (const gchar * m1) {
struct addr_info_s m1a;
if (!grid_string_to_addrinfo (m1, NULL, &m1a))
return NEWERROR (CODE_NETWORK_ERROR, "Invalid M1 address");
GError *err = NULL;
meta1v2_remote_unlink_service (&m1a, &err, args->url, type);
return err;
}
GError *err = _m1_locate_and_action (args, hook);
if (!err || CODE_IS_NETWORK_ERROR(err->code)) {
/* Also decache on timeout, a majority of request succeed,
* and it will probably silently succeed */
hc_decache_reference_service (resolver, args->url, type);
}
if (!err)
return _reply_success_json (args, NULL);
return _reply_common_error (args, err);
}
示例13: _body_parse_error
static GError *
_body_parse_error (GString *b)
{
g_assert (b != NULL);
struct json_tokener *tok = json_tokener_new ();
struct json_object *jbody = json_tokener_parse_ex (tok, b->str, b->len);
json_tokener_free (tok);
tok = NULL;
if (!jbody)
return NEWERROR(0, "No error explained");
struct json_object *jcode, *jmsg;
struct oio_ext_json_mapping_s map[] = {
{"status", &jcode, json_type_int, 0},
{"message", &jmsg, json_type_string, 0},
{NULL, NULL, 0, 0}
};
GError *err = oio_ext_extract_json(jbody, map);
if (!err) {
int code = 0;
const char *msg = "Unknown error";
if (jcode) code = json_object_get_int64 (jcode);
if (jmsg) msg = json_object_get_string (jmsg);
err = NEWERROR(code, "(code=%d) %s", code, msg);
}
json_object_put (jbody);
return err;
}
示例14: _connect
static int
_connect(const gchar *url, GError **err)
{
struct addr_info_s ai;
memset(&ai, 0, sizeof(ai));
if (!grid_string_to_addrinfo(url, NULL, &ai)) {
*err = NEWERROR(EINVAL, "invalid URL");
return -1;
}
if (!ai.port) {
*err = NEWERROR(EINVAL, "no port");
return -1;
}
int fd = addrinfo_connect_nopoll(&ai, 1000, err);
if (0 > fd)
return -1;
sock_set_linger_default(fd);
sock_set_nodelay(fd, TRUE);
sock_set_tcpquickack(fd, TRUE);
*err = NULL;
return fd;
}
示例15: sqlx_cache_unlock_and_close_base
GError *
sqlx_cache_unlock_and_close_base(sqlx_cache_t *cache, gint bd, gboolean force)
{
GError *err = NULL;
GRID_TRACE2("%s(%p,%d,%d)", __FUNCTION__, (void*)cache, bd, force);
EXTRA_ASSERT(cache != NULL);
if (base_id_out(cache, bd))
return NEWERROR(CODE_INTERNAL_ERROR, "invalid base id=%d", bd);
g_mutex_lock(&cache->lock);
cache->used = TRUE;
sqlx_base_t *base; base = GET(cache,bd);
switch (base->status) {
case SQLX_BASE_FREE:
EXTRA_ASSERT(base->count_open == 0);
EXTRA_ASSERT(base->owner == NULL);
err = NEWERROR(CODE_INTERNAL_ERROR, "base not used");
break;
case SQLX_BASE_IDLE:
case SQLX_BASE_IDLE_HOT:
EXTRA_ASSERT(base->count_open == 0);
EXTRA_ASSERT(base->owner == NULL);
err = NEWERROR(CODE_INTERNAL_ERROR, "base closed");
break;
case SQLX_BASE_USED:
EXTRA_ASSERT(base->count_open > 0);
// held by the current thread
if (!(-- base->count_open)) { // to be closed
if (force) {
_expire_base(cache, base);
} else {
sqlx_base_debug("CLOSING", base);
base->owner = NULL;
if (base->heat >= cache->heat_threshold)
sqlx_base_move_to_list(cache, base, SQLX_BASE_IDLE_HOT);
else
sqlx_base_move_to_list(cache, base, SQLX_BASE_IDLE);
}
}
break;
case SQLX_BASE_CLOSING:
EXTRA_ASSERT(base->owner != NULL);
EXTRA_ASSERT(base->owner != g_thread_self());
err = NEWERROR(CODE_INTERNAL_ERROR, "base being closed");
break;
}
if (base && !err)
sqlx_base_debug(__FUNCTION__, base);
g_cond_signal(base->cond);
g_mutex_unlock(&cache->lock);
return err;
}