Fix bad memory access at client disconnection
[src/app-framework-binder.git] / src / afs-supervisor.c
index f4ceb51..31b8b7c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
+ * Copyright (C) 2016-2019 "IoT.bzh"
  * Author José Bollo <jose.bollo@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -225,7 +225,7 @@ static int make_supervised(int fd, struct afb_cred *cred)
        s->next = superviseds;
        superviseds = s;
        pthread_mutex_unlock(&mutex);
-       afb_stub_ws_on_hangup(s->stub, on_supervised_hangup);
+       afb_stub_ws_set_on_hangup(s->stub, on_supervised_hangup);
        return 0;
 }
 
@@ -282,7 +282,7 @@ static void listening(void *closure, uint32_t revents, struct fdev *fdev)
 {
        if ((revents & EPOLLIN) != 0)
                accept_supervision_link((int)(intptr_t)closure);
-       if ((revents & EPOLLHUP) != 0) {
+       else if ((revents & EPOLLHUP) != 0) {
                ERROR("supervision socket closed");
                exit(1);
        }