Hi Everybody;
I wrote a class that uses boost library to create thread. My thread function just do select operation for mysql database. Besides, I developed a client program to test server side, but server side gave 'segmentation error ' after fourth client request via socket.
void Thread::Start(void (*function)()){
boost::thread th(function);
th.join();
}
and
//my thread function
//connection part successfully works.
void tf(){
db.ConnectDatabase();
cout<<"db connected"<<endl;
MYSQL_RES* result= db.Select("SELECT * FROM store");
MYSQL_ROW row;
while((row = mysql_fetch_row(result)) != NULL ) {
printf("Store Name : %s\n", row[0]);
}
db.CloseDatabase();
cout<<"database closed"<<endl;
}
Output
---------
Database initialize started...
Database init finished
db connected
Query : SELECT * FROM store
Store Name : Kipa
Store Name : Kipa
Store Name : Kipa
Store Name : Best Buy
database closed
db connected
Query : SELECT * FROM store
Store Name : Kipa
Store Name : Kipa
Store Name : Kipa
Store Name : Best Buy
database closed
db connected
Query : SELECT * FROM store
Store Name : Kipa
Store Name : Kipa
Store Name : Kipa
Store Name : Best Buy
database closed
db connected
Query : SELECT * FROM store
Store Name : Kipa
Store Name : Kipa
Store Name : Kipa
Store Name : Best Buy
database closed
make: *** [run] Segmentation fault
Thank you..