projects
/
project
/
ubus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libubus: reset ctx->sock.eof to fix reconnect issues
[project/ubus.git]
/
libubus.c
diff --git
a/libubus.c
b/libubus.c
index bfbaeb6565905f2614e202fc8c25d265fd1ca52c..9463522488c11782dc9c15c79f1932b37e1149c1 100644
(file)
--- a/
libubus.c
+++ b/
libubus.c
@@
-103,7
+103,7
@@
ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
break;
}
break;
}
- ubus_process_obj_msg(ctx, buf);
+ ubus_process_obj_msg(ctx, buf
, fd
);
break;
case UBUS_MSG_MONITOR:
if (ctx->monitor_cb)
break;
case UBUS_MSG_MONITOR:
if (ctx->monitor_cb)
@@
-277,6
+277,7
@@
static void ubus_default_connection_lost(struct ubus_context *ctx)
int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
{
int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
{
+ uloop_init();
memset(ctx, 0, sizeof(*ctx));
ctx->sock.fd = -1;
memset(ctx, 0, sizeof(*ctx));
ctx->sock.fd = -1;
@@
-294,6
+295,7
@@
int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
avl_init(&ctx->objects, ubus_cmp_id, false, NULL);
if (ubus_reconnect(ctx, path)) {
free(ctx->msgbuf.data);
avl_init(&ctx->objects, ubus_cmp_id, false, NULL);
if (ubus_reconnect(ctx, path)) {
free(ctx->msgbuf.data);
+ ctx->msgbuf.data = NULL;
return -1;
}
return -1;
}
@@
-358,7
+360,10
@@
struct ubus_context *ubus_connect(const char *path)
void ubus_shutdown(struct ubus_context *ctx)
{
blob_buf_free(&b);
void ubus_shutdown(struct ubus_context *ctx)
{
blob_buf_free(&b);
+ if (!ctx)
+ return;
close(ctx->sock.fd);
close(ctx->sock.fd);
+ uloop_timeout_cancel(&ctx->pending_timer);
free(ctx->msgbuf.data);
}
free(ctx->msgbuf.data);
}