Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
20  src/c/.gitignore
... ...
@@ -0,0 +1,20 @@
  1
+.libs
  2
+Makefile
  3
+Makefile.in
  4
+aclocal.m4
  5
+autom4te.cache
  6
+*.o
  7
+*.lo
  8
+*.la
  9
+load_gen*
  10
+missing
  11
+compile
  12
+config.*
  13
+configure
  14
+cli_mt
  15
+cli_st
  16
+depcomp
  17
+install-sh
  18
+libtool
  19
+ltmain.sh
  20
+stamp-h1
26  src/c/include/zookeeper.h
@@ -338,6 +338,32 @@ ZOOAPI zhandle_t *zookeeper_init(const char *host, watcher_fn fn,
338 338
 ZOOAPI int zookeeper_close(zhandle_t *zh);
339 339
 
340 340
 /**
  341
+ * \brief close the zookeeper handle and free up any resources.
  342
+ * 
  343
+ * After this call, the client session be valid up until the negotiated timeout
  344
+ * with the server. The function will flush any outstanding send requests
  345
+ * before return. As a result it may block.
  346
+ *
  347
+ * This differs from zookeeper_close, in that it allows the session to be resumed.
  348
+ *
  349
+ * This method should only be called only once on a zookeeper handle. Calling
  350
+ * twice will cause undefined (and probably undesirable behavior). Calling any other
  351
+ * zookeeper method after calling close is undefined behaviour and should be avoided.
  352
+ *
  353
+ * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  354
+ * \return a result code. Regardless of the error code returned, the zhandle 
  355
+ * will be destroyed and all resources freed. 
  356
+ *
  357
+ * ZOK - success
  358
+ * ZBADARGUMENTS - invalid input parameters
  359
+ * ZOPERATIONTIMEOUT - failed to flush the buffers within the specified timeout.
  360
+ * ZCONNECTIONLOSS - a network error occured while attempting to send request to server
  361
+ * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
  362
+ */
  363
+ZOOAPI int zookeeper_drop(zhandle_t *zh);
  364
+
  365
+
  366
+/**
341 367
  * \brief return the client session id, only valid if the connections
342 368
  * is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE)
343 369
  */
15  src/c/src/zookeeper.c
@@ -2281,7 +2281,7 @@ static int add_string_completion(zhandle_t *zh, int xid,
2281 2281
     return add_completion(zh, xid, COMPLETION_STRING, dc, data, 0,0);
2282 2282
 }
2283 2283
 
2284  
-int zookeeper_close(zhandle_t *zh)
  2284
+int close_or_drop(zhandle_t *zh, int close_session)
2285 2285
 {
2286 2286
     int rc=ZOK;
2287 2287
     if (zh==0)
@@ -2297,7 +2297,7 @@ int zookeeper_close(zhandle_t *zh)
2297 2297
         adaptor_finish(zh);
2298 2298
         return ZOK;
2299 2299
     }
2300  
-    if(zh->state==ZOO_CONNECTED_STATE){
  2300
+    if((zh->state==ZOO_CONNECTED_STATE) && (close_session == 1)){
2301 2301
         struct oarchive *oa;
2302 2302
         struct RequestHeader h = { .xid = get_xid(), .type = CLOSE_OP};
2303 2303
         LOG_INFO(("Closing zookeeper sessionId=%#llx to [%s]\n",
@@ -2329,6 +2329,17 @@ int zookeeper_close(zhandle_t *zh)
2329 2329
     return rc;
2330 2330
 }
2331 2331
 
  2332
+
  2333
+int zookeeper_close(zhandle_t *zh)
  2334
+{
  2335
+        return close_or_drop(zh, 1);
  2336
+}
  2337
+
  2338
+int zookeeper_drop(zhandle_t *zh)
  2339
+{
  2340
+        return close_or_drop(zh, 0);
  2341
+}
  2342
+
2332 2343
 static int isValidPath(const char* path, const int flags) {
2333 2344
     int len = 0;
2334 2345
     char lastc = '/';

No commit comments for this range

Something went wrong with that request. Please try again.