* 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"
#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;
return NULL;
}
-void free_sockets() {
+void free_sockets(int close_only) {
if(!sockets) return;
struct ClientSocket *client, *next;
for (client = sockets->data; client; client = next) {
next = client->next;
- destroy_socket(client);
+ if(close_only) {
+ if((client->flags & SOCKET_FLAG_CONNECTED))
+ iohandler_printf(client->iofd, "QUIT :[NeonServ %s.%d] shutdown requested.\n", NEONSERV_VERSION, patchlevel);
+ } else
+ destroy_socket(client);
+ }
+ if(!close_only) {
+ free(sockets);
+ sockets = NULL;
}
- free(sockets);
- sockets = NULL;
}