MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / thd

Function thd

tests/tools/insert.c:317–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317void *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
364void check(void)
365{

Callers

nothing calls this directly

Calls 11

timemsFunction · 0.85
cdb2_openFunction · 0.85
tdprintfFunction · 0.85
cdb2_errstrFunction · 0.85
cdb2_closeFunction · 0.85
myexitFunction · 0.85
cdb2_run_statementFunction · 0.85
cdb2_set_debug_traceFunction · 0.85
read_nodeFunction · 0.85
insertFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected