Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Fix issue where the application would not terminate correctly when done. #19

Merged
merged 5 commits into from
Nov 8, 2017

Conversation

CoqRogue
Copy link
Contributor

@CoqRogue CoqRogue commented Nov 7, 2017

Move creation and destruction of progress events to the execute function so that the progress event is not holding up the execution after application is done.

@CoqRogue CoqRogue requested a review from mrodem November 7, 2017 14:09
bihanssen
bihanssen previously approved these changes Nov 7, 2017
Copy link
Contributor

@mrodem mrodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good, but I am unable to compile on Linux now. It fails with this error:

/home/mrodem/tmp/pc-nrfjprog-js/src/platform/linux/osfiles.cpp:37:10: fatal error: 
      '../osfiles.h' file not found
#include "../osfiles.h"

I suspect it has something to do with the changes that were introduced in 0f4c00c.

@CoqRogue
Copy link
Contributor Author

CoqRogue commented Nov 8, 2017

@mrodem That is correct. It is fixed in the feature/rtt-support branch in commit 1ae31d9. Should probably be fixed by adding . to the include directories as adding relative paths in includes are cumbersome to maintain. Will fix.

keepDeviceOpen = false;
}

HighLevel::~HighLevel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary to keep empty destructor?

HighLevel::~HighLevel()
{}

void HighLevel::CallFunction(Nan::NAN_METHOD_ARGS_TYPE info, parse_parameters_function_t parse, execute_function_t execute, return_function_t ret, const bool hasSerialNumber)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to stick to max-100-char-line-length, it makes it easier to read&review the code.

return;
}

log("===============================================\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this debug logging, that is, should it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is logs that are sent up on an error. So they are nice to have. They are mainly used in debugging, but make sense to send up in all cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok by me.

}
}

nrfjprogdll_err_t excuteError = baton->executeFunction(baton, probe);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: excute


if (progressEvent != nullptr)
{
auto handle = reinterpret_cast<uv_handle_t *>(progressEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a cast needed here? It's already of type uv_handle_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a uv_async_t, so a cast is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see it now.


uv_close(handle, [](uv_handle_t *handle)
{
free(handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

progressEvent was created with new() at the top of the function, shouldn't it then be cleaned up with delete instead of free()?

Nan::HandleScope scope;

auto baton = static_cast<Baton *>(req->data);
//TODO: Create an arrary of correct size instead of a way to large one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantics: 'too' instead of 'to'
or even better, implement what the TODO says :)

@mrodem
Copy link
Contributor

mrodem commented Nov 8, 2017

Still not able to compile on Linux unfortunately:

/home/mrodem/projects/pc-nrfjprog-js/src/platform/linux/../../libraryloader.h:49:22: error: use of undeclared identifier 'NULL'
    if (*func_ptr == NULL) {
                     ^
/home/mrodem/projects/pc-nrfjprog-js/src/platform/linux/libraryloader.cpp:49:12: error: no matching function for call to 'dlopen'
    return dlopen(path);
           ^~~~~~
/usr/include/dlfcn.h:56:14: note: candidate function not viable: requires 2 arguments, but 1 was provided
extern void *dlopen (const char *__file, int __mode) __THROWNL;
             ^
1 warning and 2 errors generated.

Copy link
Contributor

@mrodem mrodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@CoqRogue CoqRogue merged commit 4be2368 into master Nov 8, 2017
@chunfantasy chunfantasy deleted the bugfix/termination branch March 30, 2020 09:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants