Open jiangrong2001 opened 6 years ago
(gdb) thread apply all bt
Thread 3 (Thread 0x7ffff053f700 (LWP 34885)):
Thread 2 (Thread 0x7ffff0d40700 (LWP 34884)):
userdata=0x7ffff053ec10) at cetcd.c:1003
Thread 1 (Thread 0x7ffff7fe0840 (LWP 34867)):
(gdb)
pthread_mutex_t unTimerLock; /**/
cetcd_client cli;
void get_tread1(int ThreadId) { cetcd_response *resp; while(1) { ETCD_TIMER_LOCK(); resp = cetcd_get(&cli, "/test_query"); ETCD_TIMER_UNLOCK(); if (resp->err) { printf("get_tread1 cetcd_get error :%d, %s (%s)\n", resp->err->ecode, resp->err->message, resp->err->cause); } else { //printf("get_tread1 cetcd_tty OK:%s\n", resp->node->value); } cetcd_response_release(resp);
} return 0;
}
void get_tread2(int ThreadId) { cetcd_response *resp; sleep(2);
while(1) { ETCD_TIMER_LOCK(); resp = cetcd_get(&cli, "/test_query"); ETCD_TIMER_UNLOCK(); if (resp->err) { printf("get_tread2 cetcd_get error :%d, %s (%s)\n", resp->err->ecode, resp->err->message, resp->err->cause); } else { //printf("get_tread2 cetcd_tty OK:%s\n", resp->node->value); } cetcd_response_release(resp); } return 0;
int main(int argc, char argv[]) { cetcd_response resp; cetcd_array addrs; pthread_t thread1; pthread_t thread2; pthread_mutex_init(&unTimerLock, 0); int ThreadId1 = 1; int ThreadId2 = 1;
cetcd_array_init(&addrs, 1); cetcd_array_append(&addrs, "http://171.19.0.1:2379"); cetcd_client_init(&cli, &addrs); printf("connnect to http://171.19.0.1:2379"); resp = cetcd_create(&cli, "/test_tty", "hello cetcd", 0); if(resp->err) { printf("error :%d, %s (%s)\n", resp->err->ecode, resp->err->message, resp->err->cause); } resp = cetcd_create(&cli, "/test_query", "hello cetcd query", 0); if(resp->err) { printf("error :%d, %s (%s)\n", resp->err->ecode, resp->err->message, resp->err->cause); } pthread_create(&thread1, NULL, (void *(*)(void *))get_tread1, 0); pthread_create(&thread2, NULL, (void *(*)(void *))get_tread2, 0); while(1) { sleep(1); } cetcd_array_destroy(&addrs); cetcd_client_destroy(&cli); return 0;
(gdb) thread apply all bt
Thread 3 (Thread 0x7ffff053f700 (LWP 34885)):
0 0x00007ffff76cff4d in write () from /lib64/libc.so.6
1 0x00007ffff765e363 in _IO_new_file_write () from /lib64/libc.so.6
2 0x00007ffff765f7cc in GIIO_do_write () from /lib64/libc.so.6
3 0x00007ffff765ea01 in GIIO_file_xsputn () from /lib64/libc.so.6
4 0x00007ffff7630a4d in vfprintf () from /lib64/libc.so.6
5 0x00007ffff7639c79 in printf () from /lib64/libc.so.6
6 0x00007ffff7bcfffb in cetcd_send_request (curl=0x60aa50, req=0x7ffff053ed80) at cetcd.c:1186
7 0x00007ffff7bd0154 in cetcd_cluster_request (cli=0x6020c0, req=0x7ffff053ed80) at cetcd.c:1221
8 0x00007ffff7bce188 in cetcd_lsdir (cli=0x6020c0, key=0x400e01 "/test_query", sort=0, recursive=0) at cetcd.c:538
9 0x00007ffff7bce0b8 in cetcd_get (cli=0x6020c0, key=0x400e01 "/test_query") at cetcd.c:522
10 0x0000000000400b84 in get_tread2 (ThreadId=0x0) at cetcd_set.c:65
11 0x00007ffff79b0dc5 in start_thread () from /lib64/libpthread.so.0
12 0x00007ffff76de71d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7ffff0d40700 (LWP 34884)):
0 0x00007ffff761d5d7 in raise () from /lib64/libc.so.6
1 0x00007ffff761ecc8 in abort () from /lib64/libc.so.6
2 0x00007ffff765d2f7 in __libc_message () from /lib64/libc.so.6
3 0x00007ffff76646d3 in _int_free () from /lib64/libc.so.6
4 0x00007ffff7bc9b02 in sdsMakeRoomFor (s=0x7fffe8000983 "lication/json", addlen=1) at sds/sds.c:233
5 0x00007ffff7bca131 in sdscatlen (s=0x7fffe8000983 "lication/json", t=0x613d20, len=1) at sds/sds.c:389
6 0x00007ffff7bcf628 in cetcd_parse_response (ptr=0x613d20 "Content-Type: application/json\r\n", size=1, nmemb=32,
7 0x00007ffff737b9c2 in Curl_client_chop_write () from /lib64/libcurl.so.4
8 0x00007ffff7379d93 in Curl_http_readwrite_headers () from /lib64/libcurl.so.4
9 0x00007ffff738cbc8 in Curl_readwrite () from /lib64/libcurl.so.4
10 0x00007ffff7397351 in multi_runsingle () from /lib64/libcurl.so.4
11 0x00007ffff7397df9 in curl_multi_perform () from /lib64/libcurl.so.4
12 0x00007ffff738e745 in curl_easy_perform () from /lib64/libcurl.so.4
13 0x00007ffff7bcfefe in cetcd_send_request (curl=0x60aa50, req=0x7ffff0d3fd80) at cetcd.c:1166
14 0x00007ffff7bd0154 in cetcd_cluster_request (cli=0x6020c0, req=0x7ffff0d3fd80) at cetcd.c:1221
15 0x00007ffff7bce188 in cetcd_lsdir (cli=0x6020c0, key=0x400e01 "/test_query", sort=0, recursive=0) at cetcd.c:538
16 0x00007ffff7bce0b8 in cetcd_get (cli=0x6020c0, key=0x400e01 "/test_query") at cetcd.c:522
17 0x0000000000400b11 in get_tread1 (ThreadId=0x0) at cetcd_set.c:39
18 0x00007ffff79b0dc5 in start_thread () from /lib64/libpthread.so.0
19 0x00007ffff76de71d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7ffff7fe0840 (LWP 34867)):
0 0x00007ffff76a596d in nanosleep () from /lib64/libc.so.6
1 0x00007ffff76a5804 in sleep () from /lib64/libc.so.6
2 0x0000000000400d32 in main (argc=1, argv=0x7fffffffe618) at cetcd_set.c:130
(gdb)
test code below:
include "../cetcd.h"
include
pthread_mutex_t unTimerLock; /**/
define ETCD_TIMER_LOCK() //pthread_mutex_lock(&unTimerLock)
define ETCD_TIMER_UNLOCK() //pthread_mutex_unlock(&unTimerLock)
cetcd_client cli;
void get_tread1(int ThreadId) { cetcd_response *resp; while(1) { ETCD_TIMER_LOCK(); resp = cetcd_get(&cli, "/test_query"); ETCD_TIMER_UNLOCK(); if (resp->err) { printf("get_tread1 cetcd_get error :%d, %s (%s)\n", resp->err->ecode, resp->err->message, resp->err->cause); } else { //printf("get_tread1 cetcd_tty OK:%s\n", resp->node->value); } cetcd_response_release(resp);
}
void get_tread2(int ThreadId) { cetcd_response *resp; sleep(2);
}
int main(int argc, char argv[]) { cetcd_response resp; cetcd_array addrs; pthread_t thread1; pthread_t thread2; pthread_mutex_init(&unTimerLock, 0); int ThreadId1 = 1; int ThreadId2 = 1;
}