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

Use erlang term format instead of ascii #13

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

hrefhref
Copy link
Contributor

@hrefhref hrefhref commented May 13, 2020

This changes apprentice.c to use the erl_interface/ei.h instead of ascii.

Probably also fixes a possible buffer overflow in the old process_line, and will work with the maximum path length (4096).

Magic errors now try to uses magic_errno to have more generic errors (for example, my libmagic wasn't returning the same string as yours ("unable to access file").

perform/3 calls now support passing a binary instead of a file path ({:bytes, ...}).

The databases are now loaded by using message passing and not arguments.

Added GenMagic.Server.recycle and GenMagic.Server.reload which allows to manually recycle/reload the port, and also loading a new set of databases.

Fixes building on musl (was related to the arguments code, see #16, #18).

Handle timeouts a bit nicer in server.

Handle a recycle stop timeout by forcing the port close.

Added tests dedicated to the port.

Tested on: MacOS, FreeBSD, Alpine, Ubuntu, Debian, Fedora, Voidlinux. TODO: Open/Net BSD.

@hrefhref hrefhref mentioned this pull request May 14, 2020
@hrefhref hrefhref marked this pull request as ready for review May 14, 2020 16:43
@hrefhref
Copy link
Contributor Author

Checked with Valgrind and everything seems nice.

@hrefhref
Copy link
Contributor Author

A test is failing on travis only, see #17. Otherwise tests are OK.

@hrefhref
Copy link
Contributor Author

Put it in WIP until I fix #17 and #18

Also:

- Adds `GenMagic.Server.recycle` and `GenMagic.Server.reload` which
allows to restart/reload the apprentice server with a new set of
databases,
- Fix compilation on musl based distributions (was caused by the args
code),
- Handle timeouts better in `GenMagic.Server`
- Force the port to close in recycling if the graceful stop timeouts
@hrefhref hrefhref marked this pull request as ready for review June 15, 2020 16:26
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.

2 participants