Skip to content

Commit 3e17afb

Browse files
better handling of fdtransfer
1 parent 89718b1 commit 3e17afb

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/profiler.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,21 @@ Error Profiler::start(Arguments& args, bool reset) {
10591059
VM::tryAttach();
10601060
}
10611061

1062+
if (args._fdtransfer) {
1063+
if (!FdTransferClient::connectToServer(args._fdtransfer_path)) {
1064+
return Error("Failed to initialize FdTransferClient");
1065+
}
1066+
}
1067+
1068+
Error error = startInternal(args, reset);
1069+
if (error) {
1070+
FdTransferClient::closePeer();
1071+
}
1072+
1073+
return error;
1074+
}
1075+
1076+
Error Profiler::startInternal(Arguments& args, bool reset) {
10621077
Error error = checkJvmCapabilities();
10631078
if (error) {
10641079
return error;
@@ -1195,13 +1210,6 @@ Error Profiler::start(Arguments& args, bool reset) {
11951210
}
11961211
}
11971212

1198-
if (args._fdtransfer) {
1199-
if (!FdTransferClient::connectToServer(args._fdtransfer_path)) {
1200-
error = Error("Failed to initialize FdTransferClient");
1201-
goto error1;
1202-
}
1203-
}
1204-
12051213
error = _engine->start(args);
12061214
if (error) {
12071215
goto error1;
@@ -1287,7 +1295,6 @@ Error Profiler::start(Arguments& args, bool reset) {
12871295
_jfr.stop();
12881296
unlockAll();
12891297

1290-
FdTransferClient::closePeer();
12911298
return error;
12921299
}
12931300

src/profiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class Profiler {
196196
void shutdown(Arguments& args);
197197
Error check(Arguments& args);
198198
Error start(Arguments& args, bool reset);
199+
Error startInternal(Arguments& args, bool reset);
199200
Error stop(bool restart = false);
200201
Error flushJfr();
201202
Error dump(Writer& out, Arguments& args);

0 commit comments

Comments
 (0)