Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix command handling in the C client shell (phunt via fpj)
git-svn-id: https://svn.apache.org/repos/asf/zookeeper/branches/branch-3.4@1755750 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
fpj committed Aug 10, 2016
1 parent b70b160 commit 27ecf98
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -45,6 +45,8 @@ BUGFIXES:
ZOOKEEPER-2498: Potential resource leak in C client when processing
unexpected / out of order response (Michael Han via rgs)

Fix command handling in the C client shell (phunt via fpj)

IMPROVEMENTS:

ZOOKEEPER-2240 Make the three-node minimum more explicit in
Expand Down
7 changes: 6 additions & 1 deletion src/c/README
Expand Up @@ -72,7 +72,12 @@ tar downloaded from Apache please skip to step 2.
other document formats please use "./configure --help"


USING THE CLIENT
EXAMPLE/SAMPLE C CLIENT SHELL

NOTE: the ZooKeeper C client shell (cli_st and cli_mt) is meant as a
example/sample of ZooKeeper C client API usage. It is not a full
fledged client and not meant for production usage - see the Java
client shell for a fully featured shell.

You can test your client by running a zookeeper server (see
instructions on the project wiki page on how to run it) and connecting
Expand Down
18 changes: 17 additions & 1 deletion src/c/src/cli.c
Expand Up @@ -16,6 +16,14 @@
* limitations under the License.
*/

/**
* cli.c is a example/sample C client shell for ZooKeeper. It contains
* basic shell functionality which exercises some of the features of
* the ZooKeeper C client API. It is not a full fledged client and is
* not meant for production usage - see the Java client shell for a
* fully featured shell.
*/

#include <zookeeper.h>
#include <proto.h>
#include <stdlib.h>
Expand Down Expand Up @@ -540,7 +548,15 @@ int main(int argc, char **argv) {
}
if (argc > 2) {
if(strncmp("cmd:",argv[2],4)==0){
strcpy(cmd,argv[2]+4);
size_t cmdlen = strlen(argv[2]);
if (cmdlen > sizeof(cmd)) {
fprintf(stderr,
"Command length %zu exceeds max length of %zu\n",
cmdlen,
sizeof(cmd));
return 2;
}
strncpy(cmd, argv[2]+4, sizeof(cmd));
batchMode=1;
fprintf(stderr,"Batch mode: %s\n",cmd);
}else{
Expand Down

0 comments on commit 27ecf98

Please sign in to comment.