* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#include "main.h"
#include "ClientSocket.h"
#include "IRCParser.h"
#include "UserNode.h"
#include "version.h"
#include "IOHandler.h"
#include "IRCEvents.h"
+#include "log.h"
struct socket_list {
struct ClientSocket *data;
sockets = malloc(sizeof(*sockets));
if (!sockets)
{
- perror("malloc() failed");
+ printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
return;
}
sockets->data = NULL;
if(!(client && (client->flags & SOCKET_FLAG_CONNECTED))) return 0;
SYNCHRONIZE(synchronized);
#ifdef HAVE_THREADS
- putlog(LOGLEVEL_RAW, "[%d send %d] %s", getCurrentThreadID(), len, msg);
+ printf_log("main", LOG_IRCRAW, "[%d send %d] %s", getCurrentThreadID(), len, msg);
#else
- putlog(LOGLEVEL_RAW, "[send %d] %s", len, msg);
+ printf_log("main", LOG_IRCRAW, "[send %d] %s", len, msg);
#endif
iohandler_send(client->iofd, msg, len);
client->traffic_out += len;
#ifdef HAVE_THREADS
unsigned int tid;
#endif
+ if(process_state.running == 0)
+ return; //just ignore the event (shutdown sequence)
switch(event->type) {
case IOEVENT_CONNECTED:
client->flags |= SOCKET_FLAG_CONNECTED;
} else
destroy_socket(client);
}
- if(!close_only)
+ if(!close_only) {
free(sockets);
- sockets = NULL;
+ sockets = NULL;
+ }
}