static void test_nc_rpc_copy(void **state) { (void)state; struct nc_rpc *rpc = NULL; /* create copy rpc with NC_PARAMTYPE_CONST */ rpc = nc_rpc_copy(NC_DATASTORE_RUNNING, "target-url", NC_DATASTORE_RUNNING, "src-url", NC_WD_ALL, NC_PARAMTYPE_CONST); assert_non_null(rpc); check_copy(rpc, NC_DATASTORE_RUNNING, "target-url", NC_DATASTORE_RUNNING, "src-url", NC_WD_ALL); nc_rpc_free(rpc); /* create copy rpc with NC_PARAMTYPE_FREE */ char *target = strdup("target"); char *src = strdup("src"); rpc = nc_rpc_copy(NC_DATASTORE_STARTUP, target, NC_DATASTORE_RUNNING, src, NC_WD_ALL_TAG, NC_PARAMTYPE_FREE); assert_non_null(rpc); check_copy(rpc, NC_DATASTORE_STARTUP, target, NC_DATASTORE_RUNNING, src, NC_WD_ALL_TAG); nc_rpc_free(rpc); /* create copy rpc with NC_PARAMTYPE_DUP_AND_FREE */ rpc = nc_rpc_copy(NC_DATASTORE_STARTUP, "url", NC_DATASTORE_CANDIDATE, "url", NC_WD_TRIM, NC_PARAMTYPE_DUP_AND_FREE); assert_non_null(rpc); check_copy(rpc, NC_DATASTORE_STARTUP, "url", NC_DATASTORE_CANDIDATE, "url", NC_WD_TRIM); nc_rpc_free(rpc); }
/** * generic acl checking for different methods (basic set of methods supported) * returns null if no err */ static dav_error *check_methods(request_rec *r, const dav_resource *resource, davacl_dir_cfg *conf) { const dav_hooks_repository *repos = REPOS(conf); if (repos == NULL || resource == NULL) return dav_acl_privilege_error(r, "unknown", NULL); switch (r->method_number) { default: if (r->method_number == iM_ACL) { return check_acl(r, resource, conf, repos); } else if (r->method_number == iM_HEAD) { return check_get(r, resource, conf, repos); } else { TRACE(r, "Unknown methdod:%d", r->method_number); return NULL; } break; case M_PUT: return check_put(r, resource, conf, repos); case M_PROPPATCH: return check_proppatch(r, resource, conf, repos); case M_MKCOL: return check_mkcol(r, resource, conf, repos); case M_PROPFIND: /* done with individual properties within dav_get_props() and * dav_get_allprops */ return NULL; case M_DELETE: return check_delete(r, resource, conf, repos); case M_OPTIONS: case M_GET: return check_get(r, resource, conf, repos); case M_COPY: return check_copy(r, resource, conf, repos); case M_MOVE: return check_move(r, resource, conf, repos); case M_LOCK: return check_lock(r, resource, conf, repos); case M_UNLOCK: return check_unlock(r, resource, conf, repos); } }
int main(void) { int *src, *dst; int firstrow = 0, lastrow = 10; int i, r, c; for (i = 0; i < LARGE_SIZE * LARGE_SIZE; i++) large_mat[i] = i; src = &large_mat[(ROW_START + firstrow) * LARGE_SIZE + COL_START]; dst = &small_mat[firstrow * SMALL_SIZE]; copy_data(dst, src, SMALL_SIZE, LARGE_SIZE, lastrow - firstrow); for (r = firstrow; r < lastrow; r++) { printf("Scanning row %d (src: %p, dst: %p)\n", r, &large_mat[(ROW_START + r) * LARGE_SIZE + COL_START], &small_mat[r * SMALL_SIZE]); for (c = 0; c < SMALL_SIZE; c++) check_copy(r, c); } }
/* * backup -- * Periodically do a backup and verify it. */ void * backup(void *arg) { WT_CONNECTION *conn; WT_CURSOR *backup_cursor; WT_SESSION *session; u_int period; int ret; const char *key; (void)(arg); conn = g.wts_conn; /* Backups aren't supported for non-standard data sources. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) return (NULL); /* Open a session. */ if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); /* * Perform a backup at somewhere under 10 seconds (so we get at * least one done), and then at 45 second intervals. */ for (period = mmrand(NULL, 1, 10);; period = 45) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.workers_finished) { --period; sleep(1); } if (g.workers_finished) break; /* Lock out named checkpoints */ if ((ret = pthread_rwlock_wrlock(&g.backup_lock)) != 0) die(ret, "pthread_rwlock_wrlock: backup lock"); /* Re-create the backup directory. */ if ((ret = system(g.home_backup_init)) != 0) die(ret, "backup directory creation failed"); /* * open_cursor can return EBUSY if a metadata operation is * currently happening - retry in that case. */ while ((ret = session->open_cursor(session, "backup:", NULL, NULL, &backup_cursor)) == EBUSY) sleep(1); if (ret != 0) die(ret, "session.open_cursor: backup"); while ((ret = backup_cursor->next(backup_cursor)) == 0) { if ((ret = backup_cursor->get_key(backup_cursor, &key)) != 0) die(ret, "cursor.get_key"); copy_file(key); } if ((ret = backup_cursor->close(backup_cursor)) != 0) die(ret, "cursor.close"); if ((ret = pthread_rwlock_unlock(&g.backup_lock)) != 0) die(ret, "pthread_rwlock_unlock: backup lock"); check_copy(); } if ((ret = session->close(session, NULL)) != 0) die(ret, "session.close"); return (NULL); }
/* * hot_backup -- * Periodically do a hot backup and verify it. */ void * hot_backup(void *arg) { WT_CONNECTION *conn; WT_CURSOR *backup_cursor; WT_SESSION *session; u_int period; int ret; const char *key; (void)arg; /* If hot backups aren't configured, we're done. */ if (!g.c_hot_backups) return (NULL); /* Hot backups aren't supported for non-standard data sources. */ if (DATASOURCE("kvsbdb") || DATASOURCE("memrata")) return (NULL); conn = g.wts_conn; /* Open a session. */ if ((ret = conn->open_session( conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); /* * Perform a hot backup at somewhere under 10 seconds (so we get at * least one done), and then at 45 second intervals. */ for (period = MMRAND(1, 10);; period = 45) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.threads_finished) { --period; sleep(1); } if (g.threads_finished) break; /* Lock out named checkpoints */ if ((ret = pthread_rwlock_wrlock(&g.backup_lock)) != 0) die(ret, "pthread_rwlock_wrlock: hot-backup lock"); /* Re-create the backup directory. */ (void)system("cd RUNDIR && rm -rf BACKUP"); if (mkdir(RUNDIR_BACKUP, 0777) != 0) die(errno, "mkdir: %s", RUNDIR_BACKUP); /* * open_cursor can return EBUSY if a metadata operation is * currently happening - retry in that case. */ while ((ret = session->open_cursor(session, "backup:", NULL, NULL, &backup_cursor)) == EBUSY) sleep(1); if (ret != 0) die(ret, "session.open_cursor: backup"); while ((ret = backup_cursor->next(backup_cursor)) == 0) { if ((ret = backup_cursor->get_key(backup_cursor, &key)) != 0) die(ret, "cursor.get_key"); hot_copy(key); } if ((ret = backup_cursor->close(backup_cursor)) != 0) die(ret, "cursor.close"); if ((ret = pthread_rwlock_unlock(&g.backup_lock)) != 0) die(ret, "pthread_rwlock_unlock: hot-backup lock"); check_copy(); } if ((ret = session->close(session, NULL)) != 0) die(ret, "session.close"); return (NULL); }
/* * backup -- * Periodically do a backup and verify it. */ void * backup(void *arg) { WT_CONNECTION *conn; WT_CURSOR *backup_cursor; WT_DECL_RET; WT_SESSION *session; u_int incremental, period; bool full; const char *config, *key; (void)(arg); conn = g.wts_conn; /* Backups aren't supported for non-standard data sources. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) return (NULL); /* Open a session. */ testutil_check(conn->open_session(conn, NULL, NULL, &session)); /* * Perform a full backup at somewhere under 10 seconds (that way there's * at least one), then at larger intervals, optionally do incremental * backups between full backups. */ incremental = 0; for (period = mmrand(NULL, 1, 10);; period = mmrand(NULL, 20, 45)) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.workers_finished) { --period; sleep(1); } /* * We can't drop named checkpoints while there's a backup in * progress, serialize backups with named checkpoints. Wait * for the checkpoint to complete, otherwise backups might be * starved out. */ testutil_check(pthread_rwlock_wrlock(&g.backup_lock)); if (g.workers_finished) { testutil_check(pthread_rwlock_unlock(&g.backup_lock)); break; } if (incremental) { config = "target=(\"log:\")"; full = false; } else { /* Re-create the backup directory. */ testutil_checkfmt( system(g.home_backup_init), "%s", "backup directory creation failed"); config = NULL; full = true; } /* * open_cursor can return EBUSY if concurrent with a metadata * operation, retry in that case. */ while ((ret = session->open_cursor( session, "backup:", NULL, config, &backup_cursor)) == EBUSY) __wt_yield(); if (ret != 0) testutil_die(ret, "session.open_cursor: backup"); while ((ret = backup_cursor->next(backup_cursor)) == 0) { testutil_check( backup_cursor->get_key(backup_cursor, &key)); copy_file(session, key); } if (ret != WT_NOTFOUND) testutil_die(ret, "backup-cursor"); /* After an incremental backup, truncate the log files. */ if (incremental) testutil_check(session->truncate( session, "log:", backup_cursor, NULL, NULL)); testutil_check(backup_cursor->close(backup_cursor)); testutil_check(pthread_rwlock_unlock(&g.backup_lock)); /* * If automatic log archival isn't configured, optionally do * incremental backups after each full backup. If we're not * doing any more incrementals, verify the backup (we can't * verify intermediate states, once we perform recovery on the * backup database, we can't do any more incremental backups). */ if (full) incremental = g.c_logging_archive ? 1 : mmrand(NULL, 1, 5); if (--incremental == 0) check_copy(); } if (incremental != 0) check_copy(); testutil_check(session->close(session, NULL)); return (NULL); }