| 315 | } |
| 316 | |
| 317 | void *thd(void *arg) |
| 318 | { |
| 319 | int64_t now = timems(), end = now + runtime * 1000; |
| 320 | char *readnode; |
| 321 | cdb2_hndl_tp *db; |
| 322 | int rc; |
| 323 | |
| 324 | rc = cdb2_open(&db, dbname, cltype, CDB2_RANDOM); |
| 325 | if (rc) { |
| 326 | tdprintf(stderr, db, __func__, __LINE__, "thd: open rc %d %s\n", rc, |
| 327 | cdb2_errstr(db)); |
| 328 | cdb2_close(db); |
| 329 | myexit(__func__, __LINE__, 1); |
| 330 | } |
| 331 | |
| 332 | if (is_hasql) { |
| 333 | rc = cdb2_run_statement(db, "set hasql on"); |
| 334 | if (rc) { |
| 335 | tdprintf(stderr, db, __func__, __LINE__, |
| 336 | "thd: set hasql on rc %d, %s\n", rc, cdb2_errstr(db)); |
| 337 | cdb2_close(db); |
| 338 | myexit(__func__, __LINE__, 1); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | if (debug_trace) { |
| 343 | cdb2_set_debug_trace(db); |
| 344 | } |
| 345 | |
| 346 | if (!(readnode = read_node(db))) |
| 347 | tdprintf(stderr, db, __func__, __LINE__, |
| 348 | "Couldn't determine read node for thread\n"); |
| 349 | else { |
| 350 | if (debug_trace) |
| 351 | tdprintf(stderr, db, __func__, __LINE__, "read node is %s\n", |
| 352 | readnode); |
| 353 | } |
| 354 | |
| 355 | while (now < end) { |
| 356 | insert(&db, readnode); |
| 357 | now = timems(); |
| 358 | } |
| 359 | cdb2_close(db); |
| 360 | if (readnode) free(readnode); |
| 361 | return NULL; |
| 362 | } |
| 363 | |
| 364 | void check(void) |
| 365 | { |
nothing calls this directly
no test coverage detected