projects
/
NeonServV5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added stats module for neonserv.krypton-bouncer.de stats
[NeonServV5.git]
/
src
/
ClientSocket.c
diff --git
a/src/ClientSocket.c
b/src/ClientSocket.c
index c49577724393e3de6b1443841072ff8e1ed46105..d1f80ff8773358a09a9c557b216afbea9c8490c8 100644
(file)
--- a/
src/ClientSocket.c
+++ b/
src/ClientSocket.c
@@
-1,4
+1,4
@@
-/* ClientSocket.c - NeonServ v5.
3
+/* ClientSocket.c - NeonServ v5.
4
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
@@
-35,7
+35,7
@@
static pthread_mutex_t synchronized;
static pthread_mutex_t synchronized_recv;
struct ParseOrder {
static pthread_mutex_t synchronized_recv;
struct ParseOrder {
- unsigned
long
tid;
+ unsigned
int
tid;
struct ParseOrder *next;
};
struct ParseOrder *parse_order = NULL;
struct ParseOrder *next;
};
struct ParseOrder *parse_order = NULL;
@@
-74,6
+74,7
@@
struct ClientSocket* create_socket(char *host, int port, char *bindto, char *pas
client->ident = strdup(ident);
client->realname = strdup(realname);
client->user = NULL;
client->ident = strdup(ident);
client->realname = strdup(realname);
client->user = NULL;
+ client->network_name = NULL;
client->flags = 0;
client->bufferpos = 0;
client->traffic_in = 0;
client->flags = 0;
client->bufferpos = 0;
client->traffic_in = 0;
@@
-230,7
+231,7
@@
static int _connect_socket(struct ClientSocket *client) {
return 1;
}
#else
return 1;
}
#else
-static int connect_socket(struct ClientSocket *client) {
+static int
_
connect_socket(struct ClientSocket *client) {
if((client->flags & SOCKET_FLAG_CONNECTED)) return 1;
struct hostent *host;
struct sockaddr_in addr;
if((client->flags & SOCKET_FLAG_CONNECTED)) return 1;
struct hostent *host;
struct sockaddr_in addr;
@@
-344,6
+345,8
@@
static void destroy_socket(struct ClientSocket *client, int free_socket) {
free(client->bind);
if(client->pass)
free(client->pass);
free(client->bind);
if(client->pass)
free(client->pass);
+ if(client->network_name)
+ free(client->network_name);
free(client);
} else if(client->flags & SOCKET_FLAG_FAST_JUMP) {
client->flags &= ~SOCKET_FLAG_FAST_JUMP;
free(client);
} else if(client->flags & SOCKET_FLAG_FAST_JUMP) {
client->flags &= ~SOCKET_FLAG_FAST_JUMP;
@@
-354,7
+357,11
@@
static void destroy_socket(struct ClientSocket *client, int free_socket) {
int write_socket_force(struct ClientSocket *client, char* msg, int len) {
SYNCHRONIZE(synchronized);
int write_socket_force(struct ClientSocket *client, char* msg, int len) {
SYNCHRONIZE(synchronized);
- printf("[send %d] %s", len, msg);
+ #ifdef HAVE_THREADS
+ putlog(LOGLEVEL_RAW, "[%d send %d] %s", getCurrentThreadID(), len, msg);
+ #else
+ putlog(LOGLEVEL_RAW, "[send %d] %s", len, msg);
+ #endif
if(!(client->flags & SOCKET_FLAG_HAVE_SSL) || ssl_write(client, msg, len) == -2) {
#ifdef WIN32
send(client->sock, msg, len, 0);
if(!(client->flags & SOCKET_FLAG_HAVE_SSL) || ssl_write(client, msg, len) == -2) {
#ifdef WIN32
send(client->sock, msg, len, 0);
@@
-376,7
+383,7
@@
int write_socket(struct ClientSocket *client, char* msg, int len) {
}
#if HAVE_THREADS
}
#if HAVE_THREADS
-static void clientsocket_start_of_recv(unsigned
long
tid) {
+static void clientsocket_start_of_recv(unsigned
int
tid) {
SYNCHRONIZE(whohandler_sync);
struct ParseOrder *entry, *last;
for(last = parse_order; last; last = last->next) {
SYNCHRONIZE(whohandler_sync);
struct ParseOrder *entry, *last;
for(last = parse_order; last; last = last->next) {
@@
-393,7
+400,7
@@
static void clientsocket_start_of_recv(unsigned long tid) {
DESYNCHRONIZE(whohandler_sync);
}
DESYNCHRONIZE(whohandler_sync);
}
-static void clientsocket_end_of_recv(unsigned
long
tid) {
+static void clientsocket_end_of_recv(unsigned
int
tid) {
SYNCHRONIZE(whohandler_sync);
struct ParseOrder *entry, *last = NULL;
for(entry = parse_order; entry; entry = entry->next) {
SYNCHRONIZE(whohandler_sync);
struct ParseOrder *entry, *last = NULL;
for(entry = parse_order; entry; entry = entry->next) {
@@
-410,7
+417,7
@@
static void clientsocket_end_of_recv(unsigned long tid) {
DESYNCHRONIZE(whohandler_sync);
}
DESYNCHRONIZE(whohandler_sync);
}
-int clientsocket_parseorder_top(unsigned
long
tid) {
+int clientsocket_parseorder_top(unsigned
int
tid) {
if(parse_order && parse_order->tid == tid)
return 1;
else
if(parse_order && parse_order->tid == tid)
return 1;
else
@@
-418,8
+425,8
@@
int clientsocket_parseorder_top(unsigned long tid) {
}
#endif
}
#endif
-
void
socket_loop(int timeout_seconds) {
- if(sockets == NULL) return;
+
int
socket_loop(int timeout_seconds) {
+ if(sockets == NULL) return
0
;
int is_synchronized = 1;
SYNCHRONIZE(synchronized_recv);
fd_set fds;
int is_synchronized = 1;
SYNCHRONIZE(synchronized_recv);
fd_set fds;
@@
-439,7
+446,7
@@
void socket_loop(int timeout_seconds) {
ret = select(ret + 1, &fds, NULL, NULL, &timeout);
if(ret == 0) {
DESYNCHRONIZE(synchronized_recv);
ret = select(ret + 1, &fds, NULL, NULL, &timeout);
if(ret == 0) {
DESYNCHRONIZE(synchronized_recv);
- return;
+ return
1
;
}
for (sock = sockets->data; sock; sock = next) {
next = sock->next;
}
for (sock = sockets->data; sock; sock = next) {
next = sock->next;
@@
-494,7
+501,7
@@
void socket_loop(int timeout_seconds) {
sock->bufferpos -= used;
}
is_synchronized = 0;
sock->bufferpos -= used;
}
is_synchronized = 0;
- unsigned
long tid = syscall(SYS_gettid
);
+ unsigned
int tid = (unsigned int) pthread_self_tid(
);
clientsocket_start_of_recv(tid);
DESYNCHRONIZE(synchronized_recv);
parse_lines(sock, linesbuf, used);
clientsocket_start_of_recv(tid);
DESYNCHRONIZE(synchronized_recv);
parse_lines(sock, linesbuf, used);
@@
-530,6
+537,7
@@
void socket_loop(int timeout_seconds) {
if(is_synchronized) {
DESYNCHRONIZE(synchronized_recv);
}
if(is_synchronized) {
DESYNCHRONIZE(synchronized_recv);
}
+ return (ret + 1);
}
void
}
void
@@
-575,6
+583,8
@@
void free_sockets() {
free(client->bind);
if(client->pass)
free(client->pass);
free(client->bind);
if(client->pass)
free(client->pass);
+ if(client->network_name)
+ free(client->network_name);
free(client);
}
free(sockets);
free(client);
}
free(sockets);