Add the thread identifier to various multi-threaded programs and tests.

This commit is contained in:
Richard W.M. Jones
2015-10-07 18:01:09 +01:00
parent f6e13aeb65
commit f291411f76
5 changed files with 21 additions and 0 deletions

View File

@@ -149,6 +149,7 @@ worker_thread (void *thread_data_vp)
size_t output_len = 0;
guestfs_h *g;
int err;
char id[64];
/* Take the next domain from the list. */
if (thread_data->verbose)
@@ -191,6 +192,11 @@ worker_thread (void *thread_data_vp)
return &thread_data->r;
}
/* Set the handle identifier so we can tell threads apart. */
snprintf (id, sizeof id, "thread_%zu_domain_%zu",
thread_data->thread_num, i);
guestfs_set_identifier (g, id);
/* Copy some settings from the options guestfs handle. */
guestfs_set_trace (g, thread_data->trace);
guestfs_set_verbose (g, thread_data->verbose);