Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bdb/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -8801,7 +8801,7 @@ int bdb_direct_count(bdb_cursor_ifn_t *cur, int ixnum, int64_t *rcnt, int is_sna
args[i].last_checkpoint_lsn.offset = last_checkpoint_lsn_offset;
if (parallel_count) {
args[i].sqlthd = pthread_getspecific(query_info_key);
pthread_create(&thds[i], &attr, db_count, &args[i]);
Pthread_create(&thds[i], &attr, db_count, &args[i]);
} else {
args[i].sqlthd = NULL;
db_count(&args[i]);
Expand Down
57 changes: 9 additions & 48 deletions bdb/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3078,27 +3078,11 @@ if (!is_real_netinfo(bdb_state->repinfo->netinfo))

/* create the watcher thread */
logmsg(LOGMSG_DEBUG, "creating the watcher thread\n");
rc = pthread_create(&(bdb_state->watcher_thread), &attr, watcher_thread,
Pthread_create(&(bdb_state->watcher_thread), &attr, watcher_thread,
bdb_state);
if (rc != 0) {
logmsg(LOGMSG_ERROR, "couldnt create watcher thread\n");
return NULL;
}

Pthread_attr_destroy(&attr);

if (0) {
pthread_t lwm_printer_tid;
rc = pthread_create(&lwm_printer_tid, NULL, lwm_printer_thd, bdb_state);
if (rc) {
logmsg(LOGMSG_DEBUG, "start lwm printer thread rc %d\n", rc);
return NULL;
}
}

/*sleep(2); this is not needed anymore */

/* do not proceed untill we find a master */
/* do not proceed until we find a master */
waitformaster:
while (bdb_state->repinfo->master_host == db_eid_invalid) {
logmsg(LOGMSG_WARN, "^^^^^^^^^^^^ waiting for a master...\n");
Expand Down Expand Up @@ -5508,7 +5492,7 @@ static int bdb_upgrade_downgrade_reopen_wrap(bdb_state_type *bdb_state, int op,
pthread_t tid;

/* schedule a dummy add */
pthread_create(&tid, &(bdb_state->pthread_attr_detach),
Pthread_create(&tid, &(bdb_state->pthread_attr_detach),
dummy_add_thread, bdb_state);
}

Expand Down Expand Up @@ -5627,7 +5611,7 @@ int create_master_lease_thread(bdb_state_type *bdb_state)
pthread_attr_t attr;
Pthread_attr_init(&attr);
Pthread_attr_setstacksize(&attr, 128 * 1024);
pthread_create(&tid, &attr, master_lease_thread, bdb_state);
Pthread_create(&tid, &attr, master_lease_thread, bdb_state);
Pthread_attr_destroy(&attr);
return 0;
}
Expand All @@ -5638,7 +5622,7 @@ void create_coherency_lease_thread(bdb_state_type *bdb_state)
pthread_attr_t attr;
Pthread_attr_init(&attr);
Pthread_attr_setstacksize(&attr, 128 * 1024);
pthread_create(&tid, &attr, coherency_lease_thread, bdb_state);
Pthread_create(&tid, &attr, coherency_lease_thread, bdb_state);
Pthread_attr_destroy(&attr);
}

Expand Down Expand Up @@ -6018,38 +6002,22 @@ static bdb_state_type *bdb_open_int(int envonly, const char name[], const char d
log files to the database files, allowing us to remove
log files.
*/
rc = pthread_create(&(bdb_state->checkpoint_thread), &attr,
Pthread_create(&(bdb_state->checkpoint_thread), &attr,
checkpoint_thread, bdb_state);
if (rc != 0) {
logmsg(LOGMSG_ERROR, "unable to create checkpoint thread - rc=%d "
"errno=%d %s\n",
rc, errno, strerror(errno));
logmsg(LOGMSG_INFO, "%s failing with bdberr_misc at line %d\n", __func__, __LINE__);
*bdberr = BDBERR_MISC;
return NULL;
}

/*
create memp_trickle_thread.
this thread tries to keep a certain amount of memory free
so that a read can be done without incurring a last minute
write in an effort to make memory available for the read
*/
rc = pthread_create(&(bdb_state->memp_trickle_thread), &attr,
Pthread_create(&(bdb_state->memp_trickle_thread), &attr,
memp_trickle_thread, bdb_state);
if (rc != 0) {
logmsg(LOGMSG_ERROR, "unable to create memp_trickle thread - rc=%d "
"errno=%d %s\n",
rc, errno, strerror(errno));
logmsg(LOGMSG_INFO, "%s failing with bdberr_misc at line %d\n", __func__, __LINE__);
*bdberr = BDBERR_MISC;
return NULL;
}

/* create the deadlock detect thread if we arent doing auto
deadlock detection */
if (!bdb_state->attr->autodeadlockdetect) {
rc = pthread_create(&dummy_tid, &attr, deadlockdetect_thread,
Pthread_create(&dummy_tid, &attr, deadlockdetect_thread,
bdb_state);
}

Expand Down Expand Up @@ -6086,15 +6054,8 @@ static bdb_state_type *bdb_open_int(int envonly, const char name[], const char d
} else {
print(bdb_state,
"logfiles will be deleted in logdelete_thread\n");
rc = pthread_create(&(bdb_state->logdelete_thread), &attr,
Pthread_create(&(bdb_state->logdelete_thread), &attr,
logdelete_thread, bdb_state);
if (rc) {
logmsg(LOGMSG_ERROR,
"unable to create logdelete thread rc %d %s\n", rc,
strerror(rc));
*bdberr = BDBERR_MISC;
return NULL;
}
}

Pthread_attr_destroy(&attr);
Expand Down
36 changes: 2 additions & 34 deletions bdb/fstdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,24 +740,8 @@ static int bdb_fstdumpdta_sendsz_int(bdb_state_type *bdb_state, SBUF2 *sb,
perthread[nthr].real_thread = 1;
perthread[nthr].get_genids = get_genids;

rc = pthread_create(&perthread[nthr].tid, &attr, fstdump_thread,
Pthread_create(&perthread[nthr].tid, &attr, fstdump_thread,
&perthread[nthr]);

if (rc != 0) {
logmsg(LOGMSG_ERROR,
"bdb_fstdumpdta_sendsz: pthread_create failed rc %d %s\n",
rc, strerror(rc));

Pthread_mutex_lock(&fstdump.lock);
{
snprintf0(fstdump.errmsg, sizeof(fstdump.errmsg),
"pthread_create failed");
fstdump.bdberr = 1;
}
Pthread_mutex_unlock(&fstdump.lock);
break;
}

numthreads++;
}

Expand Down Expand Up @@ -800,23 +784,7 @@ static int bdb_fstdumpdta_sendsz_int(bdb_state_type *bdb_state, SBUF2 *sb,
args.num_done = 0;

for (nthr = 0; nthr < bdb_state->attr->fstdump_maxthreads; nthr++) {
rc = pthread_create(&tids[nthr], &attr, fstdump_thread2, &args);

if (rc != 0) {
logmsg(LOGMSG_ERROR,
"bdb_fstdumpdta_sendsz: pthread_create failed rc %d %s\n",
rc, strerror(rc));

Pthread_mutex_lock(&fstdump.lock);
{
snprintf0(fstdump.errmsg, sizeof(fstdump.errmsg),
"pthread_create failed");
fstdump.bdberr = 1;
}
Pthread_mutex_unlock(&fstdump.lock);
break;
}

Pthread_create(&tids[nthr], &attr, fstdump_thread2, &args);
numthreads++;
}

Expand Down
5 changes: 2 additions & 3 deletions bdb/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,6 @@ static void *bdb_thread_wrapper(void *p)
int bdb_run_in_a_thread(bdb_state_type *bdb_state,
void (*func)(bdb_state_type *))
{
int rc;
pthread_t tid;
struct bdb_thread_args *args;

Expand All @@ -1111,9 +1110,9 @@ int bdb_run_in_a_thread(bdb_state_type *bdb_state,
args->bdb_state = bdb_state;
args->func = func;

rc = pthread_create(&tid, &attr, bdb_thread_wrapper, args);
Pthread_create(&tid, &attr, bdb_thread_wrapper, args);
Pthread_attr_destroy(&attr);
return rc;
return 0;
}

static volatile int count_freepages_abort = 0;
Expand Down
18 changes: 9 additions & 9 deletions bdb/locktest.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void bdb_detect(void *_bdb_state)
dbenv = bdb_state->dbenv;
pthread_t t;
extern pthread_attr_t gbl_pthread_attr_detached;
pthread_create(&t, &gbl_pthread_attr_detached, detect, NULL);
Pthread_create(&t, &gbl_pthread_attr_detached, detect, NULL);
}

void bdb_locker_summary(void *_bdb_state)
Expand Down Expand Up @@ -202,7 +202,7 @@ static void test_same_lock(db_lockmode_t mode)
arg[i].num_obj = 1;
arg[i].mode = mode;
arg[i].tid = i;
pthread_create(&t[i], &locktest_attr, test_lockmgr, &arg[i]);
Pthread_create(&t[i], &locktest_attr, test_lockmgr, &arg[i]);
}
fail = 0;
for (i = 0; i < THDS; ++i) {
Expand Down Expand Up @@ -254,7 +254,7 @@ static void test_n_locks(const int n, db_lockmode_t mode)
arg->tid = i;

for (j = 0; j < THD_GRPS; ++j) {
pthread_create(&t[i++], &locktest_attr, test_lockmgr, arg);
Pthread_create(&t[i++], &locktest_attr, test_lockmgr, arg);
}
}
fail = 0;
Expand Down Expand Up @@ -296,7 +296,7 @@ static void test_diff_lock(db_lockmode_t mode)
arg->mode = mode;
arg->num_obj = 1;
arg->tid = i;
pthread_create(&t[i], &locktest_attr, test_lockmgr, arg);
Pthread_create(&t[i], &locktest_attr, test_lockmgr, arg);
}
fail = 0;
for (i = 0; i < THDS; ++i) {
Expand Down Expand Up @@ -359,7 +359,7 @@ static void test_lock_per_sec(db_lockmode_t mode)
pthread_t t;
ssize_t *rc;
stop = 0;
pthread_create(&t, &locktest_attr, test_get_put, (void *)mode);
Pthread_create(&t, &locktest_attr, test_get_put, (void *)mode);
sleep(sleep_sec);
stop = 1;
pthread_join(t, (void **)&rc);
Expand Down Expand Up @@ -598,7 +598,7 @@ static ssize_t tester(const char *name, size_t num, tester_routine *routine)
for (i = 0; i < num; ++i) {
arg[i].id = i;
arg[i].num = num;
pthread_create(&t[i], &locktest_attr, routine, &arg[i]);
Pthread_create(&t[i], &locktest_attr, routine, &arg[i]);
}
for (i = 0; i < num; ++i) {
pthread_join(t[i], (void **)&ret[i]);
Expand Down Expand Up @@ -715,7 +715,7 @@ static void get_locks_wrapper(int argc, GetLocksArg argv[])
int i;

for (i = 0; i < argc; ++i) {
pthread_create(&t[i], &locktest_attr, get_locks, &argv[i]);
Pthread_create(&t[i], &locktest_attr, get_locks, &argv[i]);
}
for (i = 0; i < argc; ++i) {
pthread_join(t[i], (void **)&rc[i]);
Expand Down Expand Up @@ -915,7 +915,7 @@ static void locvec_test()
int i;
pthread_t t[20];
for (i = 0; i < arraylen(t); ++i) {
pthread_create(&t[i], NULL, lockvec, NULL);
Pthread_create(&t[i], NULL, lockvec, NULL);
}
void *ret;
for (i = 0; i < arraylen(t); ++i) {
Expand Down Expand Up @@ -997,7 +997,7 @@ void bdb_locktest(void *_bdb_state)
void *ret;
pthread_t t;
uint64_t before = gettimeofday_ms();
pthread_create(&t, NULL, locktest, io_override_get_std());
Pthread_create(&t, NULL, locktest, io_override_get_std());
pthread_join(t, &ret);
Pthread_attr_destroy(&locktest_attr);
uint64_t after = gettimeofday_ms();
Expand Down
21 changes: 5 additions & 16 deletions bdb/rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,8 +1389,6 @@ static void *elect_thread(void *args)

static void call_for_election_int(bdb_state_type *bdb_state, int op)
{
int rc;

pthread_t elect_thr;
elect_thread_args_type *elect_thread_args;

Expand All @@ -1416,12 +1414,8 @@ static void call_for_election_int(bdb_state_type *bdb_state, int op)
Pthread_mutex_unlock(&(bdb_state->repinfo->elect_mutex));

logmsg(LOGMSG_INFO, "call_for_election: creating elect thread\n");
rc = pthread_create(&elect_thr, &(bdb_state->pthread_attr_detach),
Pthread_create(&elect_thr, &(bdb_state->pthread_attr_detach),
elect_thread, (void *)elect_thread_args);
if (rc) {
logmsg(LOGMSG_ERROR, "call_for_election: can't create election thread: %d\n", rc);
free(elect_thread_args);
}
}

void call_for_election(bdb_state_type *bdb_state, const char *func, int line)
Expand Down Expand Up @@ -1689,7 +1683,7 @@ void net_newnode_rtn(netinfo_type *netinfo_ptr, struct interned_string *host, in

/* Colease thread will do this */
if (!bdb_state->attr->coherency_lease) {
pthread_create(&tid, &(bdb_state->pthread_attr_detach),
Pthread_create(&tid, &(bdb_state->pthread_attr_detach),
dummy_add_thread, bdb_state);
}

Expand Down Expand Up @@ -1921,12 +1915,7 @@ int net_hostdown_rtn(netinfo_type *netinfo_ptr, struct interned_string *host)
Pthread_attr_init(&attr);
Pthread_attr_setstacksize(&attr, 128 * 1024);

rc = pthread_create(&tid, &attr, hostdown_thread, hostdown_buf);
if (rc != 0) {
logmsg(LOGMSG_FATAL, "%s: pthread_create hostdown_thread: %d %s\n", __func__,
rc, strerror(rc));
exit(1);
}
Pthread_create(&tid, &attr, hostdown_thread, hostdown_buf);
rc = pthread_detach(tid);
if (rc != 0) {
logmsg(LOGMSG_FATAL, "%s: pthread_detach hostdown_thread: %d %s\n", __func__,
Expand Down Expand Up @@ -3854,7 +3843,7 @@ static void add_rep_mon(struct rep_mon *rm)
rm->added = 1;
} else {
pthread_t t;
pthread_create(&t, NULL, rep_mon, NULL);
Pthread_create(&t, NULL, rep_mon, NULL);
}
Pthread_mutex_unlock(&rep_mon_lk);
}
Expand Down Expand Up @@ -4810,7 +4799,7 @@ void berkdb_receive_msg(void *ack_handle, void *usr_ptr, char *from_host,
case USER_TYPE_ADD_DUMMY: {
extern pthread_attr_t gbl_pthread_attr_detached;
pthread_t tid;
pthread_create(&tid, &gbl_pthread_attr_detached,
Pthread_create(&tid, &gbl_pthread_attr_detached,
dummy_add_thread_nodelay, bdb_state);
net_ack_message(ack_handle, 0);
break;
Expand Down
2 changes: 1 addition & 1 deletion bdb/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void *coherency_lease_thread(void *arg)
if (inc_wait && (add_interval = bdb_state->attr->add_record_interval)) {
time_t now = time(NULL);
if ((now - last_add_record) >= add_interval) {
pthread_create(&tid, &gbl_pthread_attr_detached,
Pthread_create(&tid, &gbl_pthread_attr_detached,
rep_catchup_add_thread, bdb_state);
last_add_record = now;
}
Expand Down
9 changes: 1 addition & 8 deletions berkdb/log/log_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,14 +1750,7 @@ __log_write_td(arg)
static void
__log_write_segments_init(void)
{
int ret;
if ((ret = pthread_create(&log_write_td, NULL, __log_write_td,
log_write_dblp)) != 0) {
DB_ENV *dbenv = log_write_dblp->dbenv;
__db_err(dbenv,
"DB_ENV->log_write_segments_init: error creating pthread");
ret = __db_panic(dbenv, ret);
}
Pthread_create(&log_write_td, NULL, __log_write_td, log_write_dblp);
}

/*
Expand Down
13 changes: 2 additions & 11 deletions db/comdb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4538,23 +4538,14 @@ static void ttrap(struct timer_parm *parm)

void create_old_blkseq_thread(struct dbenv *dbenv)
{
int rc;

if (!dbenv->purge_old_blkseq_is_running) {
rc = pthread_create(&dbenv->purge_old_blkseq_tid, &gbl_pthread_attr,
Pthread_create(&dbenv->purge_old_blkseq_tid, &gbl_pthread_attr,
purge_old_blkseq_thread, thedb);
if (rc)
logmsg(LOGMSG_WARN,
"Warning: can't start purge_old_blkseq thread: rc %d err %s\n",
rc, strerror(rc));
}

if (!dbenv->purge_old_files_is_running && !gbl_is_physical_replicant) {
rc = pthread_create(&dbenv->purge_old_files_tid, &gbl_pthread_attr,
Pthread_create(&dbenv->purge_old_files_tid, &gbl_pthread_attr,
purge_old_files_thread, thedb);
if (rc)
logmsg(LOGMSG_WARN, "Warning: can't start purge_oldfiles thread: rc %d err %s\n",
rc, strerror(rc));
}
}

Expand Down
Loading