fix strange log on subscribe

This commit is contained in:
Martin/Geno 2018-07-19 13:46:41 +02:00
parent 691f8935c6
commit 6f3187767d
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 14 additions and 10 deletions

View File

@ -6,6 +6,7 @@
#include "ubus_events.h"
#include "ubus_service.h"
#define UBUS_SOCKET "/var/run/ubus.sock"
static struct ubus_context *ctx;
@ -18,7 +19,7 @@ int wifictld_ubus_init()
int ret = 0;
// connect to ubus
ctx = ubus_connect(NULL);
ctx = ubus_connect(UBUS_SOCKET);
if (!ctx) {
log_error("Failed to connect to ubus");
return 1;

View File

@ -11,8 +11,6 @@ bool client_probe_steering = true;
// steering contains learning already
bool client_probe_learning = false;
static struct blob_buf b;
// bind on every hostapd by receive all ubus registered services
static void recieve_interfaces(struct ubus_context *ctx, struct ubus_object_data *obj, void *priv);
@ -34,10 +32,8 @@ struct ubus_subscriber sub = {
*/
int wifictld_ubus_bind_events(struct ubus_context *ctx)
{
int ret = 0;
// register subscriber on ubus
ret = ubus_register_subscriber(ctx, &sub);
int ret = ubus_register_subscriber(ctx, &sub);
if (ret) {
log_error("Error while registering subscriber: %s", ubus_strerror(ret));
ubus_free(ctx);
@ -61,22 +57,29 @@ static void recieve_interfaces(struct ubus_context *ctx, struct ubus_object_data
if (lenpath < lenpre || strncmp(path_prefix, obj->path, lenpre) != 0) {
return;
}
char *path = malloc((lenpath+1) * sizeof(char));
strncpy(path, obj->path, lenpath);
path[lenpath] = '\0';
//change hostapd to wait for response
struct blob_buf b = {};
blob_buf_init(&b, 0);
blobmsg_add_u32(&b, str, 1);
ret = ubus_invoke(ctx, obj->id, str, b.head, NULL, NULL, 100);
blob_buf_free(&b);
if (ret) {
log_error("Error while register response for event '%s': %s\n", obj->path, ubus_strerror(ret));
log_error("Error while register response for event '%s': %s\n", path, ubus_strerror(ret));
}
//subscribe hostapd with THIS interface
ret = ubus_subscribe(ctx, &sub, obj->id);
if (ret) {
log_error("Error while register subscribe for event '%s': %s\n", obj->path, ubus_strerror(ret));
log_error("Error while register subscribe for event '%s': %s\n", path, ubus_strerror(ret));
}
log_info("subscribe %s: %d:%d\n", obj->path, obj->id, obj->type_id);
log_info("subscribe %s\n", path);
}

View File

@ -5,7 +5,7 @@
#include "wifi_clients.h"
#include "ubus_events.h"
static struct blob_buf b;
static struct blob_buf b = {};
static int ubus_get_clients(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg)