Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Zookeeper >> mail # user >> simple zookeeper client in C


Copy link to this message
-
simple zookeeper client in C
Hi ,

I am trying out a simple c client for zookeeper, made a copy of zookeeper-3.4.5/src/c/src/cli.c just to understand how the c APIs works, the program is attached.

I see errors/coredumps being generated, I am surely doing something wrong, any help appreciated.

case 1:

.../zookeeper-3.4.5/src/c> ./myt localhost:2181
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
Segmentation fault (core dumped)

starting it under gdb:
(gdb) r localhost:2181
Starting program: .../zookeeper-3.4.5/src/c/myt localhost:2181
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff70d9700 (LWP 9489)]
[New Thread 0x7ffff68d8700 (LWP 9490)]
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
2013-05-21 15:58:03,210:9485(0x7ffff7fd7700):ZOO_ERROR@handle_socket_error_msg@1643: Socket [127.0.0.1:2181] zk retcode=-7, errno=110(Connection timed out): connection to 127.0.0.1:2181 timed out (exceeded timeout by 1ms)
2013-05-21 15:58:03,210:9485(0x7ffff70d9700):ZOO_ERROR@handle_socket_error_msg@1643: Socket [127.0.0.1:2181] zk retcode=-7, errno=110(Connection timed out): connection to 127.0.0.1:2181 timed out (exceeded timeout by 2ms)
Watcher SESSION_EVENT state = CONNECTING_STATE
Watcher SESSION_EVENT state = CONNECTING_STATE
2013-05-21 15:58:13,212:9485(0x7ffff7fd7700):ZOO_WARN@zookeeper_interest@1557: Exceeded deadline by 10003ms
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...

Program received signal SIGSEGV, Segmentation fault.
queue_buffer (list=0x6030b8, b=0x0, add_to_front=0) at src/zookeeper.c:970
970         b->next = 0;
(gdb) bt
#0  queue_buffer (list=0x6030b8, b=0x0, add_to_front=0) at src/zookeeper.c:970
#1  0x00007ffff7bc939d in check_events (events=<optimized out>, zh=0x603040) at src/zookeeper.c:1727
#2  zookeeper_process (zh=0x603040, events=<optimized out>) at src/zookeeper.c:2170
#3  0x0000000000401448 in main (argc=2, argv=0x7fffffffeab8) at mytest.c:542

case 2:

2013-05-21 15:49:25,811:2493(0x7fae0ec17700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,812:2493(0x7fae0fb16700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,813:2493(0x7fae0ec17700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,814:2493(0x7fae0fb16700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,814:2493(0x7fae0ec17700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,815:2493(0x7fae0fb16700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 15:49:25,816:2493(0x7fae0ec17700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
Segmentation fault (core dumped)

under gdb:
2013-05-21 16:05:13,598:10413(0x7ffff7fd7700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 16:05:13,598:10413(0x7ffff70d9700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 16:05:13,599:10413(0x7ffff7fd7700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed
2013-05-21 16:05:13,599:10413(0x7ffff70d9700):ZOO_ERROR@handle_socket_error_msg@1579: Socket [:0] zk retcode=-1, errno=97(Address family not supported by protocol): socket() call failed

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff70d9700 (LWP 10415)]
zookeeper_interest (zh=0x603040, fd=0x7ffff70d8e38, interest=0x7ffff70d8e3c, tv=0x7ffff70d8e20)
    at src/zookeeper.c:1577
1577                zh->fd = socket(zh->addrs[zh->connect_index].ss_family, SOCK_STREAM, 0);
(gdb) bt
#0  zookeeper_interest (zh=0x603040, fd=0x7ffff70d8e38, interest=0x7ffff70d8e3c, tv=0x7ffff70d8e20)
    at src/zookeeper.c:1577
#1  0x00007ffff7bd1361 in do_io (v=0x603040) at src/mt_adaptor.c:378
#2  0x00007ffff72eee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#3  0x00007ffff78f3cbd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x0000000000000000 in ?? ()
case 3
zookeeper-3.4.5/src/c> ./myt localhost:2181
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
2013-05-21 15:54:04,078:7030(0x7f36727cf700):ZOO_ERROR@handle_socket_error_msg@1643: Socket [127.0.0.1:2181] zk retcode=-7, errno=110(Connection timed out): connection to 127.0.0.1:2181 timed out (exceeded timeout by 7ms)
Watcher SESSION_EVENT state = CONNECTING_STATE
Watcher SESSION_EVENT state = CONNECTED_STATE
Connected ...
2013-05-21 15:54:24,085:7030(0x7f36736ce700):ZOO_ERROR@handle_socket_error_msg@2245: Socket [127.0.0.1:2181] zk retcode=-2, errno=115(Operation now in progress): unexpected server response: expected 0x14584484, but received 0xfffffffe
Watcher SESSION_EVENT state = CONNECTING_STATE
2013-05-21 15:54:34,088:7030(0x7f36727cf700):ZOO_ERROR@handle_socket_error_msg@1721: Socket [127.0.0.1:2181] zk retcode=-4, errno=112(Host is down): failed while receiving a server response
2013-05-21 15:54:34,091:7030(0x7f36736ce700):ZOO_ERROR@handle_socket_error_msg@1721: Socket [127.0.0.1:2181] zk retcode=-4, errno=112(Host is down): failed while
+
Pramod Srinivasan 2013-05-22, 01:25