Skip to content

Changes#1

Merged
toots merged 6 commits intosavonet:masterfrom
MisterDA:changes
Jul 19, 2021
Merged

Changes#1
toots merged 6 commits intosavonet:masterfrom
MisterDA:changes

Conversation

@MisterDA
Copy link
Copy Markdown
Collaborator

Hi!
This PR introduces fixes and some changes:

  • switches completely to the Windows Unicode API and handles conversion from OCaml strings to OS strings;
  • doesn't use the caml_winsvc_ prefix but only winsvc_ as caml_ is reserved by OCaml standard library;
  • improves the error reporting by using system error messages;
  • introduces a new exception to handle the case where a program isn't launched through the Windows Service manager;
  • and adds small C improvements.
    Let me know what you think!

Using the `caml_` prefix here is unlikely to cause any problem at all
as the library really uses `caml_winsvc_`, however it's better not to
use the prefix at all.
Copy link
Copy Markdown

@dra27 dra27 left a comment

Choose a reason for hiding this comment

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

I'd just use Failure _, or possibly even Not_found - it's a uniquely useful error (as in you might do something other than terminate with it)

Comment thread src/winsvc_stubs.c
report_status(SERVICE_STOPPED, NO_ERROR, 2000);
}

#define raise_error(str) caml_raise_with_string(*caml_named_value("caml_service_exn"), str)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixes a bug as well - "caml_service_exn" here but "caml_winsvc_exn" above

Comment thread src/winsvc_stubs.c Outdated
Comment thread src/winsvc_stubs.c Outdated
If StartServiceCtrlDispatcher() returns
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT, then the program is being run
as a console application rather than as a service. Not using
Winsvc.Error helps identifying this special case.
@MisterDA
Copy link
Copy Markdown
Collaborator Author

Applied your suggestions, thanks!

@toots
Copy link
Copy Markdown
Member

toots commented Jul 19, 2021

This all looks great! My only remark is w.r.t. to the namespace. Liqiudsoap is built statically and I try to be on the most safe side I can with potentiasl symbol name clashes. I agree on the caml_ prefix being reserved so I'll just go with ocaml_winscv, which is the conventions in our others bindings. Other than that, the changes look like great improvements. This code has been needing some love for a while. Thanks!

@toots toots closed this Jul 19, 2021
@toots toots reopened this Jul 19, 2021
@toots toots merged commit fd5aad5 into savonet:master Jul 19, 2021
@MisterDA MisterDA deleted the changes branch July 19, 2021 15:07
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

Successfully merging this pull request may close these issues.

4 participants