Advertisement
Guest User

Untitled

a guest
Mar 24th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <pthread.h>
  2. #include <zdb/zdb.h>
  3.  
  4. URL_T url;
  5. ConnectionPool_T pool;
  6.  
  7. void* closeCon()
  8. {
  9.   ConnectionPool_stop(pool);
  10.   ConnectionPool_free(&pool);
  11.   URL_free(&url);
  12.   return NULL;
  13. }
  14.  
  15. int main(void)
  16. {
  17.  
  18.   // init connection
  19.   url = URL_new("mysql://localhost/sdfsInt?user=root&password=foobar");
  20.   pool = ConnectionPool_new(url);
  21.   ConnectionPool_start(pool);
  22.  
  23.  
  24.   // close connection, either "threaded" or unthreaded
  25.   // unthreaded close works fine,
  26.   // threaded connection close fails with:
  27.   //   Error in my_thread_global_end(): 1 threads didn't exit
  28. #if 0
  29.   closeCon();
  30. #else
  31.   pthread_t myThread;
  32.   pthread_create(&myThread, NULL, closeCon, NULL);
  33.   pthread_join(myThread, NULL);
  34. #endif
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement