summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6e419a8)
raw | patch | inline | side by side (parent: 6e419a8)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 2 Mar 2009 14:27:12 +0000 (15:27 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 2 Mar 2009 14:27:12 +0000 (15:27 +0100) |
And free allocated memory when connecting fails. Only assign anything to
the user-provided pointer if `lcc_connect' succeeds. This should make
error-handling much more straight-forward.
the user-provided pointer if `lcc_connect' succeeds. This should make
error-handling much more straight-forward.
src/libcollectdclient/client.c | patch | blob | history |
index 93eadb752c3c5ec0b81ff2d74e0521b8e17b0ef2..684fa39baabc8afb5069cb2616eea26bdefcc2c5 100644 (file)
lcc_response_t res;
int status;
+ if (c->fh == NULL)
+ {
+ lcc_set_errno (c, EBADF);
+ return (-1);
+ }
+
status = lcc_send (c, command);
if (status != 0)
return (status);
int lcc_connect (const char *address, lcc_connection_t **ret_con) /* {{{ */
{
lcc_connection_t *c;
+ int status;
if (address == NULL)
return (-1);
return (-1);
memset (c, 0, sizeof (*c));
+ status = lcc_open_socket (c, address);
+ if (status != 0)
+ {
+ lcc_disconnect (c);
+ return (status);
+ }
+
*ret_con = c;
- return (lcc_open_socket (c, address));
+ return (0);
} /* }}} int lcc_connect */
int lcc_disconnect (lcc_connection_t *c) /* {{{ */