Commit Graph

80 Commits

Author SHA1 Message Date
Jason Rhinelander 48a6561002
Merge pull request #13 from jagerman/fix-reply-segfault
Fix python binding segfault
2023-09-27 19:57:23 -03:00
Jason Rhinelander 1198dc217d
sid build fix 2023-09-27 19:45:28 -03:00
Jason Rhinelander b0edf998f8
Fix python binding segfault
This fixes a segfault in the reply handling code, where the destructor
of a `py::function` wasn't necessarily happening with the GIL held,
which could make Python segfault.

The solution that was here to address this didn't work because it was
relying on std::optionals, but it is possible (and apparently sometimes
happens) that the std::function this lambda gets stuffed into gets moved
(or maybe copied?), which then results in *two* lambda destructions: we
were correctly dealing with the one that eventually gets called by
clearing things properly when it gets called, but the temporary
destructor also fires, and that is the one that broke.

This changes it to instead leak bare pointers into the lambda and then
recapture them inside when we get called; since we are guaranteed to be
called exactly once, this recaptures them without losing them but
doesn't incur destruction of a py::function deep in oxenmq (outside of
GIL scope).
2023-09-27 16:06:08 -03:00
Jason Rhinelander 5359810a10
Merge pull request #12 from jagerman/connect-auth-level
Expose setting auth level on outgoing connection
2023-03-28 09:30:41 +11:00
Jason Rhinelander ace70998d7 fix debian sid builds
Python 3.11+ complains when trying to use pip globally, but for CI it
seems fine to override (and potentially break the temporary CI image).
2023-03-28 09:21:15 +11:00
Jason Rhinelander 6e50822bc9
Expose setting auth level on outgoing connection
This is necessary to allow a remote to issue authenticated commands back
to us.
2023-03-08 17:31:49 -04:00
Jason Rhinelander 30a9a26ea7
Merge pull request #11 from jagerman/remove-bencode
Remove base32z encoding
2022-08-04 14:28:54 -03:00
Jason Rhinelander f62fa4916f
Remove base32z encoding
We have pyoxenc for that instead.
2022-08-04 13:31:22 -03:00
Jason Rhinelander 4bf412905a
Rename is_reply -> is_request
The property is retrieving whether a reply is expected, not whether the
message itself is a reply.
2022-06-09 18:29:29 -03:00
Jason Rhinelander 296f61a7c0
macos compilation fix
macos clang won't apply the implicit `operator std::string()` from
py::bytes here for some unknown reason.
2022-01-11 11:16:47 -04:00
Jason Rhinelander e4b9a39fd0
Merge pull request #10 from jagerman/fixes
Fixes
2021-12-03 15:39:55 -04:00
Jason Rhinelander 36e32066d0
Version bump 2021-12-03 13:10:19 -04:00
Jason Rhinelander 4136c29d06
Make Message property accessors copy
The default references, which breaks because Message gets reused, so
storing `.conn` gives you something that changes the next time a worker
gets a message.
2021-12-03 13:08:11 -04:00
Jason Rhinelander f1160d0a25
Make allow_connection properly optional 2021-12-03 13:07:49 -04:00
Jason Rhinelander 4020ab8a49
Make ConnectionIDs hashable 2021-12-03 13:07:35 -04:00
Jason Rhinelander a678fcf0ce
Remove include for older pybind compatibility 2021-12-02 15:39:54 -04:00
Jason Rhinelander 59e86ab6b6
Merge pull request #9 from jagerman/fix-allow-func
Fix allow function argument decoding error
2021-12-02 15:17:04 -04:00
Jason Rhinelander 530280ac60
Fix allow function argument decoding error
Avoids a utf-8 decoding error when accepting a connection with an allow
function by properly wrapping the function in a version that passes
pubkey as a `bytes`.
2021-12-02 15:14:54 -04:00
Jason Rhinelander 367007dd66 Update readme for new code 2021-10-22 20:22:54 -03:00
Jason Rhinelander 06e0e2eb44
Merge pull request #7 from jagerman/redo
pyoxenmq overhaul
2021-10-22 20:09:09 -03:00
Jason Rhinelander b12c754895 Fixes and address warnings
- timeout in the syncronous connect_remote wasn't being passed through
- callback and syncronous connect_remote had some deviation in args;
  unified them to both take keyword-only timeout and
  ephemeral_routing_id, and to take timeout as a timedelta with a
  default (rather than an optional in the callback-based one).
- removed unused "noopt".  I forget what it was for, but it didn't end
  up being used.
2021-10-22 19:12:57 -03:00
Jason Rhinelander 6d59248f45 Build with -Wextra -Werror and color 2021-10-22 19:12:57 -03:00
Jason Rhinelander 97238b04ba Hacking around for macos
Build local oxenmq

Install everything into a local prefix
2021-10-22 19:12:57 -03:00
Jason Rhinelander 996370228c Add drone build & tests 2021-10-22 19:12:57 -03:00
Jason Rhinelander 171e94cf11 Add simple pytest tests 2021-10-22 17:03:06 -03:00
Jason Rhinelander 5ceed8a416 Various fixes for bugs revealed in testing
- make extract data parts always flatten to arbitrary depth.  We were
  only flattening once (and only sometimes), but arbitrary flattening is
  nicer (as long as we don't ultimately encouter anything that isn't
  str/bytes).
- fix Message.data()/.dataview() pre-loading nulls into the list.  The
  py::list constructor argument here is pre-fill, not a reservation.
- fix add_command: it was broken because when the wrapped callback gets
  invoked it tries casting the Message via copying, but that breaks
  (Message isn't copyable).  Fix it by adding a wrapper that does a
  referencing cast to a Python object.
- Add missing docs for add_command
- Doc typo fixes
- Remove OxenMQ default and loglevel constructors, and make the
  remaining constructor take everything by keyword arguments.  (Default
  constructor remains equivalent, and the log-level constructor now has
  to have the log level named).
- Fix OxenMQ keyword constructor: invoking it was failing because the
  annotation default on sn_lookup wasn't properly castable to the
  required types (it should be py::none() rather than nullptr).  Also
  fix the defaults for pubkey/privkey to be py::bytes() (the empty
  string worked fine, but using bytes makes it show up as bytes defaults
  in the generated signature doc string).
- Further document connect_inproc with a description of why you might
  want it.
- Fix send not actually including the message data parts
- Work around segfault in the reply callback: because we have lambdas
  with python object captures, we'd segfault in the proxy thread when it
  frees them after calling them because that freeing invokes python
  destructor but it doesn't hold the gil.  Fixed by making the lambda
  consume its own callbacks (which is fine because oxenmq will invoke
  the callback exactly once).
- Fix request_future invocation which raised an error on invocation:
  straight lambdas aren't castable to python objects, so stuff the
  lambda inside std::functions, which are.
2021-10-22 16:28:21 -03:00
Jason Rhinelander 6a382865b2 Remove cmake build system and submodules
setup.py works fine, and we don't need two separate build systems.

Remove the submodules as well because we aren't using them and don't
need them; you should install pybind11 and oxenmq outside this project.
2021-10-22 16:09:36 -03:00
Jason Rhinelander a62f6c4769 Formatting 2021-10-22 16:08:57 -03:00
Jason Rhinelander c4d9eb8a8f De-Frankenstein the build 2021-10-22 00:45:15 -03:00
Jason Rhinelander 0e1283784e Remove unwanted headers
- pybind11/gil.h is only in recent pybind (but is implicitly included by
  the main pybind11.h header)
- detail/common shouldn't be included
2021-10-21 23:47:58 -03:00
Jason Rhinelander a98722a7da pyoxenmq overhaul
- Wrap much more of the OxenMQ
- Add extensive pydoc to everything
- Switch setup.py to pybind's built-in tools
2021-10-21 22:23:02 -03:00
Jeff feb28e1973
Merge pull request #6 from jagerman/oxenmq-updates
Oxenmq updates
2021-06-20 03:59:15 -04:00
Jason Rhinelander 959df9c5dd Remove duplicate method
Not sure why this was here, but AFAICT it is identical to
`add_request_command` without the `_ex`.
2021-06-19 22:58:03 -03:00
Jason Rhinelander 2805d01f6b Update old routing id field name 2021-06-19 22:58:03 -03:00
Jason Rhinelander 739e445c03 Rename to pyoxenmq
Finish renaming everything from loki->oxen, and update to latest
oxen-mq submodule.
2021-06-19 22:57:43 -03:00
Jeff 9ac2d20632
Merge pull request #5 from majestrate/oxen-refactor-2021-02-01
update readme
2021-04-14 13:27:41 -04:00
Jeff Becker f7d562f5d1
update readme
* fix urls
* fix names
2021-04-14 13:23:07 -04:00
Jason Rhinelander 56239c9390 Fix loki-mq submodule path 2021-02-27 13:26:12 -04:00
Jeff 8c75af04ca
Merge pull request #4 from majestrate/oxen-refactor-2021-02-01
loki -> oxen refactor
2021-02-18 06:07:03 -05:00
Jeff Becker 4597f5ca6c
loki -> oxen refactor
* rename all namespaces so it compiles again
2021-02-01 10:48:27 -05:00
Jeff aade6d835c
Merge pull request #3 from loki-project/KeeJef-patch-1
Add dependencies
2020-11-26 05:06:09 -05:00
Kee Jefferys 2c13d931d9
Add dependencies
Not sure if this is the full or accurate list, was what i needed to install
2020-11-26 13:43:56 +11:00
Jeff Becker 5ebc6ee614
add lokinet.auth package 2020-11-09 08:51:40 -05:00
Jeff Becker 3787a12fcd
package lokinet package 2020-11-09 08:32:28 -05:00
Jeff Becker fc1a85da79
build lokimq from pkg-config 2020-11-09 08:32:10 -05:00
Jeff 626316e49c update readme and ignore 2020-10-03 12:33:49 -04:00
Jeff a3d3aafb5c dont use reference in arguments 2020-09-24 11:59:45 -04:00
Jeff f568f911d1 use py::function 2020-09-24 11:59:36 -04:00
Jeff 6ea7941862 wrap lokimq::Message 2020-09-24 11:59:19 -04:00
Jeff 532d530836 move py::bytes construction inside scoped acquire 2020-09-24 11:42:24 -04:00