Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: slyphon/apache-zookeeper
...
head fork: slyphon/apache-zookeeper
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
20 src/c/.gitignore
@@ -0,0 +1,20 @@
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+*.o
+*.lo
+*.la
+load_gen*
+missing
+compile
+config.*
+configure
+cli_mt
+cli_st
+depcomp
+install-sh
+libtool
+ltmain.sh
+stamp-h1
View
26 src/c/include/zookeeper.h
@@ -338,6 +338,32 @@ ZOOAPI zhandle_t *zookeeper_init(const char *host, watcher_fn fn,
ZOOAPI int zookeeper_close(zhandle_t *zh);
/**
+ * \brief close the zookeeper handle and free up any resources.
+ *
+ * After this call, the client session be valid up until the negotiated timeout
+ * with the server. The function will flush any outstanding send requests
+ * before return. As a result it may block.
+ *
+ * This differs from zookeeper_close, in that it allows the session to be resumed.
+ *
+ * This method should only be called only once on a zookeeper handle. Calling
+ * twice will cause undefined (and probably undesirable behavior). Calling any other
+ * zookeeper method after calling close is undefined behaviour and should be avoided.
+ *
+ * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
+ * \return a result code. Regardless of the error code returned, the zhandle
+ * will be destroyed and all resources freed.
+ *
+ * ZOK - success
+ * ZBADARGUMENTS - invalid input parameters
+ * ZOPERATIONTIMEOUT - failed to flush the buffers within the specified timeout.
+ * ZCONNECTIONLOSS - a network error occured while attempting to send request to server
+ * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
+ */
+ZOOAPI int zookeeper_drop(zhandle_t *zh);
+
+
+/**
* \brief return the client session id, only valid if the connections
* is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE)
*/
View
15 src/c/src/zookeeper.c
@@ -2281,7 +2281,7 @@ static int add_string_completion(zhandle_t *zh, int xid,
return add_completion(zh, xid, COMPLETION_STRING, dc, data, 0,0);
}
-int zookeeper_close(zhandle_t *zh)
+int close_or_drop(zhandle_t *zh, int close_session)
{
int rc=ZOK;
if (zh==0)
@@ -2297,7 +2297,7 @@ int zookeeper_close(zhandle_t *zh)
adaptor_finish(zh);
return ZOK;
}
- if(zh->state==ZOO_CONNECTED_STATE){
+ if((zh->state==ZOO_CONNECTED_STATE) && (close_session == 1)){
struct oarchive *oa;
struct RequestHeader h = { .xid = get_xid(), .type = CLOSE_OP};
LOG_INFO(("Closing zookeeper sessionId=%#llx to [%s]\n",
@@ -2329,6 +2329,17 @@ int zookeeper_close(zhandle_t *zh)
return rc;
}
+
+int zookeeper_close(zhandle_t *zh)
+{
+ return close_or_drop(zh, 1);
+}
+
+int zookeeper_drop(zhandle_t *zh)
+{
+ return close_or_drop(zh, 0);
+}
+
static int isValidPath(const char* path, const int flags) {
int len = 0;
char lastc = '/';

No commit comments for this range

Something went wrong with that request. Please try again.