Commit d6973c44 authored by Philip Carns's avatar Philip Carns

add ability to uniquify diag output

parent a97c0951
......@@ -176,7 +176,7 @@ int main(int argc, char **argv)
HG_Addr_free(hg_class, svr_addr);
/* shut down everything */
margo_diag_dump(mid, "-");
margo_diag_dump(mid, "-", 0);
margo_finalize(mid);
ABT_finalize();
......
......@@ -102,7 +102,7 @@ static void my_rpc_shutdown_ult(hg_handle_t handle)
HG_Destroy(handle);
margo_diag_dump(mid, "-");
margo_diag_dump(mid, "-", 0);
/* NOTE: we assume that the server daemon is using
* margo_wait_for_finalize() to suspend until this RPC executes, so there
......
......@@ -223,9 +223,11 @@ void margo_diag_start(margo_instance_id mid);
*
* @param [in] mid Margo instance
* @param [in] file output file ("-" for stdout)
* @param [in] uniquify flag indicating if file name should have additional
* information added to it to make output from different processes unique
* @returns void
*/
void margo_diag_dump(margo_instance_id mid, const char* file);
void margo_diag_dump(margo_instance_id mid, const char* file, int uniquify);
#define MARGO_REGISTER(__mid, __func_name, __in_t, __out_t, __handler, __mplex_id, __pool) do { \
hg_return_t __hret; \
......
......@@ -935,20 +935,36 @@ static void print_diag_data(FILE *file, const char* name, const char *descriptio
return;
}
void margo_diag_dump(margo_instance_id mid, const char* file)
void margo_diag_dump(margo_instance_id mid, const char* file, int uniquify)
{
FILE *outfile;
time_t ltime;
char revised_file_name[256] = {0};
assert(mid->diag_enabled);
if(uniquify)
{
char hostname[128] = {0};
int pid;
gethostname(hostname, 128);
pid = getpid();
sprintf(revised_file_name, "%s-%s-%d", file, hostname, pid);
}
else
{
sprintf(revised_file_name, "%s", file);
}
if(strcmp("-", file) == 0)
{
outfile = stdout;
}
else
{
outfile = fopen(file, "a");
outfile = fopen(revised_file_name, "a");
if(!outfile)
{
perror("fopen");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment