summaryrefslogtreecommitdiff
path: root/src/sock
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:43 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:43 +0200
commitf038883a6e004eb4312ba1e761da06b596e14d3f (patch)
tree358f989cac07885cfa913c66a0d563d18c021b26 /src/sock
parent98eac951f8087b213f5850bd126dcb279db360a8 (diff)
tagging ychat-0.7.7.0ychat-0.7.7.0
Diffstat (limited to 'src/sock')
-rw-r--r--src/sock/CVS/Entries4
-rwxr-xr-xsrc/sock/sock.cpp40
-rwxr-xr-xsrc/sock/sock.h25
3 files changed, 25 insertions, 44 deletions
diff --git a/src/sock/CVS/Entries b/src/sock/CVS/Entries
index 8431283..05cb6fc 100644
--- a/src/sock/CVS/Entries
+++ b/src/sock/CVS/Entries
@@ -1,3 +1,3 @@
-/sock.cpp/1.29/Sat Mar 5 12:43:37 2005//
-/sock.h/1.14/Sun Feb 27 06:28:53 2005//
+/sock.cpp/1.22/Mon Feb 21 01:55:50 2005//
+/sock.h/1.10/Mon Feb 21 01:55:50 2005//
D
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
index 42daf24..802a980 100755
--- a/src/sock/sock.cpp
+++ b/src/sock/sock.cpp
@@ -15,7 +15,9 @@ sock::sock()
{
this->b_run = true;
this->i_req = 0;
+ this->i_threads = 0;
this->req_parser = new reqp();
+ this->thrd_pool = new pool();
#ifdef LOGGING
this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
@@ -29,7 +31,7 @@ sock::~sock()
//<<*
void
-sock::chat_stream( int i_sock, user *p_user, map<string,string> &map_params )
+sock::chat_stream( int i_sock, user *p_user, hashmap<string> &map_params )
{
string s_msg( "\n" );
@@ -150,11 +152,10 @@ sock::read_write( int* p_sock )
{
wrap::system_message( READERR );
}
-
else
{
// stores the request params.
- map<string,string> map_params;
+ hashmap<string> map_params;
// get the s_rep ( s_html response which will be send imediatly to the client
struct sockaddr_in client;
@@ -164,21 +165,14 @@ sock::read_write( int* p_sock )
getpeername( i_sock, (struct sockaddr *)&client, (int*)&size);
#else
+
getpeername( i_sock, (struct sockaddr *)&client, &size);
#endif
-
- uint32_t &s_addr = client.sin_addr.s_addr;
- if ( (map_params["REMOTE_ADDR"] = get_elem(s_addr)) == "" )
- {
- map_params["REMOTE_ADDR"] = string(inet_ntoa(client.sin_addr));
- set_elem(map_params["REMOTE_ADDR"], s_addr);
- wrap::system_message(SOCKCAC+map_params["REMOTE_ADDR"]);
- }
- //map_params["REMOTE_ADDR"] = inet_ntoa_callback(&client.sin_addr);
+ map_params["REMOTE_ADDR"] = inet_ntoa(client.sin_addr);
//map_params["REMOTE_PORT"] = ntohs(client.sin_port);
- string s_rep = req_parser->parse(i_sock, string(c_req), map_params);
+ string s_rep = req_parser->parse( i_sock, string( c_req ), map_params );
#ifdef LOGGING
@@ -207,11 +201,11 @@ int
sock::start()
{
wrap::system_message( SOCKSRV );
- pool* p_pool = wrap::POOL;
#ifdef NCURSES
+
print_hits();
- p_pool->print_pool_size();
+ thrd_pool->print_pool_size();
#endif
int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
@@ -293,27 +287,13 @@ sock::start()
{
int *p_sock = new int;
*p_sock = i;
- p_pool->run( (void*) p_sock );
+ thrd_pool->run( (void*) p_sock );
FD_CLR( i, &active_fd_set );
}
}
}
}
-void
-sock::clean_ipcache()
-{
- int i_ipcachesize = wrap::CONF->get_int("httpd.ipcachesize");
- int i_currentsize = size();
-
- if ( i_currentsize > 0 && (i_ipcachesize == 0 || i_ipcachesize <= i_currentsize) )
- {
- wrap::system_message(
- SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")");
- clear();
- }
-}
-
#ifdef NCURSES
void
sock::print_hits()
diff --git a/src/sock/sock.h b/src/sock/sock.h
index 62f32ae..0d93543 100755
--- a/src/sock/sock.h
+++ b/src/sock/sock.h
@@ -10,34 +10,36 @@
#include <netinet/in.h>
#include <netdb.h>
+#include "../thrd/pool.h"
#include "../reqp.h"
#include "../chat/user.h"
-#include "../thrd/pool.h"
-#include "../maps/shashmap.h"
#ifdef LOGGING
#include "../logd.h"
#endif
+#include "../maps/hashmap.h"
+
using namespace std;
-class sock : protected shashmap
-< string, uint32_t, self_hash<uint32_t>, equals_allocator<uint32_t> >
+class sock
{
private:
-#ifdef LOGGING
- logd *log_daemon; // the log daemon
-#endif
-
// total number of server requests.
unsigned long long i_req;
+
bool b_run; // true while socket manager is running.
reqp *req_parser; // parses the http requests from clients.
+ pool *thrd_pool; // the thread pool.
+#ifdef LOGGING
+
+ logd *log_daemon; // the log daemon
+#endif
char *c_buffer; // char buffer!
- pthread_mutex_t mut_hits;
+ int i_threads; // total amount of threads inside the thread pool.
- static string inet_ntoa_callback(void* p_void);
+ pthread_mutex_t mut_hits;
public:
// creates a server socket.
@@ -59,10 +61,9 @@ public:
int read_write( int* p_sock );
int start();
- void clean_ipcache();
// the chat stream there all the chat messages will sent through.
- static void chat_stream( int i_sock, user* p_user, map<string,string> &map_params ); //<<
+ static void chat_stream( int i_sock, user* p_user, hashmap<string> &map_params ); //<<
#ifdef NCURSES