Skip to content

Commit faf08f8

Browse files
committed
libplugin: correctly mark that plugin_notification_end STEALS the stream.
And also slightly generalize: plugin_notification_start() can take any tal ptr. Signed-off-by: Rusty Russell <[email protected]>
1 parent dd68a20 commit faf08f8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

plugins/libplugin.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,10 +1859,10 @@ void plugin_gossmap_logcb(struct plugin *plugin,
18591859
va_end(ap);
18601860
}
18611861

1862-
struct json_stream *plugin_notification_start(struct plugin *plugin,
1862+
struct json_stream *plugin_notification_start(const tal_t *ctx,
18631863
const char *method)
18641864
{
1865-
struct json_stream *js = new_json_stream(plugin, NULL, NULL);
1865+
struct json_stream *js = new_json_stream(ctx, NULL, NULL);
18661866

18671867
json_object_start(js, NULL);
18681868
json_add_string(js, "jsonrpc", "2.0");
@@ -1873,7 +1873,7 @@ struct json_stream *plugin_notification_start(struct plugin *plugin,
18731873
}
18741874

18751875
void plugin_notification_end(struct plugin *plugin,
1876-
struct json_stream *stream)
1876+
struct json_stream *stream STEALS)
18771877
{
18781878
json_object_end(stream);
18791879
jsonrpc_finish_and_send(plugin, stream);

plugins/libplugin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ void plugin_notify_end(struct command *cmd, struct json_stream *js);
534534

535535
/* Send a notification for a custom notification topic. These are sent
536536
* to lightningd and distributed to subscribing plugins. */
537-
struct json_stream *plugin_notification_start(struct plugin *plugins,
537+
struct json_stream *plugin_notification_start(const tal_t *ctx,
538538
const char *method);
539539
void plugin_notification_end(struct plugin *plugin,
540-
struct json_stream *stream TAKES);
540+
struct json_stream *stream STEALS);
541541

542542
/* Convenience wrapper for notify "message" */
543543
void plugin_notify_message(struct command *cmd,

plugins/test/run-route-calc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char
299299
{ fprintf(stderr, "plugin_log called!\n"); abort(); }
300300
/* Generated stub for plugin_notification_end */
301301
void plugin_notification_end(struct plugin *plugin UNNEEDED,
302-
struct json_stream *stream TAKES UNNEEDED)
302+
struct json_stream *stream STEALS UNNEEDED)
303303
{ fprintf(stderr, "plugin_notification_end called!\n"); abort(); }
304304
/* Generated stub for plugin_notification_start */
305-
struct json_stream *plugin_notification_start(struct plugin *plugins UNNEEDED,
305+
struct json_stream *plugin_notification_start(const tal_t *ctx UNNEEDED,
306306
const char *method UNNEEDED)
307307
{ fprintf(stderr, "plugin_notification_start called!\n"); abort(); }
308308
/* Generated stub for plugin_notify_message */

plugins/test/run-route-overlong.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char
296296
{ fprintf(stderr, "plugin_log called!\n"); abort(); }
297297
/* Generated stub for plugin_notification_end */
298298
void plugin_notification_end(struct plugin *plugin UNNEEDED,
299-
struct json_stream *stream TAKES UNNEEDED)
299+
struct json_stream *stream STEALS UNNEEDED)
300300
{ fprintf(stderr, "plugin_notification_end called!\n"); abort(); }
301301
/* Generated stub for plugin_notification_start */
302-
struct json_stream *plugin_notification_start(struct plugin *plugins UNNEEDED,
302+
struct json_stream *plugin_notification_start(const tal_t *ctx UNNEEDED,
303303
const char *method UNNEEDED)
304304
{ fprintf(stderr, "plugin_notification_start called!\n"); abort(); }
305305
/* Generated stub for plugin_notify_message */

0 commit comments

Comments
 (0)