libubus: add an inline function for socket event handling
[project/ubus.git] / libubus.h
index 53b78f6..9e78ad4 100644 (file)
--- a/libubus.h
+++ b/libubus.h
@@ -145,6 +145,12 @@ static inline void ubus_add_uloop(struct ubus_context *ctx)
        uloop_fd_add(&ctx->sock, ULOOP_EDGE_TRIGGER | ULOOP_BLOCKING | ULOOP_READ);
 }
 
+/* call this for read events on ctx->sock.fd when not using uloop */
+static inline void ubus_handle_event(struct ubus_context *ctx)
+{
+       ctx->sock.cb(&ctx->sock, ULOOP_READ);
+}
+
 /* ----------- raw request handling ----------- */
 
 /* wait for a request to complete and return its status */
@@ -177,8 +183,8 @@ int ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method,
                 struct blob_attr *msg, ubus_data_handler_t cb, void *priv);
 
 /* asynchronous version of ubus_invoke() */
-void ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
-                       struct blob_attr *msg, struct ubus_request *req);
+int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
+                      struct blob_attr *msg, struct ubus_request *req);
 
 /* send a reply to an incoming object method call */
 int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req,