add psmb_destroy()
authorEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 12:05:09 +0000 (13:05 +0100)
committerEugene Crosser <evgenii.cherkashin@cloud.ionos.com>
Wed, 13 Mar 2019 12:05:09 +0000 (13:05 +0100)
Signed-off-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
src/psmb_socket.c

index a3c718a9902334f9804cb6fa8338e3b1f9816961..28344a7a65c04138712f1dc5922a37e167a3b2e7 100644 (file)
@@ -138,3 +138,15 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx)
        }
        return (psmb_result_t){PSMB_OK};
 }
+
+void psmb_destroy(psmb_ctx_t *ctx)
+{
+       if (ctx->fd == -1) {
+               LOG(ctx, LOG_ERR, "psmb_ctx is not open");
+       } else {
+               if (close(ctx->fd) == -1)
+                       LOG(ctx, LOG_ERR, "close(): %m");
+       }
+       /* clean up the rest */
+       (*ctx->free)(ctx);
+}