static void _manage_prefix(struct meta1_backend_s *m1, guint8 *prefix, sqlite3 *tmpdb) { gchar sql[LIMIT_LENGTH_NSNAME + 128]; int cb(void * u, int nbcols, char **vals, char **cols) { char *err_msg2 = NULL; (void) u; (void) nbcols; (void) cols; memset(sql, 0, sizeof(sql)); g_snprintf(sql, sizeof(sql), "UPDATE vns SET size = size + %s " "WHERE vns = '%s'", vals[1], vals[0]); GRID_TRACE("_manage_prefix executing [%s]", sql); if (sqlite3_exec(tmpdb, sql, NULL, NULL, &err_msg2) != SQLITE_OK) { GRID_WARN("Could not update size for VNS %s: %s", vals[0], err_msg2); } sqlite3_free(err_msg2); err_msg2 = NULL; if (!sqlite3_changes(tmpdb)) { /* VNS not found */ g_snprintf(sql, sizeof(sql), "INSERT INTO vns (vns,size) " "VALUES ('%s',%s)", vals[0], vals[1]); GRID_TRACE("_manage_prefix VNS not found, executing [%s]", sql); if (sqlite3_exec(tmpdb, sql, NULL, NULL, &err_msg2) != SQLITE_OK) { GRID_WARN("Could not set size for VNS %s: %s", vals[0], err_msg2); } sqlite3_free(err_msg2); } return 0; }
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; }
static void _task_reconfigure_events (gpointer p) { if (!grid_main_is_running ()) return; if (!p || !PSRV(p)->events_queue) return; struct namespace_info_s *ni = PSRV(p)->nsinfo; if (!ni || !ni->options) return; gint64 i64 = OIO_EVTQ_MAXPENDING; gchar *k; /* without the prefix */ i64 = gridcluster_get_nsinfo_int64 (ni, OIO_CFG_EVTQ_MAXPENDING, i64); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, OIO_CFG_EVTQ_MAXPENDING, i64); /* with the prefix */ k = g_strconcat (PSRV(p)->service_config->srvtype, ".", OIO_CFG_EVTQ_MAXPENDING, NULL); i64 = gridcluster_get_nsinfo_int64 (ni, k, i64); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, k, i64); g_free(k); if (i64 >= 0 && i64 < G_MAXUINT) { guint u = (guint) i64; oio_events_queue__set_max_pending (PSRV(p)->events_queue, u); } }
static int grid_get_geometry(grid_t* grid, MC_GGEOMETRY* geom) { GRID_TRACE("grid_get_geometry(%p, %p)", grid, geom); if(MC_ERR((geom->fMask & ~GRID_GGF_ALL) != 0)) { MC_TRACE("grid_get_geometry: fMask has some unsupported bit(s)"); SetLastError(ERROR_INVALID_PARAMETER); return -1; } if(geom->fMask & MC_GGF_COLUMNHEADERHEIGHT) geom->wColumnHeaderHeight = grid->header_height; if(geom->fMask & MC_GGF_ROWHEADERWIDTH) geom->wRowHeaderWidth = grid->header_width; if(geom->fMask & MC_GGF_DEFCOLUMNWIDTH) geom->wDefColumnWidth = grid->def_col_width; if(geom->fMask & MC_GGF_DEFROWHEIGHT) geom->wDefRowHeight = grid->def_row_height; if(geom->fMask & MC_GGF_PADDINGHORZ) geom->wPaddingHorz = grid->padding_h; if(geom->fMask & MC_GGF_PADDINGVERT) geom->wPaddingVert = grid->padding_v; return 0; }
static GError * __get_one_property(struct sqlx_sqlite3_s *sq3, struct oio_url_s *url, const gchar *name, GPtrArray *gpa) { GError *err = NULL; sqlite3_stmt *stmt = NULL; int rc; GRID_TRACE("%s(n=%s)", __FUNCTION__, name); sqlite3_prepare_debug(rc, sq3->db, "SELECT name,value FROM properties WHERE cid = ? AND name = ?", -1, &stmt, NULL); if (rc != SQLITE_OK && rc != SQLITE_DONE) err = M1_SQLITE_GERROR(sq3->db, rc); else { (void) sqlite3_bind_blob(stmt, 1, oio_url_get_id(url), oio_url_get_id_size(url), NULL); (void) sqlite3_bind_text(stmt, 2, name, -1, NULL); while (SQLITE_ROW == (rc = sqlite3_step(stmt))) { g_ptr_array_add(gpa, item(stmt, 0)); g_ptr_array_add(gpa, item(stmt, 1)); } if (rc != SQLITE_OK && rc != SQLITE_DONE) err = M1_SQLITE_GERROR(sq3->db, rc); sqlite3_finalize_debug(rc, stmt); } return err; }
void grid_changed_n_nodes() { int per[3] = { 1, 1, 1 }; GRID_TRACE(fprintf(stderr,"%d: grid_changed_n_nodes:\n",this_node)); MPI_Comm_free(&comm_cart); MPI_Cart_create(MPI_COMM_WORLD, 3, node_grid, per, 0, &comm_cart); MPI_Comm_rank(comm_cart, &this_node); MPI_Cart_coords(comm_cart, this_node, 3, node_pos); calc_node_neighbors(this_node); #ifdef GRID_DEBUG fprintf(stderr,"%d: node_pos=(%d,%d,%d)\n",this_node,node_pos[0],node_pos[1],node_pos[2]); fprintf(stderr,"%d: node_neighbors=(%d,%d,%d,%d,%d,%d)\n",this_node, node_neighbors[0],node_neighbors[1],node_neighbors[2], node_neighbors[3],node_neighbors[4],node_neighbors[5]); fprintf(stderr,"%d: boundary=(%d,%d,%d,%d,%d,%d)\n",this_node, boundary[0],boundary[1],boundary[2],boundary[3],boundary[4],boundary[5]); #endif grid_changed_box_l(); }
static void _task_reconfigure_events (gpointer p) { if (!grid_main_is_running ()) return; if (!p || !PSRV(p)->events_queue) return; struct namespace_info_s *ni = PSRV(p)->nsinfo; if (!ni || !ni->options) return; gint64 i64 = namespace_info_get_srv_param_i64(ni, NULL, PSRV(p)->service_config->srvtype, OIO_CFG_EVTQ_MAXPENDING, OIO_EVTQ_MAXPENDING); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, OIO_CFG_EVTQ_MAXPENDING, i64); if (i64 >= 0 && i64 < G_MAXUINT) { guint u = (guint) i64; oio_events_queue__set_max_pending (PSRV(p)->events_queue, u); } i64 = namespace_info_get_srv_param_i64(ni, NULL, PSRV(p)->service_config->srvtype, OIO_CFG_EVTQ_BUFFER_DELAY, OIO_EVTQ_BUFFER_DELAY); if (i64 >= 0 && i64 < 3600) { oio_events_queue__set_buffering(PSRV(p)->events_queue, i64 * G_TIME_SPAN_SECOND); } }
static int grid_resize_table(grid_t* grid, WORD col_count, WORD row_count) { GRID_TRACE("grid_resize_table(%d, %d)", (int) col_count, (int) row_count); if(grid->table != 0) { if(MC_ERR(table_resize(grid->table, col_count, row_count) != 0)) { MC_TRACE("grid_resize_table: table_resize() failed."); return -1; } } else { if(grid->col_widths != NULL) grid_alloc_col_widths(grid, grid->col_count, col_count, TRUE); if(grid->row_heights) grid_alloc_row_heights(grid, grid->row_count, row_count, TRUE); grid->col_count = col_count; grid->row_count = row_count; if(!grid->no_redraw) { InvalidateRect(grid->win, NULL, TRUE); grid_setup_scrollbars(grid, TRUE); } } return 0; }
static GError* _open_and_lock(struct meta0_backend_s *m0, enum m0v2_open_type_e how, struct sqlx_sqlite3_s **handle) { GError *err = NULL; EXTRA_ASSERT(m0 != NULL); EXTRA_ASSERT(handle != NULL); /* Now open/lock the base in a way suitable for our op */ guint flag = m0_to_sqlx(how); struct sqlx_name_s n = {.base=m0->ns, .type=NAME_SRVTYPE_META0, .ns=m0->ns}; err = sqlx_repository_open_and_lock(m0->repository, &n, flag, handle, NULL); if (err != NULL) { if (!CODE_IS_REDIRECT(err->code)) g_prefix_error(&err, "Open/Lock error: "); return err; } EXTRA_ASSERT(*handle != NULL); GRID_TRACE("Opened and locked [%s/%s]", m0->id, NAME_SRVTYPE_META0); return NULL; } static void _unlock_and_close(struct sqlx_sqlite3_s *sq3) { EXTRA_ASSERT(sq3 != NULL); sqlx_admin_save_lazy (sq3); sqlx_repository_unlock_and_close_noerror(sq3); }
void calc_node_neighbors(int node) { int dir; map_node_array(node,node_pos); for(dir=0;dir<3;dir++) { int buf; MPI_Cart_shift(comm_cart, dir, -1, &buf, node_neighbors + 2*dir); MPI_Cart_shift(comm_cart, dir, 1, &buf, node_neighbors + 2*dir + 1); /* left boundary ? */ if (node_pos[dir] == 0) { boundary[2*dir] = 1; } else { boundary[2*dir] = 0; } /* right boundary ? */ if (node_pos[dir] == node_grid[dir]-1) { boundary[2*dir+1] = -1; } else { boundary[2*dir+1] = 0; } } GRID_TRACE(printf("%d: node_grid %d %d %d, pos %d %d %d, node_neighbors ", this_node, node_grid[0], node_grid[1], node_grid[2], node_pos[0], node_pos[1], node_pos[2])); }
static GError * __replace_property(struct sqlx_sqlite3_s *sq3, struct oio_url_s *url, const gchar *name, const gchar *value) { GError *err = NULL; gint rc; sqlite3_stmt *stmt = NULL; EXTRA_ASSERT(name != NULL && *name != '\0'); EXTRA_ASSERT(value != NULL && *value != '\0'); GRID_TRACE("%s(n=%s,v=%s)", __FUNCTION__, name, value); sqlite3_prepare_debug(rc, sq3->db, "REPLACE INTO properties (name,value,cid) VALUES (?,?,?)", -1, &stmt, NULL); if (rc != SQLITE_OK && rc != SQLITE_DONE) err = M1_SQLITE_GERROR(sq3->db, rc); else { (void) sqlite3_bind_text(stmt, 1, name, -1, NULL); (void) sqlite3_bind_text(stmt, 2, value, -1, NULL); (void) sqlite3_bind_blob(stmt, 3, oio_url_get_id(url), oio_url_get_id_size(url), NULL); sqlite3_step_debug_until_end (rc, stmt); if (rc != SQLITE_DONE && rc != SQLITE_OK) err = M1_SQLITE_GERROR(sq3->db, rc); sqlite3_finalize_debug(rc, stmt); } return err; }
static struct meta0_assign_meta1_s* _select_source_assign_m1(GList *lst, guint8 *treat_prefixes, const guint avgscore) { if (lst == NULL ) return NULL; struct meta0_assign_meta1_s *aM1 =(g_list_first(lst))->data; if (aM1->score <= avgscore) return NULL; // check current prefix GArray *prefixes = aM1->assignPrefixes; if (prefixes) { if (!_select_prefix(prefixes,treat_prefixes)) { aM1->available=FALSE; aM1->assignPrefixes=NULL; } } else { aM1->available=FALSE; } if (!aM1->available) { lst=g_list_delete_link(lst,lst); return _select_source_assign_m1(lst, treat_prefixes,avgscore); } GRID_TRACE("select source meta1 %s, score %d",aM1->addr,aM1->score); return aM1; }
static gboolean _select_prefix(GArray *prefixes, guint8 *treat_prefixes) { if (!prefixes) { return FALSE; } if ( prefixes->len != 0 ) { guint8 *prefix = (guint8 *)prefixes->data; if(!_is_treat_prefix(treat_prefixes,prefix)) { GRID_TRACE("select prefix %02X%02X ",prefix[0],prefix[1]); return TRUE; } prefixes=g_array_remove_index(prefixes,0); if ( prefixes->len != 0 ) { return _select_prefix(prefixes,treat_prefixes); } } g_array_free(prefixes,TRUE); prefixes=NULL; return FALSE; }
static GError * _reload(struct meta0_backend_s *m0, gboolean lazy) { GError *err = NULL; EXTRA_ASSERT(m0 != NULL); GRID_TRACE("%s(%p,lazy=%d)", __FUNCTION__, m0, lazy); g_rw_lock_writer_lock(&(m0->rwlock)); if (!lazy || m0->reload_requested || !m0->array_by_prefix || !m0->array_meta1_ref) { if (m0->array_by_prefix) { meta0_utils_array_clean(m0->array_by_prefix); m0->array_by_prefix = NULL; } if (m0->array_meta1_ref) { meta0_utils_array_meta1ref_clean(m0->array_meta1_ref); m0->array_meta1_ref = NULL; } err = _load(m0); m0->reload_requested = FALSE; if (NULL != err) g_prefix_error(&err, "Loading error: "); } g_rw_lock_writer_unlock(&(m0->rwlock)); return err; }
static enum http_rc_e handler_action (struct http_request_s *rq, struct http_reply_ctx_s *rp) { // Get a request id for the current request const gchar *reqid = g_tree_lookup (rq->tree_headers, PROXYD_HEADER_REQID); if (reqid) oio_ext_set_reqid(reqid); else oio_ext_set_random_reqid(); // Then parse the request to find a handler struct oio_url_s *url = NULL; struct oio_requri_s ruri = {NULL, NULL, NULL, NULL}; oio_requri_parse (rq->req_uri, &ruri); struct path_matching_s **matchings = _metacd_match (rq->cmd, ruri.path); GRID_TRACE2("URI path[%s] query[%s] fragment[%s] matches[%u]", ruri.path, ruri.query, ruri.fragment, g_strv_length((gchar**)matchings)); GQuark gq_count = gq_count_unexpected; GQuark gq_time = gq_time_unexpected; enum http_rc_e rc; if (!*matchings) { rp->set_content_type ("application/json"); rp->set_body_gstr (g_string_new("{\"status\":404,\"message\":\"No handler found\"}")); rp->set_status (HTTP_CODE_NOT_FOUND, "No handler found"); rp->finalize (); rc = HTTPRC_DONE; } else { struct req_args_s args = {0}; args.req_uri = &ruri; args.matchings = matchings; args.rq = rq; args.rp = rp; args.url = url = _metacd_load_url (&args); rp->subject(oio_url_get(url, OIOURL_HEXID)); gq_count = (*matchings)->last->gq_count; gq_time = (*matchings)->last->gq_time; GRID_TRACE("%s %s URL %s", __FUNCTION__, ruri.path, oio_url_get(args.url, OIOURL_WHOLE)); req_handler_f handler = (*matchings)->last->u; rc = (*handler) (&args); } gint64 spent = oio_ext_monotonic_time () - rq->client->time.evt_in; network_server_stat_push4 (rq->client->server, TRUE, gq_count, 1, gq_count_all, 1, gq_time, spent, gq_time_all, spent); path_matching_cleanv (matchings); oio_requri_clear (&ruri); oio_url_pclean (&url); oio_ext_set_reqid (NULL); return rc; }
static void grid_notify_format(grid_t* grid) { LRESULT lres; lres = MC_SEND(grid->notify_win, WM_NOTIFYFORMAT, grid->win, NF_QUERY); grid->unicode_notifications = (lres == NFR_UNICODE ? 1 : 0); GRID_TRACE("grid_notify_format: Will use %s notifications.", grid->unicode_notifications ? "Unicode" : "ANSI"); }
void version_debug(const gchar *tag, GTree *versions) { if (!GRID_TRACE_ENABLED()) return; (void) tag; gchar *s = version_dump(versions); GRID_TRACE("%s %s (%s)", tag, s, __FUNCTION__); g_free(s); }
static void monitor_get_status(const gchar *monitor_cmd, service_info_t *si) { gchar *str_si; if (strlen(monitor_cmd) > 0) { GRID_TRACE("Collecting the service state"); parse_output(monitor_cmd, si); str_si = service_info_to_string(si); GRID_DEBUG("SVC state: %s", str_si); g_free(str_si); } }
void grid_changed_box_l() { int i; GRID_TRACE(fprintf(stderr,"%d: grid_changed_box_l:\n",this_node)); GRID_TRACE(fprintf(stderr,"%d: node_pos %d %d %d\n", this_node, node_pos[0], node_pos[1], node_pos[2])); GRID_TRACE(fprintf(stderr,"%d: node_grid %d %d %d\n", this_node, node_grid[0], node_grid[1], node_grid[2])); for(i = 0; i < 3; i++) { local_box_l[i] = box_l[i]/(double)node_grid[i]; my_left[i] = node_pos[i] *local_box_l[i]; my_right[i] = (node_pos[i]+1)*local_box_l[i]; box_l_i[i] = 1/box_l[i]; } calc_minimal_box_dimensions(); #ifdef GRID_DEBUG fprintf(stderr,"%d: local_box_l = (%.3f, %.3f, %.3f)\n",this_node, local_box_l[0],local_box_l[1],local_box_l[2]); fprintf(stderr,"%d: coordinates: x in [%.3f, %.3f], y in [%.3f, %.3f], z in [%.3f, %.3f]\n",this_node, my_left[0],my_right[0],my_left[1],my_right[1],my_left[2],my_right[2]); #endif }
/* Test if a list has one and only one element */ gboolean _has_only_one_element(gpointer k, gpointer v, gpointer d) { (void) d; GSList *chunk_list = (GSList *) v; guint length = g_slist_length(chunk_list); if (GRID_DEBUG_ENABLED()) { GString *hash_str = metautils_gba_to_hexgstr(NULL, (GByteArray *) k); if (length == 1) { GRID_TRACE("Removing bean of hash '%s' from hash table", hash_str->str); } else { GRID_DEBUG("Found % 4d beans with hash '%s'", length, hash_str->str); } g_string_free(hash_str, TRUE); } return (length == 1); }
void data_slab_sequence_trace(struct data_slab_sequence_s *dss) { struct data_slab_s *s; if (!GRID_TRACE_ENABLED()) return; GRID_TRACE(" DSS %p -> %p", dss->first, dss->last); for (s = dss->first; s ;) { data_slab_trace("SLAB", s); if (s == dss->last) break; s = s->next; } }
void http_put_feed (struct http_put_s *p, GBytes *b) { g_assert (p != NULL); g_assert (b != NULL); gssize len = g_bytes_get_size (b); GRID_TRACE("%s (%p) <- %"G_GSIZE_FORMAT, __FUNCTION__, p, len); g_assert (len <= 0 || p->remaining_length < 0 || len <= p->remaining_length); g_queue_push_tail (p->buffer_tail, b); if (!len) { /* marker for end of stream */ p->remaining_length = 0; } else { p->remaining_length -= len; } }
static gboolean _ne_request(const char *host, int port, const char *target, const char *method, GSList *headers, GError **err) { GRID_TRACE("%s", __FUNCTION__); gboolean result = FALSE; ne_session* session = ne_session_create("http", host, port); ne_set_connect_timeout(session, 10); ne_set_read_timeout(session, 30); GRID_DEBUG("%s http://%s:%d%s", method, host, port, target); ne_request* req = ne_request_create(session, method, target); if (NULL != req) { for (GSList *l = headers; l; l = l->next) { gchar **toks = g_strsplit(l->data, ":", 2); ne_add_request_header(req, toks[0], toks[1]); g_strfreev(toks); } switch (ne_request_dispatch(req)) { case NE_OK: if (ne_get_status(req)->klass != 2) { *err = NEWERROR(0, "cannot %s '%s' (%s)", method, target, ne_get_error(session)); } else { result = TRUE; } break; case NE_AUTH: case NE_CONNECT: case NE_TIMEOUT: case NE_ERROR: default: *err = NEWERROR(0, "unexpected error from the WebDAV server (%s)", ne_get_error(session)); break; } ne_request_destroy(req); } else { // This should be an assertion *err = NEWERROR(0, "Failed to create request"); } ne_session_destroy (session); return result; }
static gboolean _configure_backend(struct sqlx_service_s *ss) { struct sqlx_repo_config_s repository_config = {0}; repository_config.flags = 0; repository_config.flags |= ss->flag_delete_on ? SQLX_REPO_DELETEON : 0; repository_config.flags |= ss->flag_cached_bases ? 0 : SQLX_REPO_NOCACHE; repository_config.flags |= ss->flag_autocreate ? SQLX_REPO_AUTOCREATE : 0; repository_config.sync_solo = ss->sync_mode_solo; repository_config.sync_repli = ss->sync_mode_repli; repository_config.page_size = SQLX_DEFAULT_PAGE_SIZE; if (ss->cfg_page_size >= 512) repository_config.page_size = ss->cfg_page_size; GError *err = sqlx_repository_init(ss->volume, &repository_config, &ss->repository); if (err) { GRID_ERROR("SQLX repository init failure : (%d) %s", err->code, err->message); g_clear_error(&err); return FALSE; } err = sqlx_repository_configure_type(ss->repository, ss->service_config->srvtype, ss->service_config->schema); if (err) { GRID_ERROR("SQLX schema init failure : (%d) %s", err->code, err->message); g_clear_error(&err); return FALSE; } sqlx_repository_configure_open_timeout (ss->repository, ss->open_timeout * G_TIME_SPAN_MILLISECOND); sqlx_repository_configure_hash (ss->repository, ss->service_config->repo_hash_width, ss->service_config->repo_hash_depth); GRID_TRACE("SQLX repository initiated"); return TRUE; }
GError * oio_sqlx_client__execute_statement (struct oio_sqlx_client_s *self, const char *in_stmt, gchar **in_params, struct oio_sqlx_output_ctx_s *out_ctx, gchar ***out_lines) { GError *err = NULL; struct oio_sqlx_batch_s *batch = NULL; struct oio_sqlx_batch_result_s *result = NULL; GRID_TRACE("%s (%p, %s)", __FUNCTION__, self, in_stmt); (void) oio_sqlx_client_factory__batch (NULL, &batch); oio_sqlx_batch__add (batch, in_stmt, in_params); err = oio_sqlx_client__execute_batch (self, batch, &result); oio_sqlx_batch__destroy (batch); if (err) { g_assert (result == NULL); return err; } g_assert (result != NULL); guint count = oio_sqlx_batch_result__count_statements (result); g_assert (count == 1); guint count_lines = 0; err = oio_sqlx_batch_result__get_statement (result, 0, &count_lines, out_ctx); if (!err && out_lines) { GPtrArray *tmp = g_ptr_array_new (); for (guint i=0; i<count_lines ;++i) { gchar **fields = oio_sqlx_batch_result__get_row (result, 0, i); g_ptr_array_add (tmp, g_strjoinv (",", fields)); g_strfreev (fields); } g_ptr_array_add (tmp, NULL); *out_lines = (gchar**) g_ptr_array_free (tmp, FALSE); } oio_sqlx_batch_result__destroy (result); return err; }
static void parse_chunkinfo_from_rawx(GHashTable *ht, struct content_textinfo_s *content, struct chunk_textinfo_s *chunk) { GHashTableIter iterator; gpointer key, value; g_hash_table_iter_init(&iterator, ht); while (g_hash_table_iter_next(&iterator, &key, &value)) { GRID_TRACE("key (%s) / value (%s)", (gchar*)key, (gchar*)value); if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CHUNK_ID, key)) chunk->id = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CHUNK_SIZE, key)) chunk->size = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CHUNK_HASH, key)) chunk->hash = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CHUNK_POS, key)) chunk->position = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CHUNK_METADATA, key)) chunk->metadata = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CONTENT_PATH, key)) { chunk->path = g_strdup(value); content->path = g_strdup(value); } else if (0 == g_ascii_strcasecmp(RAWXATTR_FROM_HEAD_CONTENT_CONTAINERID, key)) { chunk->container_id = g_strdup(value); content->container_id = g_strdup(value); } else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CONTENT_SIZE, key)) content->size = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_FROM_HEAD_CONTENT_CHUNKSNB, key)) content->chunk_nb = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_NAME_CONTENT_METADATA, key)) content->metadata = g_strdup(value); else if (0 == g_ascii_strcasecmp(RAWXATTR_FROM_HEAD_CONTENT_METADATA_SYS, key)) content->system_metadata = g_strdup(value); } }
GError* compound_type_parse(struct compound_type_s *ct, const gchar *srvtype) { EXTRA_ASSERT(ct != NULL); memset(ct, 0, sizeof(struct compound_type_s)); if (!srvtype || !*srvtype || *srvtype == '.' || *srvtype == ';') return NEWERROR(CODE_BAD_REQUEST, "Bad service type [%s]", srvtype); ct->fulltype = srvtype; gchar **tokens = g_strsplit(srvtype, ";", 2); _parse_type(ct, tokens[0]); _parse_args(ct, tokens[1]); g_free(tokens); GRID_TRACE("CT full[%s] type[%s] bare[%s] sub[%s] args[%s|%s]", ct->fulltype, ct->type, ct->baretype, ct->subtype, ct->req.k, ct->req.v); return NULL; }
static int _send (int fd, struct iovec *iov, unsigned int iovcount) { int w; retry: w = writev (fd, iov, iovcount); if (w < 0) { if (errno == EINTR) goto retry; if (errno == EAGAIN || errno == EWOULDBLOCK) { struct pollfd pfd = {0}; pfd.fd = fd; pfd.events = POLLOUT; metautils_syscall_poll (&pfd, 1, 1000); goto retry; } GRID_WARN("BEANSTALKD failed to put: [errno=%d] %s", errno, strerror(errno)); return 0; } while (w > 0 && iovcount > 0) { if (iov[0].iov_len <= (size_t)w) { w -= iov[0].iov_len; iov[0].iov_len = 0; iov ++; iovcount --; } else { iov[0].iov_len -= w; w = 0; } } if (iovcount > 0) goto retry; GRID_TRACE("BEANSTALKD put sent!"); return 1; }
static int grid_set_geometry(grid_t* grid, MC_GGEOMETRY* geom, BOOL invalidate) { GRID_TRACE("grid_set_geometry(%p, %p, %d)", grid, geom, (int)invalidate); if(geom != NULL) { if(geom->fMask & MC_GGF_COLUMNHEADERHEIGHT) grid->header_height = geom->wColumnHeaderHeight; if(geom->fMask & MC_GGF_ROWHEADERWIDTH) grid->header_width = geom->wRowHeaderWidth; if(geom->fMask & MC_GGF_DEFCOLUMNWIDTH) grid->def_col_width = geom->wDefColumnWidth; if(geom->fMask & MC_GGF_DEFROWHEIGHT) grid->def_row_height = geom->wDefRowHeight; if(geom->fMask & MC_GGF_PADDINGHORZ) grid->padding_h = geom->wPaddingHorz; if(geom->fMask & MC_GGF_PADDINGVERT) grid->padding_v = geom->wPaddingVert; } else { SIZE font_size; mc_font_size(NULL, &font_size, TRUE); grid->padding_h = CELL_DEF_PADDING_H; grid->padding_v = CELL_DEF_PADDING_V; grid->header_width = 6 * font_size.cx + 2 * grid->padding_h; grid->header_height = font_size.cy + 2 * grid->padding_v; grid->def_col_width = 8 * font_size.cx + 2 * grid->padding_h; grid->def_row_height = font_size.cy + 2 * grid->padding_v; } grid_setup_scrollbars(grid, TRUE); if(invalidate && !grid->no_redraw) InvalidateRect(grid->win, NULL, TRUE); return 0; }
static gboolean _get_attr_from_handle(struct attr_handle_s *attr_handle, GError ** error, const char *domain, const char *attrname, gchar **result) { char key[ATTR_NAME_MAX_LENGTH], *value; if (!attr_handle || !domain || !attrname || !result) { SETERRCODE(error, EINVAL, "Invalid argument (%p %p %p %p)", attr_handle, domain, attrname, result); return FALSE; } g_snprintf(key, sizeof(key), "%s.%s", domain, attrname); value = g_hash_table_lookup(attr_handle->attr_hash, key); if (value) *result = g_strdup(value); else { GRID_TRACE("Attribute [%s] not found for chunk [%s]", key, attr_handle->chunk_path); *result = NULL; } return TRUE; }