Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot shut down JAPI server from another thread #24

Closed
fraunhofer-iis-bot opened this issue Nov 25, 2019 · 4 comments
Closed

Cannot shut down JAPI server from another thread #24

fraunhofer-iis-bot opened this issue Nov 25, 2019 · 4 comments
Assignees
Milestone

Comments

@fraunhofer-iis-bot
Copy link
Collaborator

In GitLab by @kolb on Nov 25, 2019, 10:52

I run a JAPI server as part of a larger program where it is not started from the main() function, but from another thread.

When the program shuts down, I'd like to cleanly shut down the JAPI server as well. That is currently not possible because japi_start_server() is blocking and cannot be interacted with from the outside.

Example code for explanation of the issue:

// called by larger application's framework
void start(void)
{
   d_japi_thread = start_thread(japi_thread); // starts japi_thread() as separate thread
}

// called by larger application's framework
void stop(void)
{
  // Shut down the thread -> how? japi_shutdown() would be nice
  d_japi_thread->join();         // join() blocks forever :-(
}

void japi_thread(void)
{
  japi_context *ctx = japi_init(this);

  // japi setup code left out for brevity

  int ret = japi_start_server(ctx, this->port); // blocking call

  // this part is never reached except if an error occurs

  japi_pushsrv_stop(pushctx_stats);
  japi_destroy(ctx);
}

As pointed out above, a japi_shutdown(ctx) function would be nice that causes japi_start_server() to return. japi_shutdown() would have to be thread-safe.

@fraunhofer-iis-bot
Copy link
Collaborator Author

In GitLab by @fraunhofer-iis-anon on Mar 11, 2020, 15:23

mentioned in commit 62322463ce059dd21fd20c8f3f32cd1dc89cf175

@fraunhofer-iis-bot
Copy link
Collaborator Author

In GitLab by @fraunhofer-iis-anon on Mar 12, 2020, 14:27

This feature request is implemented in MR !45

@fraunhofer-iis-bot
Copy link
Collaborator Author

In GitLab by @cstender on Mar 20, 2020, 09:22

Fixed.

@fraunhofer-iis-bot
Copy link
Collaborator Author

In GitLab by @cstender on Mar 20, 2020, 09:22

closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants