diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 16:20:55 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 16:20:55 +0000 |
| commit | 6fde6b0fe90abde84011202edd40fe46eb06af44 (patch) | |
| tree | ef760338c50b4df3ae9cca96347bca962fdbec7e /src/data | |
| parent | 55b08bd93257d32df76efc4e8e3f49311c39ee82 (diff) | |
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/con.cpp | 24 | ||||
| -rw-r--r-- | src/data/con.h | 24 | ||||
| -rw-r--r-- | src/data/con_base.cpp | 24 | ||||
| -rw-r--r-- | src/data/con_base.h | 24 | ||||
| -rw-r--r-- | src/data/data.cpp | 26 | ||||
| -rw-r--r-- | src/data/data.h | 24 | ||||
| -rw-r--r-- | src/data/data_base.cpp | 39 | ||||
| -rw-r--r-- | src/data/data_base.h | 25 |
8 files changed, 16 insertions, 194 deletions
diff --git a/src/data/con.cpp b/src/data/con.cpp index c60cd66..b3aebcc 100644 --- a/src/data/con.cpp +++ b/src/data/con.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/con.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "con.h" using namespace std; diff --git a/src/data/con.h b/src/data/con.h index ca09626..9fda07b 100644 --- a/src/data/con.h +++ b/src/data/con.h @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/con.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "../incl.h" #ifdef DATABASE diff --git a/src/data/con_base.cpp b/src/data/con_base.cpp index 98baab9..003a376 100644 --- a/src/data/con_base.cpp +++ b/src/data/con_base.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/con_base.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "con_base.h" #ifdef DATABASE diff --git a/src/data/con_base.h b/src/data/con_base.h index 35853b2..9ebb89e 100644 --- a/src/data/con_base.h +++ b/src/data/con_base.h @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/con_base.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "../incl.h" #ifdef DATABASE diff --git a/src/data/data.cpp b/src/data/data.cpp index a401dab..fa509dd 100644 --- a/src/data/data.cpp +++ b/src/data/data.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/data.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "data.h" #ifdef DATABASE @@ -94,7 +70,7 @@ data::parse_result( MYSQL_RES* p_result, vector<string>& vec_elements ) vector<string>::iterator vec_iter = vec_elements.begin(); vec_iter++; - while ( (row = mysql_fetch_row(p_result)) ) + while( (row = mysql_fetch_row(p_result)) ) for ( int i=0; i < mysql_num_fields(p_result); i++, vec_iter++ ) map_ret[*vec_iter] = string(row[i]); diff --git a/src/data/data.h b/src/data/data.h index e0281db..a6ca90f 100644 --- a/src/data/data.h +++ b/src/data/data.h @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/data.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "../incl.h" #ifdef DATABASE diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp index 57705e0..61fc141 100644 --- a/src/data/data_base.cpp +++ b/src/data/data_base.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/data_base.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "data_base.h" #ifdef DATABASE @@ -32,6 +8,7 @@ using namespace std; data_base::data_base( ) { + pthread_mutex_init ( &mut_con, NULL ); vector<string> vec_keys = *wrap::CONF->get_key_vector(); vector<string>::iterator iter; @@ -83,7 +60,9 @@ void data_base::init_connections() } data_base::~data_base() -{} +{ + pthread_mutex_destroy ( &mut_con ); +} hashmap<string> data_base::select_user_data( string s_user, string s_query) @@ -125,16 +104,19 @@ data_base::print_query_( string s_query ) con* data_base::get_con() { + pthread_mutex_lock( &mut_con ); if ( empty() ) { wrap::system_message( DATANEW + string("(") + tool::int2string(size()+1) + ")" ); + pthread_mutex_unlock( &mut_con ); return new con; } else if ( size() > i_max_con-1 ) { wrap::system_message( DATAMAX + string("(") + tool::int2string(i_max_con) + ")" ); usleep( 5000000 ); + pthread_mutex_unlock( &mut_con ); return get_con(); } @@ -142,6 +124,7 @@ data_base::get_con() con* p_con = *begin(); pop_front(); + pthread_mutex_unlock( &mut_con ); wrap::system_message( DATAGET ); p_con->renew_timeout(); @@ -151,8 +134,10 @@ data_base::get_con() void data_base::push_con( con* p_con ) { + pthread_mutex_lock( &mut_con ); push_front( p_con ); + pthread_mutex_unlock( &mut_con ); wrap::system_message( DATAADD ); } @@ -160,6 +145,7 @@ void data_base::disconnect_all_connections() { wrap::system_message( DATADIS ); + pthread_mutex_lock( &mut_con ); while ( !empty() ) { @@ -168,6 +154,7 @@ data_base::disconnect_all_connections() delete p_con; } + pthread_mutex_unlock( &mut_con ); } void @@ -176,6 +163,7 @@ data_base::check_data_con_timeout() int i_timeout_time = tool::string2int(wrap::CONF->get_elem("chat.database.contimeout")); int i_last_activity; + pthread_mutex_lock( &mut_con ); list< list<con*>::iterator > erase_list; for ( list<con*>::iterator iter = begin(); @@ -196,6 +184,7 @@ data_base::check_data_con_timeout() erase_iter != erase_list.end(); erase_iter++ ) erase( *erase_iter ); + pthread_mutex_unlock( &mut_con ); } diff --git a/src/data/data_base.h b/src/data/data_base.h index 834aea3..dbad3f0 100644 --- a/src/data/data_base.h +++ b/src/data/data_base.h @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/data/data_base.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ #include "../incl.h" #ifdef DATABASE @@ -37,6 +13,7 @@ using namespace std; class data_base : protected list<con*> { private: + pthread_mutex_t mut_con; int i_max_con; protected: |
