Tools: Clean up unused argument in mgba-perf
Vicki Pfau vi@endrift.com
Thu, 09 Jan 2020 18:28:16 -0800
3 files changed,
19 insertions(+),
11 deletions(-)
M
CHANGES
→
CHANGES
@@ -119,6 +119,7 @@ - Debugger: Print break-/watchpoint ID when breaking in CLI
- SDL: Use controller GUID instead of name - SM83: Rename LR35902 to SM83 - Tools: Allow using threaded renderer in perf.py + - Tools: Clean up unused argument in mgba-perf 0.8 beta 1: (2019-10-20) - Initial beta for 0.8
M
src/platform/test/perf-main.c
→
src/platform/test/perf-main.c
@@ -63,12 +63,13 @@ static void _mPerfShutdown(int signal);
static bool _parsePerfOpts(struct mSubParser* parser, int option, const char* arg); static void _log(struct mLogger*, int, enum mLogLevel, const char*, va_list); static bool _mPerfRunCore(const char* fname, const struct mArguments*, const struct PerfOpts*); -static bool _mPerfRunServer(const char* listen, const struct mArguments*, const struct PerfOpts*); +static bool _mPerfRunServer(const struct mArguments*, const struct PerfOpts*); static bool _dispatchExiting = false; static struct VFile* _savestate = 0; static void* _outputBuffer = NULL; static Socket _socket = INVALID_SOCKET; +static Socket _server = INVALID_SOCKET; int main(int argc, char** argv) { #ifdef _3DS@@ -100,7 +101,7 @@ };
struct mArguments args = {}; bool parsed = parseArguments(&args, argc, argv, &subparser); - if (!args.fname) { + if (!args.fname && !perfOpts.server) { parsed = false; } if (!parsed || args.showHelp) {@@ -127,7 +128,7 @@ consoleUpdate(NULL);
#endif } if (perfOpts.server) { - didFail = !_mPerfRunServer(args.fname, &args, &perfOpts); + didFail = !_mPerfRunServer(&args, &perfOpts); } else { didFail = !_mPerfRunCore(args.fname, &args, &perfOpts); }@@ -266,19 +267,24 @@ printf("\033[2K\r");
} } -static bool _mPerfRunServer(const char* listen, const struct mArguments* args, const struct PerfOpts* perfOpts) { +static bool _mPerfRunServer(const struct mArguments* args, const struct PerfOpts* perfOpts) { SocketSubsystemInit(); - Socket server = SocketOpenTCP(7216, NULL); - if (SOCKET_FAILED(server)) { + _server = SocketOpenTCP(7216, NULL); + if (SOCKET_FAILED(_server)) { SocketSubsystemDeinit(); return false; } - if (SOCKET_FAILED(SocketListen(server, 0))) { - SocketClose(server); + if (SOCKET_FAILED(SocketListen(_server, 0))) { + SocketClose(_server); SocketSubsystemDeinit(); return false; } - _socket = SocketAccept(server, NULL); + _socket = SocketAccept(_server, NULL); + if (SOCKET_FAILED(_socket)) { + SocketClose(_server); + SocketSubsystemDeinit(); + return false; + } if (perfOpts->csv) { const char* header = "game_code,frames,duration,renderer\n"; SocketSend(_socket, header, strlen(header));@@ -301,7 +307,7 @@ }
memset(path, 0, sizeof(path)); } SocketClose(_socket); - SocketClose(server); + SocketClose(_server); SocketSubsystemDeinit(); return true; }@@ -310,6 +316,7 @@ static void _mPerfShutdown(int signal) {
UNUSED(signal); _dispatchExiting = true; SocketClose(_socket); + SocketClose(_server); } static bool _parsePerfOpts(struct mSubParser* parser, int option, const char* arg) {
M
tools/perf.py
→
tools/perf.py
@@ -90,7 +90,7 @@ if self.command:
server_command = list(self.command) else: server_command = [os.path.join(os.getcwd(), PerfTest.EXECUTABLE)] - server_command.extend(['--', '-PD', '0']) + server_command.extend(['--', '-PD']) if hasattr(test, "frames"): server_command.extend(['-F', str(test.frames)]) if not test.renderer: