Skip to content

Commit

Permalink
swig/python: Fix a bug handling new channels
Browse files Browse the repository at this point in the history
The return value from new_channel was causing an issue.  Always return
0.

Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed Dec 22, 2023
1 parent f5d435d commit 2538e14
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions swig/python/gensio_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,14 @@ gensio_child_event(struct gensio *io, void *user_data, int event, int readerr,

PyTuple_SET_ITEM(args, 2, gensio_py_handle_auxdata(auxdata));

rv = swig_finish_call_rv_int(data->handler_val, "new_channel",
args, false);
/*
* Do not return the return code from here, return 0. If you
* return non-zero from here, then gensio will delete the
* gensio. Python will then free the gensio if the user
* didn't keep a copy both of which are bad situations.
*/
swig_finish_call_rv_int(data->handler_val, "new_channel",
args, false);
break;

case GENSIO_EVENT_SEND_BREAK:
Expand Down Expand Up @@ -1106,6 +1112,12 @@ gensio_acc_child_event(struct gensio_accepter *accepter, void *user_data,
PyTuple_SET_ITEM(args, 0, acc_ref.val);
PyTuple_SET_ITEM(args, 1, io_ref.val);

/*
* Do not return the return code from here, return 0. If you
* return non-zero from here, then gensio will delete the
* gensio. Python will then free the gensio if the user
* didn't keep a copy both of which are bad situations.
*/
swig_finish_call(data->handler_val, "new_connection", args, false);

OI_PY_STATE_PUT(gstate);
Expand Down

0 comments on commit 2538e14

Please sign in to comment.